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/assembler.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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 instance_size = TwoByteString::InstanceSize(string_length); | 109 instance_size = TwoByteString::InstanceSize(string_length); |
109 break; | 110 break; |
110 } | 111 } |
111 case kArrayCid: | 112 case kArrayCid: |
112 case kImmutableArrayCid: { | 113 case kImmutableArrayCid: { |
113 const RawArray* raw_array = reinterpret_cast<const RawArray*>(this); | 114 const RawArray* raw_array = reinterpret_cast<const RawArray*>(this); |
114 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); | 115 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); |
115 instance_size = Array::InstanceSize(array_length); | 116 instance_size = Array::InstanceSize(array_length); |
116 break; | 117 break; |
117 } | 118 } |
| 119 case kObjectPoolCid: { |
| 120 const RawObjectPool* raw_object_pool = |
| 121 reinterpret_cast<const RawObjectPool*>(this); |
| 122 intptr_t len = raw_object_pool->ptr()->length_; |
| 123 instance_size = ObjectPool::InstanceSize(len); |
| 124 break; |
| 125 } |
118 #define SIZE_FROM_CLASS(clazz) \ | 126 #define SIZE_FROM_CLASS(clazz) \ |
119 case kTypedData##clazz##Cid: | 127 case kTypedData##clazz##Cid: |
120 CLASS_LIST_TYPED_DATA(SIZE_FROM_CLASS) { | 128 CLASS_LIST_TYPED_DATA(SIZE_FROM_CLASS) { |
121 const RawTypedData* raw_obj = | 129 const RawTypedData* raw_obj = |
122 reinterpret_cast<const RawTypedData*>(this); | 130 reinterpret_cast<const RawTypedData*>(this); |
123 intptr_t cid = raw_obj->GetClassId(); | 131 intptr_t cid = raw_obj->GetClassId(); |
124 intptr_t array_len = Smi::Value(raw_obj->ptr()->length_); | 132 intptr_t array_len = Smi::Value(raw_obj->ptr()->length_); |
125 intptr_t lengthInBytes = array_len * TypedData::ElementSizeInBytes(cid); | 133 intptr_t lengthInBytes = array_len * TypedData::ElementSizeInBytes(cid); |
126 instance_size = TypedData::InstanceSize(lengthInBytes); | 134 instance_size = TypedData::InstanceSize(lengthInBytes); |
127 break; | 135 break; |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 for (intptr_t i = 0; i < length; i++) { | 524 for (intptr_t i = 0; i < length; i++) { |
517 int32_t offset = obj->data()[i]; | 525 int32_t offset = obj->data()[i]; |
518 visitor->VisitPointer( | 526 visitor->VisitPointer( |
519 reinterpret_cast<RawObject**>(entry_point + offset)); | 527 reinterpret_cast<RawObject**>(entry_point + offset)); |
520 } | 528 } |
521 } | 529 } |
522 return Code::InstanceSize(length); | 530 return Code::InstanceSize(length); |
523 } | 531 } |
524 | 532 |
525 | 533 |
| 534 RawObjectPool::Entry* RawObjectPool::from() { |
| 535 return &ptr()->data()[Assembler::kNumFixedEntries]; |
| 536 } |
| 537 |
| 538 |
| 539 RawObjectPool::Entry* RawObjectPool::to() { |
| 540 return &ptr()->data()[Assembler::kNumFixedEntries + |
| 541 ptr()->num_tagged_entries_ - 1]; |
| 542 } |
| 543 |
| 544 |
| 545 intptr_t RawObjectPool::VisitObjectPoolPointers( |
| 546 RawObjectPool* raw_obj, ObjectPointerVisitor* visitor) { |
| 547 for (Entry* current = raw_obj->from(); |
| 548 current <= raw_obj->to(); |
| 549 current++) { |
| 550 visitor->VisitPointer(¤t->raw_obj_); |
| 551 } |
| 552 return ObjectPool::InstanceSize(raw_obj->ptr()->length_); |
| 553 } |
| 554 |
| 555 |
526 intptr_t RawInstructions::VisitInstructionsPointers( | 556 intptr_t RawInstructions::VisitInstructionsPointers( |
527 RawInstructions* raw_obj, ObjectPointerVisitor* visitor) { | 557 RawInstructions* raw_obj, ObjectPointerVisitor* visitor) { |
528 RawInstructions* obj = raw_obj->ptr(); | 558 RawInstructions* obj = raw_obj->ptr(); |
529 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 559 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
530 return Instructions::InstanceSize(obj->size_); | 560 return Instructions::InstanceSize(obj->size_); |
531 } | 561 } |
532 | 562 |
533 | 563 |
534 bool RawInstructions::ContainsPC(RawObject* raw_obj, uword pc) { | 564 bool RawInstructions::ContainsPC(RawObject* raw_obj, uword pc) { |
535 uword tags = raw_obj->ptr()->tags_; | 565 uword tags = raw_obj->ptr()->tags_; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 intptr_t RawUserTag::VisitUserTagPointers( | 942 intptr_t RawUserTag::VisitUserTagPointers( |
913 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { | 943 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { |
914 // Make sure that we got here with the tagged pointer as this. | 944 // Make sure that we got here with the tagged pointer as this. |
915 ASSERT(raw_obj->IsHeapObject()); | 945 ASSERT(raw_obj->IsHeapObject()); |
916 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 946 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
917 return UserTag::InstanceSize(); | 947 return UserTag::InstanceSize(); |
918 } | 948 } |
919 | 949 |
920 | 950 |
921 } // namespace dart | 951 } // namespace dart |
OLD | NEW |