| 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(PcDescriptors::Kind kind, | 9 void DescriptorList::AddDescriptor(PcDescriptors::Kind kind, |
| 10 intptr_t pc_offset, | 10 intptr_t pc_offset, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 (entry_point + PcOffset(i)), | 30 (entry_point + PcOffset(i)), |
| 31 Kind(i), | 31 Kind(i), |
| 32 NodeId(i), | 32 NodeId(i), |
| 33 TokenIndex(i), | 33 TokenIndex(i), |
| 34 TryIndex(i)); | 34 TryIndex(i)); |
| 35 } | 35 } |
| 36 return descriptors.raw(); | 36 return descriptors.raw(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 | 39 |
| 40 void StackmapBuilder::AddEntry(intptr_t pc_offset) { | 40 void StackmapTableBuilder::AddEntry(intptr_t pc_offset, |
| 41 stack_map_ = Stackmap::New(pc_offset, builder_); | 41 BitmapBuilder* bitmap) { |
| 42 stack_map_ = Stackmap::New(pc_offset, bitmap); |
| 42 list_.Add(stack_map_); | 43 list_.Add(stack_map_); |
| 43 } | 44 } |
| 44 | 45 |
| 45 | 46 |
| 46 bool StackmapBuilder::Verify() { | 47 bool StackmapTableBuilder::Verify() { |
| 47 intptr_t num_entries = Length(); | 48 intptr_t num_entries = Length(); |
| 48 Stackmap& map1 = Stackmap::Handle(); | 49 Stackmap& map1 = Stackmap::Handle(); |
| 49 Stackmap& map2 = Stackmap::Handle(); | 50 Stackmap& map2 = Stackmap::Handle(); |
| 50 for (intptr_t i = 1; i < num_entries; i++) { | 51 for (intptr_t i = 1; i < num_entries; i++) { |
| 51 map1 = Map(i - 1); | 52 map1 = Map(i - 1); |
| 52 map2 = Map(i); | 53 map2 = Map(i); |
| 53 // Ensure there are no duplicates and the entries are sorted. | 54 // Ensure there are no duplicates and the entries are sorted. |
| 54 if (map1.PC() >= map2.PC()) { | 55 if (map1.PC() >= map2.PC()) { |
| 55 return false; | 56 return false; |
| 56 } | 57 } |
| 57 } | 58 } |
| 58 return true; | 59 return true; |
| 59 } | 60 } |
| 60 | 61 |
| 61 | 62 |
| 62 RawArray* StackmapBuilder::FinalizeStackmaps(const Code& code) { | 63 RawArray* StackmapTableBuilder::FinalizeStackmaps(const Code& code) { |
| 63 ASSERT(Verify()); | 64 ASSERT(Verify()); |
| 64 intptr_t num_entries = Length(); | 65 intptr_t num_entries = Length(); |
| 65 uword entry_point = code.EntryPoint(); | 66 uword entry_point = code.EntryPoint(); |
| 66 if (num_entries == 0) { | 67 if (num_entries == 0) { |
| 67 return Array::Empty(); | 68 return Array::Empty(); |
| 68 } | 69 } |
| 69 for (intptr_t i = 0; i < num_entries; i++) { | 70 for (intptr_t i = 0; i < num_entries; i++) { |
| 70 stack_map_ = Map(i); | 71 stack_map_ = Map(i); |
| 71 stack_map_.SetPC(entry_point + stack_map_.PC()); | 72 stack_map_.SetPC(entry_point + stack_map_.PC()); |
| 72 stack_map_.SetCode(code); | 73 stack_map_.SetCode(code); |
| 73 } | 74 } |
| 74 return Array::MakeArray(list_); | 75 return Array::MakeArray(list_); |
| 75 } | 76 } |
| 76 | 77 |
| 77 | 78 |
| 78 RawStackmap* StackmapBuilder::Map(int index) const { | 79 RawStackmap* StackmapTableBuilder::Map(int index) const { |
| 79 Stackmap& map = Stackmap::Handle(); | 80 Stackmap& map = Stackmap::Handle(); |
| 80 map ^= list_.At(index); | 81 map ^= list_.At(index); |
| 81 return map.raw(); | 82 return map.raw(); |
| 82 } | 83 } |
| 83 | 84 |
| 84 } // namespace dart | 85 } // namespace dart |
| OLD | NEW |