| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 return; | 58 return; |
| 59 } | 59 } |
| 60 intptr_t size = SizeTag::decode(tags); | 60 intptr_t size = SizeTag::decode(tags); |
| 61 if (size != 0 && size != SizeFromClass()) { | 61 if (size != 0 && size != SizeFromClass()) { |
| 62 FATAL1("Inconsistent class size encountered %" Pd "\n", size); | 62 FATAL1("Inconsistent class size encountered %" Pd "\n", size); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 | 66 |
| 67 intptr_t RawObject::SizeFromClass() const { | 67 intptr_t RawObject::SizeFromClass() const { |
| 68 Isolate* isolate = Isolate::Current(); | 68 return SizeFromClass(Isolate::Current()->class_table()); |
| 69 NoHandleScope no_handles(isolate); | 69 } |
| 70 | 70 |
| 71 |
| 72 intptr_t RawObject::SizeFromClass(const ClassTable* class_table) const { |
| 71 // Only reasonable to be called on heap objects. | 73 // Only reasonable to be called on heap objects. |
| 72 ASSERT(IsHeapObject()); | 74 ASSERT(IsHeapObject()); |
| 73 | 75 |
| 74 intptr_t class_id = GetClassId(); | 76 intptr_t class_id = GetClassId(); |
| 75 ClassTable* class_table = isolate->class_table(); | |
| 76 #if defined(DEBUG) | 77 #if defined(DEBUG) |
| 77 if (!class_table->IsValidIndex(class_id) || | 78 if (!class_table->IsValidIndex(class_id) || |
| 78 !class_table->HasValidClassAt(class_id)) { | 79 !class_table->HasValidClassAt(class_id)) { |
| 79 FATAL2("Invalid class id: %" Pd " from tags %" Px "\n", | 80 FATAL2("Invalid class id: %" Pd " from tags %" Px "\n", |
| 80 class_id, ptr()->tags_); | 81 class_id, ptr()->tags_); |
| 81 } | 82 } |
| 82 #endif // DEBUG | 83 #endif // DEBUG |
| 83 RawClass* raw_class = class_table->At(class_id); | 84 RawClass* raw_class = class_table->At(class_id); |
| 84 ASSERT(raw_class->ptr()->id_ == class_id); | 85 ASSERT(raw_class->ptr()->id_ == class_id); |
| 85 | 86 |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 intptr_t RawUserTag::VisitUserTagPointers( | 937 intptr_t RawUserTag::VisitUserTagPointers( |
| 937 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { | 938 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { |
| 938 // Make sure that we got here with the tagged pointer as this. | 939 // Make sure that we got here with the tagged pointer as this. |
| 939 ASSERT(raw_obj->IsHeapObject()); | 940 ASSERT(raw_obj->IsHeapObject()); |
| 940 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 941 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 941 return UserTag::InstanceSize(); | 942 return UserTag::InstanceSize(); |
| 942 } | 943 } |
| 943 | 944 |
| 944 | 945 |
| 945 } // namespace dart | 946 } // namespace dart |
| OLD | NEW |