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