| 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/become.h" |
| 7 #include "vm/class_table.h" | 8 #include "vm/class_table.h" |
| 8 #include "vm/dart.h" | 9 #include "vm/dart.h" |
| 9 #include "vm/freelist.h" | 10 #include "vm/freelist.h" |
| 10 #include "vm/isolate.h" | 11 #include "vm/isolate.h" |
| 11 #include "vm/object.h" | 12 #include "vm/object.h" |
| 12 #include "vm/visitor.h" | 13 #include "vm/visitor.h" |
| 13 | 14 |
| 14 | 15 |
| 15 namespace dart { | 16 namespace dart { |
| 16 | 17 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 intptr_t num_handlers = raw_handlers->ptr()->num_entries_; | 171 intptr_t num_handlers = raw_handlers->ptr()->num_entries_; |
| 171 instance_size = ExceptionHandlers::InstanceSize(num_handlers); | 172 instance_size = ExceptionHandlers::InstanceSize(num_handlers); |
| 172 break; | 173 break; |
| 173 } | 174 } |
| 174 case kFreeListElement: { | 175 case kFreeListElement: { |
| 175 uword addr = RawObject::ToAddr(this); | 176 uword addr = RawObject::ToAddr(this); |
| 176 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); | 177 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); |
| 177 instance_size = element->Size(); | 178 instance_size = element->Size(); |
| 178 break; | 179 break; |
| 179 } | 180 } |
| 181 case kForwardingCorpse: { |
| 182 uword addr = RawObject::ToAddr(this); |
| 183 ForwardingCorpse* element = reinterpret_cast<ForwardingCorpse*>(addr); |
| 184 instance_size = element->Size(); |
| 185 break; |
| 186 } |
| 180 default: { | 187 default: { |
| 181 // Get the (constant) instance size out of the class object. | 188 // Get the (constant) instance size out of the class object. |
| 182 // TODO(koda): Add Size(ClassTable*) interface to allow caching in loops. | 189 // TODO(koda): Add Size(ClassTable*) interface to allow caching in loops. |
| 183 Isolate* isolate = Isolate::Current(); | 190 Isolate* isolate = Isolate::Current(); |
| 184 #if defined(DEBUG) | 191 #if defined(DEBUG) |
| 185 ClassTable* class_table = isolate->class_table(); | 192 ClassTable* class_table = isolate->class_table(); |
| 186 if (!class_table->IsValidIndex(class_id) || | 193 if (!class_table->IsValidIndex(class_id) || |
| 187 !class_table->HasValidClassAt(class_id)) { | 194 !class_table->HasValidClassAt(class_id)) { |
| 188 FATAL2("Invalid class id: %" Pd " from tags %" Px "\n", | 195 FATAL2("Invalid class id: %" Pd " from tags %" Px "\n", |
| 189 class_id, ptr()->tags_); | 196 class_id, ptr()->tags_); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 size = RawInstance::VisitInstancePointers(raw_obj, visitor); | 288 size = RawInstance::VisitInstancePointers(raw_obj, visitor); |
| 282 break; | 289 break; |
| 283 } | 290 } |
| 284 #undef RAW_VISITPOINTERS | 291 #undef RAW_VISITPOINTERS |
| 285 case kFreeListElement: { | 292 case kFreeListElement: { |
| 286 uword addr = RawObject::ToAddr(this); | 293 uword addr = RawObject::ToAddr(this); |
| 287 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); | 294 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); |
| 288 size = element->Size(); | 295 size = element->Size(); |
| 289 break; | 296 break; |
| 290 } | 297 } |
| 298 case kForwardingCorpse: { |
| 299 uword addr = RawObject::ToAddr(this); |
| 300 ForwardingCorpse* forwarder = reinterpret_cast<ForwardingCorpse*>(addr); |
| 301 size = forwarder->Size(); |
| 302 break; |
| 303 } |
| 291 case kNullCid: | 304 case kNullCid: |
| 292 size = Size(); | 305 size = Size(); |
| 293 break; | 306 break; |
| 294 default: | 307 default: |
| 295 OS::Print("Class Id: %" Pd "\n", class_id); | 308 OS::Print("Class Id: %" Pd "\n", class_id); |
| 296 UNREACHABLE(); | 309 UNREACHABLE(); |
| 297 break; | 310 break; |
| 298 } | 311 } |
| 299 } else { | 312 } else { |
| 300 RawInstance* raw_obj = reinterpret_cast<RawInstance*>(this); | 313 RawInstance* raw_obj = reinterpret_cast<RawInstance*>(this); |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 intptr_t RawUserTag::VisitUserTagPointers( | 975 intptr_t RawUserTag::VisitUserTagPointers( |
| 963 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { | 976 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { |
| 964 // Make sure that we got here with the tagged pointer as this. | 977 // Make sure that we got here with the tagged pointer as this. |
| 965 ASSERT(raw_obj->IsHeapObject()); | 978 ASSERT(raw_obj->IsHeapObject()); |
| 966 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 979 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 967 return UserTag::InstanceSize(); | 980 return UserTag::InstanceSize(); |
| 968 } | 981 } |
| 969 | 982 |
| 970 | 983 |
| 971 } // namespace dart | 984 } // namespace dart |
| OLD | NEW |