| 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/raw_object.h" | 5 #include "vm/raw_object.h" |
| 6 | 6 |
| 7 #include "vm/class_table.h" | 7 #include "vm/class_table.h" |
| 8 #include "vm/dart.h" | 8 #include "vm/dart.h" |
| 9 #include "vm/freelist.h" | 9 #include "vm/freelist.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| 11 #include "vm/object.h" | 11 #include "vm/object.h" |
| 12 #include "vm/visitor.h" | 12 #include "vm/visitor.h" |
| 13 | 13 |
| 14 | 14 |
| 15 namespace dart { | 15 namespace dart { |
| 16 | 16 |
| 17 #if defined(DEBUG) | 17 #if defined(DEBUG) |
| 18 DEFINE_FLAG(bool, validate_overwrite, true, "Verify overwritten fields."); | 18 DEFINE_FLAG(bool, validate_overwrite, true, "Verify overwritten fields."); |
| 19 #endif // DEBUG | 19 #endif // DEBUG |
| 20 | 20 |
| 21 const intptr_t RawPcDescriptors::kFullRecSize = | |
| 22 sizeof(RawPcDescriptors::PcDescriptorRec); | |
| 23 const intptr_t RawPcDescriptors::kCompressedRecSize = | |
| 24 sizeof(RawPcDescriptors::CompressedPcDescriptorRec); | |
| 25 | |
| 26 bool RawObject::IsVMHeapObject() const { | 21 bool RawObject::IsVMHeapObject() const { |
| 27 return Dart::vm_isolate()->heap()->Contains(ToAddr(this)); | 22 return Dart::vm_isolate()->heap()->Contains(ToAddr(this)); |
| 28 } | 23 } |
| 29 | 24 |
| 30 | 25 |
| 31 void RawObject::Validate(Isolate* isolate) const { | 26 void RawObject::Validate(Isolate* isolate) const { |
| 32 if (Object::void_class_ == reinterpret_cast<RawClass*>(kHeapObjectTag)) { | 27 if (Object::void_class_ == reinterpret_cast<RawClass*>(kHeapObjectTag)) { |
| 33 // Validation relies on properly initialized class classes. Skip if the | 28 // Validation relies on properly initialized class classes. Skip if the |
| 34 // VM is still being initialized. | 29 // VM is still being initialized. |
| 35 return; | 30 return; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 case kTypeArgumentsCid: { | 130 case kTypeArgumentsCid: { |
| 136 const RawTypeArguments* raw_array = | 131 const RawTypeArguments* raw_array = |
| 137 reinterpret_cast<const RawTypeArguments*>(this); | 132 reinterpret_cast<const RawTypeArguments*>(this); |
| 138 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); | 133 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); |
| 139 instance_size = TypeArguments::InstanceSize(array_length); | 134 instance_size = TypeArguments::InstanceSize(array_length); |
| 140 break; | 135 break; |
| 141 } | 136 } |
| 142 case kPcDescriptorsCid: { | 137 case kPcDescriptorsCid: { |
| 143 const RawPcDescriptors* raw_descriptors = | 138 const RawPcDescriptors* raw_descriptors = |
| 144 reinterpret_cast<const RawPcDescriptors*>(this); | 139 reinterpret_cast<const RawPcDescriptors*>(this); |
| 145 const intptr_t num_descriptors = raw_descriptors->ptr()->length_; | 140 intptr_t length = raw_descriptors->ptr()->length_; |
| 146 const intptr_t rec_size_in_bytes = | 141 instance_size = PcDescriptors::InstanceSize(length); |
| 147 raw_descriptors->ptr()->record_size_in_bytes_; | |
| 148 instance_size = PcDescriptors::InstanceSize(num_descriptors, | |
| 149 rec_size_in_bytes); | |
| 150 break; | 142 break; |
| 151 } | 143 } |
| 152 case kStackmapCid: { | 144 case kStackmapCid: { |
| 153 const RawStackmap* map = reinterpret_cast<const RawStackmap*>(this); | 145 const RawStackmap* map = reinterpret_cast<const RawStackmap*>(this); |
| 154 intptr_t length = map->ptr()->length_; | 146 intptr_t length = map->ptr()->length_; |
| 155 instance_size = Stackmap::InstanceSize(length); | 147 instance_size = Stackmap::InstanceSize(length); |
| 156 break; | 148 break; |
| 157 } | 149 } |
| 158 case kLocalVarDescriptorsCid: { | 150 case kLocalVarDescriptorsCid: { |
| 159 const RawLocalVarDescriptors* raw_descriptors = | 151 const RawLocalVarDescriptors* raw_descriptors = |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 uword end_pc = start_pc + raw_instr->ptr()->size_; | 540 uword end_pc = start_pc + raw_instr->ptr()->size_; |
| 549 ASSERT(end_pc > start_pc); | 541 ASSERT(end_pc > start_pc); |
| 550 if ((pc >= start_pc) && (pc < end_pc)) { | 542 if ((pc >= start_pc) && (pc < end_pc)) { |
| 551 return true; | 543 return true; |
| 552 } | 544 } |
| 553 } | 545 } |
| 554 return false; | 546 return false; |
| 555 } | 547 } |
| 556 | 548 |
| 557 | 549 |
| 558 intptr_t RawPcDescriptors::RecordSize(bool has_try_index) { | |
| 559 return has_try_index ? RawPcDescriptors::kFullRecSize | |
| 560 : RawPcDescriptors::kCompressedRecSize; | |
| 561 } | |
| 562 | |
| 563 | |
| 564 intptr_t RawPcDescriptors::VisitPcDescriptorsPointers( | 550 intptr_t RawPcDescriptors::VisitPcDescriptorsPointers( |
| 565 RawPcDescriptors* raw_obj, ObjectPointerVisitor* visitor) { | 551 RawPcDescriptors* raw_obj, ObjectPointerVisitor* visitor) { |
| 566 return PcDescriptors::InstanceSize(raw_obj->ptr()->length_, | 552 return PcDescriptors::InstanceSize(raw_obj->ptr()->length_); |
| 567 raw_obj->ptr()->record_size_in_bytes_); | |
| 568 } | 553 } |
| 569 | 554 |
| 570 | 555 |
| 571 intptr_t RawStackmap::VisitStackmapPointers(RawStackmap* raw_obj, | 556 intptr_t RawStackmap::VisitStackmapPointers(RawStackmap* raw_obj, |
| 572 ObjectPointerVisitor* visitor) { | 557 ObjectPointerVisitor* visitor) { |
| 573 return Stackmap::InstanceSize(raw_obj->ptr()->length_); | 558 return Stackmap::InstanceSize(raw_obj->ptr()->length_); |
| 574 } | 559 } |
| 575 | 560 |
| 576 | 561 |
| 577 intptr_t RawLocalVarDescriptors::VisitLocalVarDescriptorsPointers( | 562 intptr_t RawLocalVarDescriptors::VisitLocalVarDescriptorsPointers( |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 intptr_t RawUserTag::VisitUserTagPointers( | 912 intptr_t RawUserTag::VisitUserTagPointers( |
| 928 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { | 913 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { |
| 929 // Make sure that we got here with the tagged pointer as this. | 914 // Make sure that we got here with the tagged pointer as this. |
| 930 ASSERT(raw_obj->IsHeapObject()); | 915 ASSERT(raw_obj->IsHeapObject()); |
| 931 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 916 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 932 return UserTag::InstanceSize(); | 917 return UserTag::InstanceSize(); |
| 933 } | 918 } |
| 934 | 919 |
| 935 | 920 |
| 936 } // namespace dart | 921 } // namespace dart |
| OLD | NEW |