| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = raw_class->ptr()->instance_size_; |
| 52 intptr_t class_id = raw_class->ptr()->id_; | 52 intptr_t class_id = raw_class->ptr()->id_; |
| 53 | 53 |
| 54 if (instance_size == 0) { | 54 if (instance_size == 0) { |
| 55 switch (class_id) { | 55 switch (class_id) { |
| 56 case kTokenStreamCid: { | |
| 57 const RawTokenStream* raw_tokens = | |
| 58 reinterpret_cast<const RawTokenStream*>(this); | |
| 59 intptr_t tokens_length = Smi::Value(raw_tokens->ptr()->length_); | |
| 60 instance_size = TokenStream::InstanceSize(tokens_length); | |
| 61 break; | |
| 62 } | |
| 63 case kCodeCid: { | 56 case kCodeCid: { |
| 64 const RawCode* raw_code = reinterpret_cast<const RawCode*>(this); | 57 const RawCode* raw_code = reinterpret_cast<const RawCode*>(this); |
| 65 intptr_t pointer_offsets_length = | 58 intptr_t pointer_offsets_length = |
| 66 raw_code->ptr()->pointer_offsets_length_; | 59 raw_code->ptr()->pointer_offsets_length_; |
| 67 instance_size = Code::InstanceSize(pointer_offsets_length); | 60 instance_size = Code::InstanceSize(pointer_offsets_length); |
| 68 break; | 61 break; |
| 69 } | 62 } |
| 70 case kInstructionsCid: { | 63 case kInstructionsCid: { |
| 71 const RawInstructions* raw_instructions = | 64 const RawInstructions* raw_instructions = |
| 72 reinterpret_cast<const RawInstructions*>(this); | 65 reinterpret_cast<const RawInstructions*>(this); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 390 |
| 398 intptr_t RawLiteralToken::VisitLiteralTokenPointers( | 391 intptr_t RawLiteralToken::VisitLiteralTokenPointers( |
| 399 RawLiteralToken* raw_obj, ObjectPointerVisitor* visitor) { | 392 RawLiteralToken* raw_obj, ObjectPointerVisitor* visitor) { |
| 400 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 393 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 401 return LiteralToken::InstanceSize(); | 394 return LiteralToken::InstanceSize(); |
| 402 } | 395 } |
| 403 | 396 |
| 404 | 397 |
| 405 intptr_t RawTokenStream::VisitTokenStreamPointers( | 398 intptr_t RawTokenStream::VisitTokenStreamPointers( |
| 406 RawTokenStream* raw_obj, ObjectPointerVisitor* visitor) { | 399 RawTokenStream* raw_obj, ObjectPointerVisitor* visitor) { |
| 407 intptr_t length = Smi::Value(raw_obj->ptr()->length_); | |
| 408 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 400 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 409 return TokenStream::InstanceSize(length); | 401 return TokenStream::InstanceSize(); |
| 410 } | 402 } |
| 411 | 403 |
| 412 | 404 |
| 413 intptr_t RawScript::VisitScriptPointers(RawScript* raw_obj, | 405 intptr_t RawScript::VisitScriptPointers(RawScript* raw_obj, |
| 414 ObjectPointerVisitor* visitor) { | 406 ObjectPointerVisitor* visitor) { |
| 415 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 407 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 416 return Script::InstanceSize(); | 408 return Script::InstanceSize(); |
| 417 } | 409 } |
| 418 | 410 |
| 419 | 411 |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 | 973 |
| 982 intptr_t RawWeakProperty::VisitWeakPropertyPointers( | 974 intptr_t RawWeakProperty::VisitWeakPropertyPointers( |
| 983 RawWeakProperty* raw_obj, ObjectPointerVisitor* visitor) { | 975 RawWeakProperty* raw_obj, ObjectPointerVisitor* visitor) { |
| 984 // Make sure that we got here with the tagged pointer as this. | 976 // Make sure that we got here with the tagged pointer as this. |
| 985 ASSERT(raw_obj->IsHeapObject()); | 977 ASSERT(raw_obj->IsHeapObject()); |
| 986 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 978 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 987 return WeakProperty::InstanceSize(); | 979 return WeakProperty::InstanceSize(); |
| 988 } | 980 } |
| 989 | 981 |
| 990 } // namespace dart | 982 } // namespace dart |
| OLD | NEW |