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 #include "vm/code_descriptors.h" | 5 #include "vm/code_descriptors.h" |
6 | 6 |
7 namespace dart { | 7 namespace dart { |
8 | 8 |
9 void DescriptorList::AddDescriptor(RawPcDescriptors::Kind kind, | 9 void DescriptorList::AddDescriptor(RawPcDescriptors::Kind kind, |
10 intptr_t pc_offset, | 10 intptr_t pc_offset, |
11 intptr_t deopt_id, | 11 intptr_t deopt_id, |
12 intptr_t token_index, | 12 intptr_t token_pos, |
13 intptr_t try_index) { | 13 intptr_t try_index) { |
14 ASSERT((kind == RawPcDescriptors::kRuntimeCall) || | 14 ASSERT((kind == RawPcDescriptors::kRuntimeCall) || |
15 (kind == RawPcDescriptors::kOther) || | 15 (kind == RawPcDescriptors::kOther) || |
16 (deopt_id != Isolate::kNoDeoptId)); | 16 (deopt_id != Isolate::kNoDeoptId)); |
17 struct PcDesc data; | 17 |
18 data.pc_offset = pc_offset; | 18 PcDescriptors::EncodeInteger(&delta_encoded_data_, |
19 data.kind = kind; | 19 static_cast<intptr_t>(kind)); |
20 data.deopt_id = deopt_id; | 20 PcDescriptors::EncodeInteger(&delta_encoded_data_, |
21 data.SetTokenPos(token_index); | 21 try_index); |
22 data.try_index = try_index; | 22 PcDescriptors::EncodeInteger(&delta_encoded_data_, |
23 list_.Add(data); | 23 pc_offset - prev_pc_offset); |
24 if (try_index >= 0) { | 24 PcDescriptors::EncodeInteger(&delta_encoded_data_, |
25 has_try_index_ = true; | 25 deopt_id - prev_deopt_id); |
26 } | 26 PcDescriptors::EncodeInteger(&delta_encoded_data_, |
| 27 token_pos - prev_token_pos); |
| 28 |
| 29 prev_pc_offset = pc_offset; |
| 30 prev_deopt_id = deopt_id; |
| 31 prev_token_pos = token_pos; |
27 } | 32 } |
28 | 33 |
29 | 34 |
30 RawPcDescriptors* DescriptorList::FinalizePcDescriptors(uword entry_point) { | 35 RawPcDescriptors* DescriptorList::FinalizePcDescriptors(uword entry_point) { |
31 intptr_t num_descriptors = Length(); | 36 return PcDescriptors::New(&delta_encoded_data_); |
32 const PcDescriptors& descriptors = | |
33 PcDescriptors::Handle(PcDescriptors::New(num_descriptors, | |
34 has_try_index_)); | |
35 for (intptr_t i = 0; i < num_descriptors; i++) { | |
36 descriptors.AddDescriptor(i, | |
37 PcOffset(i), | |
38 Kind(i), | |
39 DeoptId(i), | |
40 TokenPos(i), | |
41 TryIndex(i)); | |
42 } | |
43 return descriptors.raw(); | |
44 } | 37 } |
45 | 38 |
46 | 39 |
47 void StackmapTableBuilder::AddEntry(intptr_t pc_offset, | 40 void StackmapTableBuilder::AddEntry(intptr_t pc_offset, |
48 BitmapBuilder* bitmap, | 41 BitmapBuilder* bitmap, |
49 intptr_t register_bit_count) { | 42 intptr_t register_bit_count) { |
50 stack_map_ = Stackmap::New(pc_offset, bitmap, register_bit_count); | 43 stack_map_ = Stackmap::New(pc_offset, bitmap, register_bit_count); |
51 list_.Add(stack_map_, Heap::kOld); | 44 list_.Add(stack_map_, Heap::kOld); |
52 } | 45 } |
53 | 46 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 list_[i].needs_stacktrace, | 109 list_[i].needs_stacktrace, |
117 has_catch_all); | 110 has_catch_all); |
118 handlers.SetHandledTypes(i, *list_[i].handler_types); | 111 handlers.SetHandledTypes(i, *list_[i].handler_types); |
119 } | 112 } |
120 } | 113 } |
121 return handlers.raw(); | 114 return handlers.raw(); |
122 } | 115 } |
123 | 116 |
124 | 117 |
125 } // namespace dart | 118 } // namespace dart |
OLD | NEW |