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 19 matching lines...) Expand all Loading... |
30 return; | 30 return; |
31 } | 31 } |
32 // All Smi values are valid. | 32 // All Smi values are valid. |
33 if (!IsHeapObject()) { | 33 if (!IsHeapObject()) { |
34 return; | 34 return; |
35 } | 35 } |
36 // Validate that the tags_ field is sensible. | 36 // Validate that the tags_ field is sensible. |
37 uword tags = ptr()->tags_; | 37 uword tags = ptr()->tags_; |
38 intptr_t reserved = ReservedBits::decode(tags); | 38 intptr_t reserved = ReservedBits::decode(tags); |
39 if (reserved != 0) { | 39 if (reserved != 0) { |
40 FATAL1("Invalid tags field encountered %#"Px"\n", tags); | 40 FATAL1("Invalid tags field encountered %#" Px "\n", tags); |
41 } | 41 } |
42 intptr_t class_id = ClassIdTag::decode(tags); | 42 intptr_t class_id = ClassIdTag::decode(tags); |
43 if (!isolate->class_table()->IsValidIndex(class_id)) { | 43 if (!isolate->class_table()->IsValidIndex(class_id)) { |
44 FATAL1("Invalid class id encountered %"Pd"\n", class_id); | 44 FATAL1("Invalid class id encountered %" Pd "\n", class_id); |
45 } | 45 } |
46 intptr_t size = SizeTag::decode(tags); | 46 intptr_t size = SizeTag::decode(tags); |
47 if (size != 0 && size != SizeFromClass()) { | 47 if (size != 0 && size != SizeFromClass()) { |
48 FATAL1("Inconsistent class size encountered %"Pd"\n", size); | 48 FATAL1("Inconsistent class size encountered %" Pd "\n", size); |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 | 52 |
53 intptr_t RawObject::SizeFromClass() const { | 53 intptr_t RawObject::SizeFromClass() const { |
54 Isolate* isolate = Isolate::Current(); | 54 Isolate* isolate = Isolate::Current(); |
55 NoHandleScope no_handles(isolate); | 55 NoHandleScope no_handles(isolate); |
56 | 56 |
57 // Only reasonable to be called on heap objects. | 57 // Only reasonable to be called on heap objects. |
58 ASSERT(IsHeapObject()); | 58 ASSERT(IsHeapObject()); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 break; | 245 break; |
246 } | 246 } |
247 #undef RAW_VISITPOINTERS | 247 #undef RAW_VISITPOINTERS |
248 case kFreeListElement: { | 248 case kFreeListElement: { |
249 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this)); | 249 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this)); |
250 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); | 250 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); |
251 size = element->Size(); | 251 size = element->Size(); |
252 break; | 252 break; |
253 } | 253 } |
254 default: | 254 default: |
255 OS::Print("Class Id: %"Pd"\n", class_id); | 255 OS::Print("Class Id: %" Pd "\n", class_id); |
256 UNREACHABLE(); | 256 UNREACHABLE(); |
257 break; | 257 break; |
258 } | 258 } |
259 } else { | 259 } else { |
260 RawInstance* raw_obj = reinterpret_cast<RawInstance*>(this); | 260 RawInstance* raw_obj = reinterpret_cast<RawInstance*>(this); |
261 size = RawInstance::VisitInstancePointers(raw_obj, visitor); | 261 size = RawInstance::VisitInstancePointers(raw_obj, visitor); |
262 } | 262 } |
263 | 263 |
264 ASSERT(size != 0); | 264 ASSERT(size != 0); |
265 ASSERT(size == Size()); | 265 ASSERT(size == Size()); |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 | 802 |
803 intptr_t RawMirrorReference::VisitMirrorReferencePointers( | 803 intptr_t RawMirrorReference::VisitMirrorReferencePointers( |
804 RawMirrorReference* raw_obj, ObjectPointerVisitor* visitor) { | 804 RawMirrorReference* raw_obj, ObjectPointerVisitor* visitor) { |
805 // Make sure that we got here with the tagged pointer as this. | 805 // Make sure that we got here with the tagged pointer as this. |
806 ASSERT(raw_obj->IsHeapObject()); | 806 ASSERT(raw_obj->IsHeapObject()); |
807 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 807 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
808 return MirrorReference::InstanceSize(); | 808 return MirrorReference::InstanceSize(); |
809 } | 809 } |
810 | 810 |
811 } // namespace dart | 811 } // namespace dart |
OLD | NEW |