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 RUNTIME_VM_CODE_DESCRIPTORS_H_ | 5 #ifndef RUNTIME_VM_CODE_DESCRIPTORS_H_ |
6 #define RUNTIME_VM_CODE_DESCRIPTORS_H_ | 6 #define RUNTIME_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 explicit DescriptorList(intptr_t initial_capacity) | 18 explicit DescriptorList(intptr_t initial_capacity) |
19 : encoded_data_(initial_capacity), | 19 : encoded_data_(initial_capacity), |
20 prev_pc_offset(0), | 20 prev_pc_offset(0), |
21 prev_deopt_id(0), | 21 prev_deopt_id(0), |
22 prev_token_pos(0) {} | 22 prev_token_pos(0) {} |
23 | 23 |
24 ~DescriptorList() { } | 24 ~DescriptorList() {} |
25 | 25 |
26 void AddDescriptor(RawPcDescriptors::Kind kind, | 26 void AddDescriptor(RawPcDescriptors::Kind kind, |
27 intptr_t pc_offset, | 27 intptr_t pc_offset, |
28 intptr_t deopt_id, | 28 intptr_t deopt_id, |
29 TokenPosition token_pos, | 29 TokenPosition token_pos, |
30 intptr_t try_index); | 30 intptr_t try_index); |
31 | 31 |
32 RawPcDescriptors* FinalizePcDescriptors(uword entry_point); | 32 RawPcDescriptors* FinalizePcDescriptors(uword entry_point); |
33 | 33 |
34 private: | 34 private: |
35 GrowableArray<uint8_t> encoded_data_; | 35 GrowableArray<uint8_t> encoded_data_; |
36 | 36 |
37 intptr_t prev_pc_offset; | 37 intptr_t prev_pc_offset; |
38 intptr_t prev_deopt_id; | 38 intptr_t prev_deopt_id; |
39 intptr_t prev_token_pos; | 39 intptr_t prev_token_pos; |
40 | 40 |
41 DISALLOW_COPY_AND_ASSIGN(DescriptorList); | 41 DISALLOW_COPY_AND_ASSIGN(DescriptorList); |
42 }; | 42 }; |
43 | 43 |
44 | 44 |
45 class CodeSourceMapBuilder : public ZoneAllocated { | 45 class CodeSourceMapBuilder : public ZoneAllocated { |
46 public: | 46 public: |
47 explicit CodeSourceMapBuilder(intptr_t initial_capacity = 64) | 47 explicit CodeSourceMapBuilder(intptr_t initial_capacity = 64) |
48 : encoded_data_(initial_capacity), | 48 : encoded_data_(initial_capacity), prev_pc_offset(0), prev_token_pos(0) {} |
49 prev_pc_offset(0), | |
50 prev_token_pos(0) {} | |
51 | 49 |
52 ~CodeSourceMapBuilder() { } | 50 ~CodeSourceMapBuilder() {} |
53 | 51 |
54 void AddEntry(intptr_t pc_offset, TokenPosition token_pos); | 52 void AddEntry(intptr_t pc_offset, TokenPosition token_pos); |
55 | 53 |
56 RawCodeSourceMap* Finalize(); | 54 RawCodeSourceMap* Finalize(); |
57 | 55 |
58 private: | 56 private: |
59 GrowableArray<uint8_t> encoded_data_; | 57 GrowableArray<uint8_t> encoded_data_; |
60 | 58 |
61 intptr_t prev_pc_offset; | 59 intptr_t prev_pc_offset; |
62 intptr_t prev_token_pos; | 60 intptr_t prev_token_pos; |
63 | 61 |
64 DISALLOW_COPY_AND_ASSIGN(CodeSourceMapBuilder); | 62 DISALLOW_COPY_AND_ASSIGN(CodeSourceMapBuilder); |
65 }; | 63 }; |
66 | 64 |
67 | 65 |
68 class StackmapTableBuilder : public ZoneAllocated { | 66 class StackmapTableBuilder : public ZoneAllocated { |
69 public: | 67 public: |
70 StackmapTableBuilder() | 68 StackmapTableBuilder() |
71 : stack_map_(Stackmap::ZoneHandle()), | 69 : stack_map_(Stackmap::ZoneHandle()), |
72 list_(GrowableObjectArray::ZoneHandle( | 70 list_(GrowableObjectArray::ZoneHandle( |
73 GrowableObjectArray::New(Heap::kOld))) { } | 71 GrowableObjectArray::New(Heap::kOld))) {} |
74 ~StackmapTableBuilder() { } | 72 ~StackmapTableBuilder() {} |
75 | 73 |
76 void AddEntry(intptr_t pc_offset, | 74 void AddEntry(intptr_t pc_offset, |
77 BitmapBuilder* bitmap, | 75 BitmapBuilder* bitmap, |
78 intptr_t register_bit_count); | 76 intptr_t register_bit_count); |
79 | 77 |
80 bool Verify(); | 78 bool Verify(); |
81 | 79 |
82 RawArray* FinalizeStackmaps(const Code& code); | 80 RawArray* FinalizeStackmaps(const Code& code); |
83 | 81 |
84 private: | 82 private: |
85 intptr_t Length() const { return list_.Length(); } | 83 intptr_t Length() const { return list_.Length(); } |
86 RawStackmap* MapAt(intptr_t index) const; | 84 RawStackmap* MapAt(intptr_t index) const; |
87 | 85 |
88 Stackmap& stack_map_; | 86 Stackmap& stack_map_; |
89 GrowableObjectArray& list_; | 87 GrowableObjectArray& list_; |
90 DISALLOW_COPY_AND_ASSIGN(StackmapTableBuilder); | 88 DISALLOW_COPY_AND_ASSIGN(StackmapTableBuilder); |
91 }; | 89 }; |
92 | 90 |
93 | 91 |
94 class ExceptionHandlerList : public ZoneAllocated { | 92 class ExceptionHandlerList : public ZoneAllocated { |
95 public: | 93 public: |
96 struct HandlerDesc { | 94 struct HandlerDesc { |
97 intptr_t outer_try_index; // Try block in which this try block is nested. | 95 intptr_t outer_try_index; // Try block in which this try block is nested. |
98 intptr_t pc_offset; // Handler PC offset value. | 96 intptr_t pc_offset; // Handler PC offset value. |
99 const Array* handler_types; // Catch clause guards. | 97 const Array* handler_types; // Catch clause guards. |
100 bool needs_stacktrace; | 98 bool needs_stacktrace; |
101 }; | 99 }; |
102 | 100 |
103 ExceptionHandlerList() : list_() {} | 101 ExceptionHandlerList() : list_() {} |
104 | 102 |
105 intptr_t Length() const { | 103 intptr_t Length() const { return list_.length(); } |
106 return list_.length(); | |
107 } | |
108 | 104 |
109 void AddPlaceHolder() { | 105 void AddPlaceHolder() { |
110 struct HandlerDesc data; | 106 struct HandlerDesc data; |
111 data.outer_try_index = -1; | 107 data.outer_try_index = -1; |
112 data.pc_offset = ExceptionHandlers::kInvalidPcOffset; | 108 data.pc_offset = ExceptionHandlers::kInvalidPcOffset; |
113 data.handler_types = NULL; | 109 data.handler_types = NULL; |
114 data.needs_stacktrace = false; | 110 data.needs_stacktrace = false; |
115 list_.Add(data); | 111 list_.Add(data); |
116 } | 112 } |
117 | 113 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 RawExceptionHandlers* FinalizeExceptionHandlers(uword entry_point) const; | 155 RawExceptionHandlers* FinalizeExceptionHandlers(uword entry_point) const; |
160 | 156 |
161 private: | 157 private: |
162 GrowableArray<struct HandlerDesc> list_; | 158 GrowableArray<struct HandlerDesc> list_; |
163 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerList); | 159 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerList); |
164 }; | 160 }; |
165 | 161 |
166 } // namespace dart | 162 } // namespace dart |
167 | 163 |
168 #endif // RUNTIME_VM_CODE_DESCRIPTORS_H_ | 164 #endif // RUNTIME_VM_CODE_DESCRIPTORS_H_ |
OLD | NEW |