| 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/freelist.h" | 8 #include "vm/freelist.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 | 42 |
| 43 intptr_t RawObject::SizeFromClass() const { | 43 intptr_t RawObject::SizeFromClass() const { |
| 44 Isolate* isolate = Isolate::Current(); | 44 Isolate* isolate = Isolate::Current(); |
| 45 NoHandleScope no_handles(isolate); | 45 NoHandleScope no_handles(isolate); |
| 46 | 46 |
| 47 // Only reasonable to be called on heap objects. | 47 // Only reasonable to be called on heap objects. |
| 48 ASSERT(IsHeapObject()); | 48 ASSERT(IsHeapObject()); |
| 49 | 49 |
| 50 RawClass* raw_class = isolate->class_table()->At(GetClassId()); | 50 RawClass* raw_class = isolate->class_table()->At(GetClassId()); |
| 51 intptr_t instance_size = raw_class->ptr()->instance_size_; | 51 intptr_t instance_size = |
| 52 raw_class->ptr()->instance_size_in_words_ << kWordSizeLog2; |
| 52 intptr_t class_id = raw_class->ptr()->id_; | 53 intptr_t class_id = raw_class->ptr()->id_; |
| 53 | 54 |
| 54 if (instance_size == 0) { | 55 if (instance_size == 0) { |
| 55 switch (class_id) { | 56 switch (class_id) { |
| 56 case kCodeCid: { | 57 case kCodeCid: { |
| 57 const RawCode* raw_code = reinterpret_cast<const RawCode*>(this); | 58 const RawCode* raw_code = reinterpret_cast<const RawCode*>(this); |
| 58 intptr_t pointer_offsets_length = | 59 intptr_t pointer_offsets_length = |
| 59 raw_code->ptr()->pointer_offsets_length_; | 60 raw_code->ptr()->pointer_offsets_length_; |
| 60 instance_size = Code::InstanceSize(pointer_offsets_length); | 61 instance_size = Code::InstanceSize(pointer_offsets_length); |
| 61 break; | 62 break; |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 | 592 |
| 592 intptr_t RawInstance::VisitInstancePointers(RawInstance* raw_obj, | 593 intptr_t RawInstance::VisitInstancePointers(RawInstance* raw_obj, |
| 593 ObjectPointerVisitor* visitor) { | 594 ObjectPointerVisitor* visitor) { |
| 594 // Make sure that we got here with the tagged pointer as this. | 595 // Make sure that we got here with the tagged pointer as this. |
| 595 ASSERT(raw_obj->IsHeapObject()); | 596 ASSERT(raw_obj->IsHeapObject()); |
| 596 uword tags = raw_obj->ptr()->tags_; | 597 uword tags = raw_obj->ptr()->tags_; |
| 597 intptr_t instance_size = SizeTag::decode(tags); | 598 intptr_t instance_size = SizeTag::decode(tags); |
| 598 if (instance_size == 0) { | 599 if (instance_size == 0) { |
| 599 RawClass* cls = | 600 RawClass* cls = |
| 600 visitor->isolate()->class_table()->At(raw_obj->GetClassId()); | 601 visitor->isolate()->class_table()->At(raw_obj->GetClassId()); |
| 601 instance_size = cls->ptr()->instance_size_; | 602 instance_size = cls->ptr()->instance_size_in_words_ << kWordSizeLog2; |
| 602 } | 603 } |
| 603 | 604 |
| 604 // Calculate the first and last raw object pointer fields. | 605 // Calculate the first and last raw object pointer fields. |
| 605 uword obj_addr = RawObject::ToAddr(raw_obj); | 606 uword obj_addr = RawObject::ToAddr(raw_obj); |
| 606 uword from = obj_addr + sizeof(RawObject); | 607 uword from = obj_addr + sizeof(RawObject); |
| 607 uword to = obj_addr + instance_size - kWordSize; | 608 uword to = obj_addr + instance_size - kWordSize; |
| 608 visitor->VisitPointers(reinterpret_cast<RawObject**>(from), | 609 visitor->VisitPointers(reinterpret_cast<RawObject**>(from), |
| 609 reinterpret_cast<RawObject**>(to)); | 610 reinterpret_cast<RawObject**>(to)); |
| 610 return instance_size; | 611 return instance_size; |
| 611 } | 612 } |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 | 962 |
| 962 intptr_t RawWeakProperty::VisitWeakPropertyPointers( | 963 intptr_t RawWeakProperty::VisitWeakPropertyPointers( |
| 963 RawWeakProperty* raw_obj, ObjectPointerVisitor* visitor) { | 964 RawWeakProperty* raw_obj, ObjectPointerVisitor* visitor) { |
| 964 // Make sure that we got here with the tagged pointer as this. | 965 // Make sure that we got here with the tagged pointer as this. |
| 965 ASSERT(raw_obj->IsHeapObject()); | 966 ASSERT(raw_obj->IsHeapObject()); |
| 966 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 967 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 967 return WeakProperty::InstanceSize(); | 968 return WeakProperty::InstanceSize(); |
| 968 } | 969 } |
| 969 | 970 |
| 970 } // namespace dart | 971 } // namespace dart |
| OLD | NEW |