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

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

Issue 18259014: Object ID Ring with tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/gc_marker.h" 5 #include "vm/gc_marker.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "vm/allocation.h" 10 #include "vm/allocation.h"
11 #include "vm/dart_api_state.h" 11 #include "vm/dart_api_state.h"
12 #include "vm/isolate.h" 12 #include "vm/isolate.h"
13 #include "vm/pages.h" 13 #include "vm/pages.h"
14 #include "vm/raw_object.h" 14 #include "vm/raw_object.h"
15 #include "vm/stack_frame.h" 15 #include "vm/stack_frame.h"
16 #include "vm/visitor.h" 16 #include "vm/visitor.h"
17 #include "vm/object_id_ring.h"
17 18
18 namespace dart { 19 namespace dart {
19 20
20 // A simple chunked marking stack. 21 // A simple chunked marking stack.
21 class MarkingStack : public ValueObject { 22 class MarkingStack : public ValueObject {
22 public: 23 public:
23 MarkingStack() 24 MarkingStack()
24 : head_(new MarkingStackChunk()), 25 : head_(new MarkingStackChunk()),
25 empty_chunks_(NULL), 26 empty_chunks_(NULL),
26 marking_stack_(NULL), 27 marking_stack_(NULL),
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 ASSERT(raw_obj->IsHeapObject()); 393 ASSERT(raw_obj->IsHeapObject());
393 if (!raw_obj->IsMarked()) { 394 if (!raw_obj->IsMarked()) {
394 table->InvalidateAt(i); 395 table->InvalidateAt(i);
395 } 396 }
396 } 397 }
397 } 398 }
398 } 399 }
399 } 400 }
400 401
401 402
403 class ObjectIdRingClearPointerVisitor : public ObjectPointerVisitor {
404 public:
405 explicit ObjectIdRingClearPointerVisitor(Isolate* isolate) :
406 ObjectPointerVisitor(isolate) {}
407
408 void Clear(RawObject** current) {
409 RawObject* raw_obj = *current;
410 ASSERT(raw_obj->IsHeapObject());
411 if (!raw_obj->IsMarked()) {
Ivan Posva 2013/07/11 17:01:42 You need to be checking the mark bits on old objec
Cutch 2013/07/11 21:31:47 Done.
412 // Object has become garbage. Replace it will null.
413 *current = Object::null();
414 }
415 }
416
417 void VisitPointers(RawObject** first, RawObject** last) {
418 for (RawObject** current = first; current <= last; current++) {
419 Clear(current);
Ivan Posva 2013/07/11 17:01:42 You can move the logic from Clear in here. The nam
Cutch 2013/07/11 21:31:47 Done.
420 }
421 }
422 };
423
424
425 void GCMarker::ProcessObjectIdTable(Isolate* isolate) {
426 ObjectIdRingClearPointerVisitor visitor(isolate);
427 ObjectIdRing* ring = isolate->object_id_ring();
428 ASSERT(ring != NULL);
429 ring->VisitPointers(&visitor);
430 }
431
432
402 void GCMarker::MarkObjects(Isolate* isolate, 433 void GCMarker::MarkObjects(Isolate* isolate,
403 PageSpace* page_space, 434 PageSpace* page_space,
404 bool invoke_api_callbacks) { 435 bool invoke_api_callbacks) {
405 MarkingStack marking_stack; 436 MarkingStack marking_stack;
406 Prologue(isolate, invoke_api_callbacks); 437 Prologue(isolate, invoke_api_callbacks);
407 MarkingVisitor mark(isolate, heap_, page_space, &marking_stack); 438 MarkingVisitor mark(isolate, heap_, page_space, &marking_stack);
408 IterateRoots(isolate, &mark, !invoke_api_callbacks); 439 IterateRoots(isolate, &mark, !invoke_api_callbacks);
409 DrainMarkingStack(isolate, &mark); 440 DrainMarkingStack(isolate, &mark);
410 IterateWeakReferences(isolate, &mark); 441 IterateWeakReferences(isolate, &mark);
411 MarkingWeakVisitor mark_weak; 442 MarkingWeakVisitor mark_weak;
412 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); 443 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks);
413 mark.Finalize(); 444 mark.Finalize();
414 ProcessWeakTables(page_space); 445 ProcessWeakTables(page_space);
446 ProcessObjectIdTable(isolate);
447
448
415 Epilogue(isolate, invoke_api_callbacks); 449 Epilogue(isolate, invoke_api_callbacks);
416 } 450 }
417 451
418 } // namespace dart 452 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/gc_marker.h ('k') | runtime/vm/heap.h » ('j') | runtime/vm/heap.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698