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" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 | 54 |
55 intptr_t RawObject::SizeFromClass() const { | 55 intptr_t RawObject::SizeFromClass() const { |
56 Isolate* isolate = Isolate::Current(); | 56 Isolate* isolate = Isolate::Current(); |
57 NoHandleScope no_handles(isolate); | 57 NoHandleScope no_handles(isolate); |
58 | 58 |
59 // Only reasonable to be called on heap objects. | 59 // Only reasonable to be called on heap objects. |
60 ASSERT(IsHeapObject()); | 60 ASSERT(IsHeapObject()); |
61 | 61 |
62 RawClass* raw_class = isolate->class_table()->At(GetClassId()); | 62 intptr_t class_id = GetClassId(); |
| 63 RawClass* raw_class = isolate->class_table()->At(class_id); |
| 64 ASSERT(raw_class->ptr()->id_ == class_id); |
| 65 |
| 66 // Get the instance size out of the class. |
63 intptr_t instance_size = | 67 intptr_t instance_size = |
64 raw_class->ptr()->instance_size_in_words_ << kWordSizeLog2; | 68 raw_class->ptr()->instance_size_in_words_ << kWordSizeLog2; |
65 intptr_t class_id = raw_class->ptr()->id_; | |
66 | 69 |
67 if (instance_size == 0) { | 70 if (instance_size == 0) { |
68 switch (class_id) { | 71 switch (class_id) { |
69 case kCodeCid: { | 72 case kCodeCid: { |
70 const RawCode* raw_code = reinterpret_cast<const RawCode*>(this); | 73 const RawCode* raw_code = reinterpret_cast<const RawCode*>(this); |
71 intptr_t pointer_offsets_length = | 74 intptr_t pointer_offsets_length = |
72 raw_code->ptr()->pointer_offsets_length_; | 75 raw_code->ptr()->pointer_offsets_length_; |
73 instance_size = Code::InstanceSize(pointer_offsets_length); | 76 instance_size = Code::InstanceSize(pointer_offsets_length); |
74 break; | 77 break; |
75 } | 78 } |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 intptr_t RawUserTag::VisitUserTagPointers( | 891 intptr_t RawUserTag::VisitUserTagPointers( |
889 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { | 892 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { |
890 // Make sure that we got here with the tagged pointer as this. | 893 // Make sure that we got here with the tagged pointer as this. |
891 ASSERT(raw_obj->IsHeapObject()); | 894 ASSERT(raw_obj->IsHeapObject()); |
892 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 895 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
893 return UserTag::InstanceSize(); | 896 return UserTag::InstanceSize(); |
894 } | 897 } |
895 | 898 |
896 | 899 |
897 } // namespace dart | 900 } // namespace dart |
OLD | NEW |