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

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

Issue 2908353002: Nonvirtual pointer visitor in GCs (Closed)
Patch Set: Separated user-defined classes case so it can be inlined Created 3 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
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/become.h" 7 #include "vm/become.h"
8 #include "vm/class_table.h" 8 #include "vm/class_table.h"
9 #include "vm/dart.h" 9 #include "vm/dart.h"
10 #include "vm/freelist.h" 10 #include "vm/freelist.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 if ((instance_size != tags_size) && (tags_size != 0)) { 213 if ((instance_size != tags_size) && (tags_size != 0)) {
214 FATAL3("Size mismatch: %" Pd " from class vs %" Pd " from tags %" Px "\n", 214 FATAL3("Size mismatch: %" Pd " from class vs %" Pd " from tags %" Px "\n",
215 instance_size, tags_size, tags); 215 instance_size, tags_size, tags);
216 } 216 }
217 #endif // DEBUG 217 #endif // DEBUG
218 return instance_size; 218 return instance_size;
219 } 219 }
220 220
221 221
222 intptr_t RawObject::VisitPointers(ObjectPointerVisitor* visitor) { 222 intptr_t RawObject::VisitPointersPredefined(ObjectPointerVisitor* visitor,
223 intptr_t class_id) {
224 ASSERT(class_id < kNumPredefinedCids);
225
223 intptr_t size = 0; 226 intptr_t size = 0;
224 227
225 // Only reasonable to be called on heap objects. 228 // Only reasonable to be called on heap objects.
226 ASSERT(IsHeapObject()); 229 ASSERT(IsHeapObject());
227 230
228 // Read the necessary data out of the class before visting the class itself. 231 switch (class_id) {
229 intptr_t class_id = GetClassId();
230
231 if (class_id < kNumPredefinedCids) {
232 switch (class_id) {
233 #define RAW_VISITPOINTERS(clazz) \ 232 #define RAW_VISITPOINTERS(clazz) \
234 case k##clazz##Cid: { \ 233 case k##clazz##Cid: { \
235 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(this); \ 234 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(this); \
236 size = Raw##clazz::Visit##clazz##Pointers(raw_obj, visitor); \ 235 size = Raw##clazz::Visit##clazz##Pointers(raw_obj, visitor); \
237 break; \ 236 break; \
238 } 237 }
239 CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS) 238 CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS)
240 #undef RAW_VISITPOINTERS 239 #undef RAW_VISITPOINTERS
241 #define RAW_VISITPOINTERS(clazz) case kTypedData##clazz##Cid: 240 #define RAW_VISITPOINTERS(clazz) case kTypedData##clazz##Cid:
242 CLASS_LIST_TYPED_DATA(RAW_VISITPOINTERS) { 241 CLASS_LIST_TYPED_DATA(RAW_VISITPOINTERS) {
243 RawTypedData* raw_obj = reinterpret_cast<RawTypedData*>(this); 242 RawTypedData* raw_obj = reinterpret_cast<RawTypedData*>(this);
244 size = RawTypedData::VisitTypedDataPointers(raw_obj, visitor); 243 size = RawTypedData::VisitTypedDataPointers(raw_obj, visitor);
245 break; 244 break;
246 } 245 }
247 #undef RAW_VISITPOINTERS 246 #undef RAW_VISITPOINTERS
248 #define RAW_VISITPOINTERS(clazz) case kExternalTypedData##clazz##Cid: 247 #define RAW_VISITPOINTERS(clazz) case kExternalTypedData##clazz##Cid:
249 CLASS_LIST_TYPED_DATA(RAW_VISITPOINTERS) { 248 CLASS_LIST_TYPED_DATA(RAW_VISITPOINTERS) {
250 RawExternalTypedData* raw_obj = 249 RawExternalTypedData* raw_obj =
251 reinterpret_cast<RawExternalTypedData*>(this); 250 reinterpret_cast<RawExternalTypedData*>(this);
252 size = RawExternalTypedData::VisitExternalTypedDataPointers(raw_obj, 251 size = RawExternalTypedData::VisitExternalTypedDataPointers(raw_obj,
253 visitor); 252 visitor);
254 break; 253 break;
255 } 254 }
256 #undef RAW_VISITPOINTERS 255 #undef RAW_VISITPOINTERS
257 #define RAW_VISITPOINTERS(clazz) case kTypedData##clazz##ViewCid: 256 #define RAW_VISITPOINTERS(clazz) case kTypedData##clazz##ViewCid:
258 CLASS_LIST_TYPED_DATA(RAW_VISITPOINTERS) 257 CLASS_LIST_TYPED_DATA(RAW_VISITPOINTERS)
259 case kByteDataViewCid: 258 case kByteDataViewCid:
260 case kByteBufferCid: { 259 case kByteBufferCid: {
261 RawInstance* raw_obj = reinterpret_cast<RawInstance*>(this); 260 RawInstance* raw_obj = reinterpret_cast<RawInstance*>(this);
262 size = RawInstance::VisitInstancePointers(raw_obj, visitor); 261 size = RawInstance::VisitInstancePointers(raw_obj, visitor);
263 break; 262 break;
264 } 263 }
265 #undef RAW_VISITPOINTERS 264 #undef RAW_VISITPOINTERS
266 case kFreeListElement: { 265 case kFreeListElement: {
267 uword addr = RawObject::ToAddr(this); 266 uword addr = RawObject::ToAddr(this);
268 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); 267 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr);
269 size = element->Size(); 268 size = element->Size();
270 break; 269 break;
271 }
272 case kForwardingCorpse: {
273 uword addr = RawObject::ToAddr(this);
274 ForwardingCorpse* forwarder = reinterpret_cast<ForwardingCorpse*>(addr);
275 size = forwarder->Size();
276 break;
277 }
278 case kNullCid:
279 size = Size();
280 break;
281 default:
282 OS::Print("Class Id: %" Pd "\n", class_id);
283 UNREACHABLE();
284 break;
285 } 270 }
286 } else { 271 case kForwardingCorpse: {
287 RawInstance* raw_obj = reinterpret_cast<RawInstance*>(this); 272 uword addr = RawObject::ToAddr(this);
288 size = RawInstance::VisitInstancePointers(raw_obj, visitor); 273 ForwardingCorpse* forwarder = reinterpret_cast<ForwardingCorpse*>(addr);
274 size = forwarder->Size();
275 break;
276 }
277 case kNullCid:
278 size = Size();
279 break;
280 default:
281 OS::Print("Class Id: %" Pd "\n", class_id);
282 UNREACHABLE();
283 break;
289 } 284 }
290 285
291 ASSERT(size != 0); 286 ASSERT(size != 0);
292 ASSERT(size == Size()); 287 ASSERT(size == Size());
293 return size; 288 return size;
294 } 289 }
295 290
296 291
297 bool RawObject::FindObject(FindObjectVisitor* visitor) { 292 bool RawObject::FindObject(FindObjectVisitor* visitor) {
298 ASSERT(visitor != NULL); 293 ASSERT(visitor != NULL);
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 intptr_t RawUserTag::VisitUserTagPointers(RawUserTag* raw_obj, 1003 intptr_t RawUserTag::VisitUserTagPointers(RawUserTag* raw_obj,
1009 ObjectPointerVisitor* visitor) { 1004 ObjectPointerVisitor* visitor) {
1010 // Make sure that we got here with the tagged pointer as this. 1005 // Make sure that we got here with the tagged pointer as this.
1011 ASSERT(raw_obj->IsHeapObject()); 1006 ASSERT(raw_obj->IsHeapObject());
1012 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 1007 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
1013 return UserTag::InstanceSize(); 1008 return UserTag::InstanceSize();
1014 } 1009 }
1015 1010
1016 1011
1017 } // namespace dart 1012 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698