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

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

Issue 1027243003: Revert "Eliminate fake-Isolate workaround from concurrent sweeper." (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return; 58 return;
59 } 59 }
60 intptr_t size = SizeTag::decode(tags); 60 intptr_t size = SizeTag::decode(tags);
61 if (size != 0 && size != SizeFromClass()) { 61 if (size != 0 && size != SizeFromClass()) {
62 FATAL1("Inconsistent class size encountered %" Pd "\n", size); 62 FATAL1("Inconsistent class size encountered %" Pd "\n", size);
63 } 63 }
64 } 64 }
65 65
66 66
67 intptr_t RawObject::SizeFromClass() const { 67 intptr_t RawObject::SizeFromClass() const {
68 return SizeFromClass(Isolate::Current()->class_table());
69 }
70
71
72 intptr_t RawObject::SizeFromClass(const ClassTable* class_table) const {
73 // Only reasonable to be called on heap objects. 68 // Only reasonable to be called on heap objects.
74 ASSERT(IsHeapObject()); 69 ASSERT(IsHeapObject());
75 70
76 intptr_t class_id = GetClassId(); 71 intptr_t class_id = GetClassId();
77 intptr_t instance_size = 0; 72 intptr_t instance_size = 0;
78 switch (class_id) { 73 switch (class_id) {
79 case kCodeCid: { 74 case kCodeCid: {
80 const RawCode* raw_code = reinterpret_cast<const RawCode*>(this); 75 const RawCode* raw_code = reinterpret_cast<const RawCode*>(this);
81 intptr_t pointer_offsets_length = 76 intptr_t pointer_offsets_length =
82 Code::PtrOffBits::decode(raw_code->ptr()->state_bits_); 77 Code::PtrOffBits::decode(raw_code->ptr()->state_bits_);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 break; 184 break;
190 } 185 }
191 case kFreeListElement: { 186 case kFreeListElement: {
192 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this)); 187 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this));
193 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); 188 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr);
194 instance_size = element->Size(); 189 instance_size = element->Size();
195 break; 190 break;
196 } 191 }
197 default: { 192 default: {
198 // Get the (constant) instance size out of the class object. 193 // Get the (constant) instance size out of the class object.
194 // TODO(koda): Add Size(ClassTable*) interface to allow caching in loops.
195 Isolate* isolate = Isolate::Current();
196 ClassTable* class_table = isolate->class_table();
199 #if defined(DEBUG) 197 #if defined(DEBUG)
200 if (!class_table->IsValidIndex(class_id) || 198 if (!class_table->IsValidIndex(class_id) ||
201 !class_table->HasValidClassAt(class_id)) { 199 !class_table->HasValidClassAt(class_id)) {
202 FATAL2("Invalid class id: %" Pd " from tags %" Px "\n", 200 FATAL2("Invalid class id: %" Pd " from tags %" Px "\n",
203 class_id, ptr()->tags_); 201 class_id, ptr()->tags_);
204 } 202 }
205 #endif // DEBUG 203 #endif // DEBUG
206 RawClass* raw_class = class_table->At(class_id); 204 RawClass* raw_class = class_table->At(class_id);
207 ASSERT(raw_class->ptr()->id_ == class_id); 205 ASSERT(raw_class->ptr()->id_ == class_id);
208 instance_size = 206 instance_size =
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 intptr_t RawUserTag::VisitUserTagPointers( 931 intptr_t RawUserTag::VisitUserTagPointers(
934 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { 932 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) {
935 // Make sure that we got here with the tagged pointer as this. 933 // Make sure that we got here with the tagged pointer as this.
936 ASSERT(raw_obj->IsHeapObject()); 934 ASSERT(raw_obj->IsHeapObject());
937 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 935 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
938 return UserTag::InstanceSize(); 936 return UserTag::InstanceSize();
939 } 937 }
940 938
941 939
942 } // namespace dart 940 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698