Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: runtime/vm/raw_object.cc

Issue 1175523002: Object pool with support for untagged entries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 instance_size = TwoByteString::InstanceSize(string_length); 108 instance_size = TwoByteString::InstanceSize(string_length);
109 break; 109 break;
110 } 110 }
111 case kArrayCid: 111 case kArrayCid:
112 case kImmutableArrayCid: { 112 case kImmutableArrayCid: {
113 const RawArray* raw_array = reinterpret_cast<const RawArray*>(this); 113 const RawArray* raw_array = reinterpret_cast<const RawArray*>(this);
114 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); 114 intptr_t array_length = Smi::Value(raw_array->ptr()->length_);
115 instance_size = Array::InstanceSize(array_length); 115 instance_size = Array::InstanceSize(array_length);
116 break; 116 break;
117 } 117 }
118 case kObjectPoolCid: {
119 const RawObjectPool* raw_object_pool =
120 reinterpret_cast<const RawObjectPool*>(this);
121 intptr_t len = raw_object_pool->ptr()->length_;
122 instance_size = ObjectPool::InstanceSize(len);
123 break;
124 }
118 #define SIZE_FROM_CLASS(clazz) \ 125 #define SIZE_FROM_CLASS(clazz) \
119 case kTypedData##clazz##Cid: 126 case kTypedData##clazz##Cid:
120 CLASS_LIST_TYPED_DATA(SIZE_FROM_CLASS) { 127 CLASS_LIST_TYPED_DATA(SIZE_FROM_CLASS) {
121 const RawTypedData* raw_obj = 128 const RawTypedData* raw_obj =
122 reinterpret_cast<const RawTypedData*>(this); 129 reinterpret_cast<const RawTypedData*>(this);
123 intptr_t cid = raw_obj->GetClassId(); 130 intptr_t cid = raw_obj->GetClassId();
124 intptr_t array_len = Smi::Value(raw_obj->ptr()->length_); 131 intptr_t array_len = Smi::Value(raw_obj->ptr()->length_);
125 intptr_t lengthInBytes = array_len * TypedData::ElementSizeInBytes(cid); 132 intptr_t lengthInBytes = array_len * TypedData::ElementSizeInBytes(cid);
126 instance_size = TypedData::InstanceSize(lengthInBytes); 133 instance_size = TypedData::InstanceSize(lengthInBytes);
127 break; 134 break;
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 for (intptr_t i = 0; i < length; i++) { 523 for (intptr_t i = 0; i < length; i++) {
517 int32_t offset = obj->data()[i]; 524 int32_t offset = obj->data()[i];
518 visitor->VisitPointer( 525 visitor->VisitPointer(
519 reinterpret_cast<RawObject**>(entry_point + offset)); 526 reinterpret_cast<RawObject**>(entry_point + offset));
520 } 527 }
521 } 528 }
522 return Code::InstanceSize(length); 529 return Code::InstanceSize(length);
523 } 530 }
524 531
525 532
533 intptr_t RawObjectPool::VisitObjectPoolPointers(
534 RawObjectPool* raw_obj, ObjectPointerVisitor* visitor) {
535 visitor->VisitPointer(
536 reinterpret_cast<RawObject**>(&raw_obj->ptr()->info_array_));
537 const intptr_t len = raw_obj->ptr()->length_;
538 RawTypedData* info_array = raw_obj->ptr()->info_array_->ptr();
539 Entry* first = raw_obj->first_entry();
540 for (intptr_t i = 0; i < len; ++i) {
541 ObjectPool::EntryType entry_type =
542 static_cast<ObjectPool::EntryType>(info_array->data()[i]);
543 if (entry_type == ObjectPool::kTaggedObject) {
544 visitor->VisitPointer(&(first + i)->raw_obj_);
545 }
546 }
547 return ObjectPool::InstanceSize(raw_obj->ptr()->length_);
548 }
549
550
526 intptr_t RawInstructions::VisitInstructionsPointers( 551 intptr_t RawInstructions::VisitInstructionsPointers(
527 RawInstructions* raw_obj, ObjectPointerVisitor* visitor) { 552 RawInstructions* raw_obj, ObjectPointerVisitor* visitor) {
528 RawInstructions* obj = raw_obj->ptr(); 553 RawInstructions* obj = raw_obj->ptr();
529 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 554 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
530 return Instructions::InstanceSize(obj->size_); 555 return Instructions::InstanceSize(obj->size_);
531 } 556 }
532 557
533 558
534 bool RawInstructions::ContainsPC(RawObject* raw_obj, uword pc) { 559 bool RawInstructions::ContainsPC(RawObject* raw_obj, uword pc) {
535 uword tags = raw_obj->ptr()->tags_; 560 uword tags = raw_obj->ptr()->tags_;
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 intptr_t RawUserTag::VisitUserTagPointers( 937 intptr_t RawUserTag::VisitUserTagPointers(
913 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { 938 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) {
914 // 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.
915 ASSERT(raw_obj->IsHeapObject()); 940 ASSERT(raw_obj->IsHeapObject());
916 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 941 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
917 return UserTag::InstanceSize(); 942 return UserTag::InstanceSize();
918 } 943 }
919 944
920 945
921 } // namespace dart 946 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698