| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_CODE_DESCRIPTORS_H_ | 5 #ifndef VM_CODE_DESCRIPTORS_H_ |
| 6 #define VM_CODE_DESCRIPTORS_H_ | 6 #define VM_CODE_DESCRIPTORS_H_ |
| 7 | 7 |
| 8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
| 9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| 11 #include "vm/growable_array.h" | 11 #include "vm/growable_array.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 class DescriptorList : public ZoneAllocated { | 16 class DescriptorList : public ZoneAllocated { |
| 17 public: | 17 public: |
| 18 struct PcDesc { | 18 explicit DescriptorList(intptr_t initial_capacity) |
| 19 intptr_t pc_offset; // PC offset value of the descriptor. | 19 : encoded_data_(initial_capacity), |
| 20 RawPcDescriptors::Kind kind; // Descriptor kind (kDeopt, kOther). | 20 prev_pc_offset(0), |
| 21 intptr_t deopt_id; // Deoptimization id. | 21 prev_deopt_id(0), |
| 22 intptr_t data; // Token position or deopt reason. | 22 prev_token_pos(0) {} |
| 23 intptr_t try_index; // Try block index of PC or deopt array index. | |
| 24 void SetTokenPos(intptr_t value) { data = value; } | |
| 25 intptr_t TokenPos() const { return data; } | |
| 26 void SetDeoptReason(ICData::DeoptReasonId value) { data = value; } | |
| 27 ICData::DeoptReasonId DeoptReason() const { | |
| 28 ASSERT((0 <= data) && (data < ICData::kDeoptNumReasons)); | |
| 29 return static_cast<ICData::DeoptReasonId>(data); | |
| 30 } | |
| 31 }; | |
| 32 | 23 |
| 33 explicit DescriptorList(intptr_t initial_capacity) | |
| 34 : list_(initial_capacity), has_try_index_(false) {} | |
| 35 ~DescriptorList() { } | 24 ~DescriptorList() { } |
| 36 | 25 |
| 37 intptr_t Length() const { | |
| 38 return list_.length(); | |
| 39 } | |
| 40 | |
| 41 intptr_t PcOffset(intptr_t index) const { | |
| 42 return list_[index].pc_offset; | |
| 43 } | |
| 44 RawPcDescriptors::Kind Kind(intptr_t index) const { | |
| 45 return list_[index].kind; | |
| 46 } | |
| 47 intptr_t DeoptId(intptr_t index) const { | |
| 48 return list_[index].deopt_id; | |
| 49 } | |
| 50 intptr_t TokenPos(intptr_t index) const { | |
| 51 return list_[index].TokenPos(); | |
| 52 } | |
| 53 ICData::DeoptReasonId DeoptReason(intptr_t index) const { | |
| 54 return list_[index].DeoptReason(); | |
| 55 } | |
| 56 intptr_t TryIndex(intptr_t index) const { | |
| 57 return (has_try_index_) ? list_[index].try_index : -1; | |
| 58 } | |
| 59 | |
| 60 void AddDescriptor(RawPcDescriptors::Kind kind, | 26 void AddDescriptor(RawPcDescriptors::Kind kind, |
| 61 intptr_t pc_offset, | 27 intptr_t pc_offset, |
| 62 intptr_t deopt_id, | 28 intptr_t deopt_id, |
| 63 intptr_t token_index, | 29 intptr_t token_pos, |
| 64 intptr_t try_index); | 30 intptr_t try_index); |
| 65 | 31 |
| 66 RawPcDescriptors* FinalizePcDescriptors(uword entry_point); | 32 RawPcDescriptors* FinalizePcDescriptors(uword entry_point); |
| 67 | 33 |
| 68 private: | 34 private: |
| 69 GrowableArray<struct PcDesc> list_; | 35 GrowableArray<uint8_t> encoded_data_; |
| 70 bool has_try_index_; | 36 |
| 37 intptr_t prev_pc_offset; |
| 38 intptr_t prev_deopt_id; |
| 39 intptr_t prev_token_pos; |
| 40 |
| 71 DISALLOW_COPY_AND_ASSIGN(DescriptorList); | 41 DISALLOW_COPY_AND_ASSIGN(DescriptorList); |
| 72 }; | 42 }; |
| 73 | 43 |
| 74 | 44 |
| 75 class StackmapTableBuilder : public ZoneAllocated { | 45 class StackmapTableBuilder : public ZoneAllocated { |
| 76 public: | 46 public: |
| 77 StackmapTableBuilder() | 47 StackmapTableBuilder() |
| 78 : stack_map_(Stackmap::ZoneHandle()), | 48 : stack_map_(Stackmap::ZoneHandle()), |
| 79 list_(GrowableObjectArray::ZoneHandle( | 49 list_(GrowableObjectArray::ZoneHandle( |
| 80 GrowableObjectArray::New(Heap::kOld))) { } | 50 GrowableObjectArray::New(Heap::kOld))) { } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 RawExceptionHandlers* FinalizeExceptionHandlers(uword entry_point) const; | 135 RawExceptionHandlers* FinalizeExceptionHandlers(uword entry_point) const; |
| 166 | 136 |
| 167 private: | 137 private: |
| 168 GrowableArray<struct HandlerDesc> list_; | 138 GrowableArray<struct HandlerDesc> list_; |
| 169 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerList); | 139 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerList); |
| 170 }; | 140 }; |
| 171 | 141 |
| 172 } // namespace dart | 142 } // namespace dart |
| 173 | 143 |
| 174 #endif // VM_CODE_DESCRIPTORS_H_ | 144 #endif // VM_CODE_DESCRIPTORS_H_ |
| OLD | NEW |