| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #ifndef VM_CODE_DESCRIPTORS_H_ |
| 6 #define VM_CODE_DESCRIPTORS_H_ |
| 7 |
| 8 #include "vm/globals.h" |
| 9 #include "vm/growable_array.h" |
| 10 #include "vm/object.h" |
| 11 |
| 12 namespace dart { |
| 13 |
| 14 class DescriptorList : public ZoneAllocated { |
| 15 public: |
| 16 struct PcDesc { |
| 17 intptr_t pc_offset; // PC offset value of the descriptor. |
| 18 PcDescriptors::Kind kind; // Descriptor kind (kDeopt, kOther). |
| 19 intptr_t node_id; // AST node id. |
| 20 intptr_t token_index; // Token position in source of PC. |
| 21 intptr_t try_index; // Try block index of PC. |
| 22 }; |
| 23 |
| 24 DescriptorList() : list_() { |
| 25 } |
| 26 ~DescriptorList() { } |
| 27 |
| 28 intptr_t Length() const { |
| 29 return list_.length(); |
| 30 } |
| 31 |
| 32 intptr_t PcOffset(int index) const { |
| 33 return list_[index].pc_offset; |
| 34 } |
| 35 PcDescriptors::Kind Kind(int index) const { |
| 36 return list_[index].kind; |
| 37 } |
| 38 intptr_t NodeId(int index) const { |
| 39 return list_[index].node_id; |
| 40 } |
| 41 intptr_t TokenIndex(int index) const { |
| 42 return list_[index].token_index; |
| 43 } |
| 44 intptr_t TryIndex(int index) const { |
| 45 return list_[index].try_index; |
| 46 } |
| 47 |
| 48 void AddDescriptor(PcDescriptors::Kind kind, |
| 49 intptr_t pc_offset, |
| 50 intptr_t node_id, |
| 51 intptr_t token_index, |
| 52 intptr_t try_index); |
| 53 |
| 54 RawPcDescriptors* FinalizePcDescriptors(uword entry_point); |
| 55 |
| 56 private: |
| 57 GrowableArray<struct PcDesc> list_; |
| 58 DISALLOW_COPY_AND_ASSIGN(DescriptorList); |
| 59 }; |
| 60 |
| 61 |
| 62 class StackmapBuilder : public ZoneAllocated { |
| 63 public: |
| 64 StackmapBuilder() : |
| 65 builder_(new BitmapBuilder()), |
| 66 code_(Code::ZoneHandle()), |
| 67 stack_map_(Stackmap::ZoneHandle()), |
| 68 list_(GrowableObjectArray::ZoneHandle(GrowableObjectArray::New())) { } |
| 69 ~StackmapBuilder() { } |
| 70 |
| 71 // Gets state of stack slot (object or regular value). |
| 72 bool IsSlotObject(intptr_t stack_slot) const { |
| 73 ASSERT(builder_ != NULL); |
| 74 return builder_->Get(stack_slot); |
| 75 } |
| 76 // Sets stack slot as containing an object. |
| 77 void SetSlotAsObject(intptr_t stack_slot) { |
| 78 ASSERT(builder_ != NULL); |
| 79 builder_->Set(stack_slot, true); |
| 80 } |
| 81 // Sets stack slot as containing regular value. |
| 82 void SetSlotAsValue(intptr_t stack_slot) { |
| 83 ASSERT(builder_ != NULL); |
| 84 builder_->Set(stack_slot, false); |
| 85 } |
| 86 // Sets min..max (inclusive) as stack slots containing objects. |
| 87 void SetSlotRangeAsObject(intptr_t min_stack_slot, intptr_t max_stack_slot) { |
| 88 ASSERT(builder_ != NULL); |
| 89 builder_->SetRange(min_stack_slot, max_stack_slot, true); |
| 90 } |
| 91 // Sets min..max (inclusive) as stack slots containing regular values. |
| 92 void SetSlotRangeAsValue(intptr_t min_stack_slot, intptr_t max_stack_slot) { |
| 93 ASSERT(builder_ != NULL); |
| 94 builder_->SetRange(min_stack_slot, max_stack_slot, false); |
| 95 } |
| 96 |
| 97 void AddEntry(intptr_t pc_offset); |
| 98 |
| 99 bool Verify(); |
| 100 |
| 101 RawArray* FinalizeStackmaps(const Code& code); |
| 102 |
| 103 private: |
| 104 intptr_t Length() const { return list_.Length(); } |
| 105 RawStackmap* Map(int index) const; |
| 106 |
| 107 BitmapBuilder* builder_; |
| 108 Code& code_; |
| 109 Stackmap& stack_map_; |
| 110 GrowableObjectArray& list_; |
| 111 DISALLOW_COPY_AND_ASSIGN(StackmapBuilder); |
| 112 }; |
| 113 |
| 114 } // namespace dart |
| 115 |
| 116 #endif // VM_CODE_DESCRIPTORS_H_ |
| OLD | NEW |