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 RawPcDescriptors::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 reason. | 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(ICData::DeoptReasonId value) { data = value; } | 26 void SetDeoptReason(ICData::DeoptReasonId value) { data = value; } |
27 ICData::DeoptReasonId DeoptReason() const { | 27 ICData::DeoptReasonId DeoptReason() const { |
28 ASSERT((0 <= data) && (data < ICData::kDeoptNumReasons)); | 28 ASSERT((0 <= data) && (data < ICData::kDeoptNumReasons)); |
29 return static_cast<ICData::DeoptReasonId>(data); | 29 return static_cast<ICData::DeoptReasonId>(data); |
30 } | 30 } |
31 }; | 31 }; |
32 | 32 |
33 explicit DescriptorList(intptr_t initial_capacity) : list_(initial_capacity) { | 33 explicit DescriptorList(intptr_t initial_capacity) : list_(initial_capacity) { |
34 } | 34 } |
35 ~DescriptorList() { } | 35 ~DescriptorList() { } |
36 | 36 |
37 intptr_t Length() const { | 37 intptr_t Length() const { |
38 return list_.length(); | 38 return list_.length(); |
39 } | 39 } |
40 | 40 |
41 intptr_t PcOffset(intptr_t index) const { | 41 intptr_t PcOffset(intptr_t index) const { |
42 return list_[index].pc_offset; | 42 return list_[index].pc_offset; |
43 } | 43 } |
44 PcDescriptors::Kind Kind(intptr_t index) const { | 44 RawPcDescriptors::Kind Kind(intptr_t index) const { |
45 return list_[index].kind; | 45 return list_[index].kind; |
46 } | 46 } |
47 intptr_t DeoptId(intptr_t index) const { | 47 intptr_t DeoptId(intptr_t index) const { |
48 return list_[index].deopt_id; | 48 return list_[index].deopt_id; |
49 } | 49 } |
50 intptr_t TokenPos(intptr_t index) const { | 50 intptr_t TokenPos(intptr_t index) const { |
51 return list_[index].TokenPos(); | 51 return list_[index].TokenPos(); |
52 } | 52 } |
53 ICData::DeoptReasonId DeoptReason(intptr_t index) const { | 53 ICData::DeoptReasonId DeoptReason(intptr_t index) const { |
54 return list_[index].DeoptReason(); | 54 return list_[index].DeoptReason(); |
55 } | 55 } |
56 intptr_t TryIndex(intptr_t index) const { | 56 intptr_t TryIndex(intptr_t index) const { |
57 return list_[index].try_index; | 57 return list_[index].try_index; |
58 } | 58 } |
59 | 59 |
60 void AddDescriptor(PcDescriptors::Kind kind, | 60 void AddDescriptor(RawPcDescriptors::Kind kind, |
61 intptr_t pc_offset, | 61 intptr_t pc_offset, |
62 intptr_t deopt_id, | 62 intptr_t deopt_id, |
63 intptr_t token_index, | 63 intptr_t token_index, |
64 intptr_t try_index); | 64 intptr_t try_index); |
65 | 65 |
66 RawPcDescriptors* FinalizePcDescriptors(uword entry_point); | 66 RawPcDescriptors* FinalizePcDescriptors(uword entry_point); |
67 | 67 |
68 private: | 68 private: |
69 GrowableArray<struct PcDesc> list_; | 69 GrowableArray<struct PcDesc> list_; |
70 DISALLOW_COPY_AND_ASSIGN(DescriptorList); | 70 DISALLOW_COPY_AND_ASSIGN(DescriptorList); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 178 } |
179 | 179 |
180 private: | 180 private: |
181 GrowableArray<struct HandlerDesc> list_; | 181 GrowableArray<struct HandlerDesc> list_; |
182 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerList); | 182 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerList); |
183 }; | 183 }; |
184 | 184 |
185 } // namespace dart | 185 } // namespace dart |
186 | 186 |
187 #endif // VM_CODE_DESCRIPTORS_H_ | 187 #endif // VM_CODE_DESCRIPTORS_H_ |
OLD | NEW |