| 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 struct PcDesc { |
| 19 intptr_t pc_offset; // PC offset value of the descriptor. | 19 intptr_t pc_offset; // PC offset value of the descriptor. |
| 20 PcDescriptors::Kind kind; // Descriptor kind (kDeopt, kOther). | 20 PcDescriptors::Kind kind; // Descriptor kind (kDeopt, kOther). |
| 21 intptr_t deopt_id; // Deoptimization id. | 21 intptr_t deopt_id; // Deoptimization id. |
| 22 intptr_t data; // Token position or deopt rason. | 22 intptr_t data; // Token position or deopt reason. |
| 23 intptr_t try_index; // Try block index of PC or deopt array index. | 23 intptr_t try_index; // Try block index of PC or deopt array index. |
| 24 void SetTokenPos(intptr_t value) { data = value; } | 24 void SetTokenPos(intptr_t value) { data = value; } |
| 25 intptr_t TokenPos() const { return data; } | 25 intptr_t TokenPos() const { return data; } |
| 26 void SetDeoptReason(DeoptReasonId value) { data = value; } | 26 void SetDeoptReason(ICData::DeoptReasonId value) { data = value; } |
| 27 DeoptReasonId DeoptReason() const { | 27 ICData::DeoptReasonId DeoptReason() const { |
| 28 return static_cast<DeoptReasonId>(data); | 28 ASSERT((0 <= data) && (data < ICData::ICData::kDeoptNumReasons)); |
| 29 return static_cast<ICData::DeoptReasonId>(data); |
| 29 } | 30 } |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 explicit DescriptorList(intptr_t initial_capacity) : list_(initial_capacity) { | 33 explicit DescriptorList(intptr_t initial_capacity) : list_(initial_capacity) { |
| 33 } | 34 } |
| 34 ~DescriptorList() { } | 35 ~DescriptorList() { } |
| 35 | 36 |
| 36 intptr_t Length() const { | 37 intptr_t Length() const { |
| 37 return list_.length(); | 38 return list_.length(); |
| 38 } | 39 } |
| 39 | 40 |
| 40 intptr_t PcOffset(intptr_t index) const { | 41 intptr_t PcOffset(intptr_t index) const { |
| 41 return list_[index].pc_offset; | 42 return list_[index].pc_offset; |
| 42 } | 43 } |
| 43 PcDescriptors::Kind Kind(intptr_t index) const { | 44 PcDescriptors::Kind Kind(intptr_t index) const { |
| 44 return list_[index].kind; | 45 return list_[index].kind; |
| 45 } | 46 } |
| 46 intptr_t DeoptId(intptr_t index) const { | 47 intptr_t DeoptId(intptr_t index) const { |
| 47 return list_[index].deopt_id; | 48 return list_[index].deopt_id; |
| 48 } | 49 } |
| 49 intptr_t TokenPos(intptr_t index) const { | 50 intptr_t TokenPos(intptr_t index) const { |
| 50 return list_[index].TokenPos(); | 51 return list_[index].TokenPos(); |
| 51 } | 52 } |
| 52 DeoptReasonId DeoptReason(intptr_t index) const { | 53 ICData::DeoptReasonId DeoptReason(intptr_t index) const { |
| 53 return list_[index].DeoptReason(); | 54 return list_[index].DeoptReason(); |
| 54 } | 55 } |
| 55 intptr_t TryIndex(intptr_t index) const { | 56 intptr_t TryIndex(intptr_t index) const { |
| 56 return list_[index].try_index; | 57 return list_[index].try_index; |
| 57 } | 58 } |
| 58 | 59 |
| 59 void AddDescriptor(PcDescriptors::Kind kind, | 60 void AddDescriptor(PcDescriptors::Kind kind, |
| 60 intptr_t pc_offset, | 61 intptr_t pc_offset, |
| 61 intptr_t deopt_id, | 62 intptr_t deopt_id, |
| 62 intptr_t token_index, | 63 intptr_t token_index, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 } | 178 } |
| 178 | 179 |
| 179 private: | 180 private: |
| 180 GrowableArray<struct HandlerDesc> list_; | 181 GrowableArray<struct HandlerDesc> list_; |
| 181 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerList); | 182 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerList); |
| 182 }; | 183 }; |
| 183 | 184 |
| 184 } // namespace dart | 185 } // namespace dart |
| 185 | 186 |
| 186 #endif // VM_CODE_DESCRIPTORS_H_ | 187 #endif // VM_CODE_DESCRIPTORS_H_ |
| OLD | NEW |