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 DECLARE_FLAG(bool, precompilation); | 9 DECLARE_FLAG(bool, precompilation); |
10 | 10 |
11 void DescriptorList::AddDescriptor(RawPcDescriptors::Kind kind, | 11 void DescriptorList::AddDescriptor(RawPcDescriptors::Kind kind, |
12 intptr_t pc_offset, | 12 intptr_t pc_offset, |
13 intptr_t deopt_id, | 13 intptr_t deopt_id, |
14 intptr_t token_pos, | 14 TokenPosition token_pos, |
15 intptr_t try_index) { | 15 intptr_t try_index) { |
16 ASSERT((kind == RawPcDescriptors::kRuntimeCall) || | 16 ASSERT((kind == RawPcDescriptors::kRuntimeCall) || |
17 (kind == RawPcDescriptors::kOther) || | 17 (kind == RawPcDescriptors::kOther) || |
18 (deopt_id != Thread::kNoDeoptId)); | 18 (deopt_id != Thread::kNoDeoptId)); |
19 | 19 |
20 // When precompiling, we only use pc descriptors for exceptions. | 20 // When precompiling, we only use pc descriptors for exceptions. |
21 if (!FLAG_precompilation || try_index != -1) { | 21 if (!FLAG_precompilation || try_index != -1) { |
22 intptr_t merged_kind_try = | 22 intptr_t merged_kind_try = |
23 RawPcDescriptors::MergedKindTry::Encode(kind, try_index); | 23 RawPcDescriptors::MergedKindTry::Encode(kind, try_index); |
24 | 24 |
25 PcDescriptors::EncodeInteger(&encoded_data_, merged_kind_try); | 25 PcDescriptors::EncodeInteger(&encoded_data_, merged_kind_try); |
26 PcDescriptors::EncodeInteger(&encoded_data_, pc_offset - prev_pc_offset); | 26 PcDescriptors::EncodeInteger(&encoded_data_, pc_offset - prev_pc_offset); |
27 PcDescriptors::EncodeInteger(&encoded_data_, deopt_id - prev_deopt_id); | 27 PcDescriptors::EncodeInteger(&encoded_data_, deopt_id - prev_deopt_id); |
28 PcDescriptors::EncodeInteger(&encoded_data_, token_pos - prev_token_pos); | 28 PcDescriptors::EncodeInteger(&encoded_data_, |
| 29 token_pos.value() - prev_token_pos); |
29 | 30 |
30 prev_pc_offset = pc_offset; | 31 prev_pc_offset = pc_offset; |
31 prev_deopt_id = deopt_id; | 32 prev_deopt_id = deopt_id; |
32 prev_token_pos = token_pos; | 33 prev_token_pos = token_pos.value(); |
33 } | 34 } |
34 } | 35 } |
35 | 36 |
36 | 37 |
37 RawPcDescriptors* DescriptorList::FinalizePcDescriptors(uword entry_point) { | 38 RawPcDescriptors* DescriptorList::FinalizePcDescriptors(uword entry_point) { |
38 if (encoded_data_.length() == 0) { | 39 if (encoded_data_.length() == 0) { |
39 return Object::empty_descriptors().raw(); | 40 return Object::empty_descriptors().raw(); |
40 } | 41 } |
41 return PcDescriptors::New(&encoded_data_); | 42 return PcDescriptors::New(&encoded_data_); |
42 } | 43 } |
43 | 44 |
44 | 45 |
45 | 46 |
46 void CodeSourceMapBuilder::AddEntry(intptr_t pc_offset, | 47 void CodeSourceMapBuilder::AddEntry(intptr_t pc_offset, |
47 intptr_t token_pos) { | 48 TokenPosition token_pos) { |
48 CodeSourceMap::EncodeInteger(&encoded_data_, pc_offset - prev_pc_offset); | 49 CodeSourceMap::EncodeInteger(&encoded_data_, pc_offset - prev_pc_offset); |
49 CodeSourceMap::EncodeInteger(&encoded_data_, token_pos - prev_token_pos); | 50 CodeSourceMap::EncodeInteger(&encoded_data_, |
| 51 token_pos.value() - prev_token_pos); |
50 | 52 |
51 prev_pc_offset = pc_offset; | 53 prev_pc_offset = pc_offset; |
52 prev_token_pos = token_pos; | 54 prev_token_pos = token_pos.value(); |
53 } | 55 } |
54 | 56 |
55 | 57 |
56 RawCodeSourceMap* CodeSourceMapBuilder::Finalize() { | 58 RawCodeSourceMap* CodeSourceMapBuilder::Finalize() { |
57 return CodeSourceMap::New(&encoded_data_); | 59 return CodeSourceMap::New(&encoded_data_); |
58 } | 60 } |
59 | 61 |
60 | 62 |
61 void StackmapTableBuilder::AddEntry(intptr_t pc_offset, | 63 void StackmapTableBuilder::AddEntry(intptr_t pc_offset, |
62 BitmapBuilder* bitmap, | 64 BitmapBuilder* bitmap, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 list_[i].needs_stacktrace, | 132 list_[i].needs_stacktrace, |
131 has_catch_all); | 133 has_catch_all); |
132 handlers.SetHandledTypes(i, *list_[i].handler_types); | 134 handlers.SetHandledTypes(i, *list_[i].handler_types); |
133 } | 135 } |
134 } | 136 } |
135 return handlers.raw(); | 137 return handlers.raw(); |
136 } | 138 } |
137 | 139 |
138 | 140 |
139 } // namespace dart | 141 } // namespace dart |
OLD | NEW |