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

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

Issue 2088923002: Revert "Background finalization." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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/dart_api_state.cc ('k') | runtime/vm/heap.h » ('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) 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 "vm/allocation.h" 7 #include "vm/allocation.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/log.h" 10 #include "vm/log.h"
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 427 }
428 if (!raw_obj->IsOldObject()) { 428 if (!raw_obj->IsOldObject()) {
429 return false; 429 return false;
430 } 430 }
431 return !raw_obj->IsMarked(); 431 return !raw_obj->IsMarked();
432 } 432 }
433 433
434 434
435 class MarkingWeakVisitor : public HandleVisitor { 435 class MarkingWeakVisitor : public HandleVisitor {
436 public: 436 public:
437 MarkingWeakVisitor(Thread* thread, FinalizationQueue* queue) : 437 MarkingWeakVisitor() : HandleVisitor(Thread::Current()) {
438 HandleVisitor(thread), queue_(queue) { } 438 }
439 439
440 void VisitHandle(uword addr) { 440 void VisitHandle(uword addr) {
441 FinalizablePersistentHandle* handle = 441 FinalizablePersistentHandle* handle =
442 reinterpret_cast<FinalizablePersistentHandle*>(addr); 442 reinterpret_cast<FinalizablePersistentHandle*>(addr);
443 RawObject* raw_obj = handle->raw(); 443 RawObject* raw_obj = handle->raw();
444 if (IsUnreachable(raw_obj)) { 444 if (IsUnreachable(raw_obj)) {
445 handle->UpdateUnreachable(thread()->isolate(), queue_); 445 handle->UpdateUnreachable(thread()->isolate());
446 } 446 }
447 } 447 }
448 448
449 private: 449 private:
450 FinalizationQueue* queue_;
451
452 DISALLOW_COPY_AND_ASSIGN(MarkingWeakVisitor); 450 DISALLOW_COPY_AND_ASSIGN(MarkingWeakVisitor);
453 }; 451 };
454 452
455 453
456 void GCMarker::Prologue(Isolate* isolate, bool invoke_api_callbacks) { 454 void GCMarker::Prologue(Isolate* isolate, bool invoke_api_callbacks) {
457 if (invoke_api_callbacks && (isolate->gc_prologue_callback() != NULL)) { 455 if (invoke_api_callbacks && (isolate->gc_prologue_callback() != NULL)) {
458 (isolate->gc_prologue_callback())(); 456 (isolate->gc_prologue_callback())();
459 } 457 }
460 isolate->PrepareForGC(); 458 isolate->PrepareForGC();
461 // The store buffers will be rebuilt as part of marking, reset them now. 459 // The store buffers will be rebuilt as part of marking, reset them now.
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 if (num_tasks == 0) { 699 if (num_tasks == 0) {
702 // Mark everything on main thread. 700 // Mark everything on main thread.
703 SkippedCodeFunctions* skipped_code_functions = 701 SkippedCodeFunctions* skipped_code_functions =
704 collect_code ? new(zone) SkippedCodeFunctions() : NULL; 702 collect_code ? new(zone) SkippedCodeFunctions() : NULL;
705 UnsyncMarkingVisitor mark(isolate, heap_, page_space, &marking_stack, 703 UnsyncMarkingVisitor mark(isolate, heap_, page_space, &marking_stack,
706 skipped_code_functions); 704 skipped_code_functions);
707 IterateRoots(isolate, &mark, 0, 1); 705 IterateRoots(isolate, &mark, 0, 1);
708 mark.DrainMarkingStack(); 706 mark.DrainMarkingStack();
709 { 707 {
710 TIMELINE_FUNCTION_GC_DURATION(thread, "WeakHandleProcessing"); 708 TIMELINE_FUNCTION_GC_DURATION(thread, "WeakHandleProcessing");
711 FinalizationQueue* queue = new FinalizationQueue(); 709 MarkingWeakVisitor mark_weak;
712 MarkingWeakVisitor mark_weak(thread, queue);
713 IterateWeakRoots(isolate, &mark_weak); 710 IterateWeakRoots(isolate, &mark_weak);
714 if (queue->length() > 0) {
715 Dart::thread_pool()->Run(new BackgroundFinalizer(isolate, queue));
716 } else {
717 delete queue;
718 }
719 } 711 }
720 // All marking done; detach code, etc. 712 // All marking done; detach code, etc.
721 FinalizeResultsFrom(&mark); 713 FinalizeResultsFrom(&mark);
722 } else { 714 } else {
723 ThreadBarrier barrier(num_tasks + 1, 715 ThreadBarrier barrier(num_tasks + 1,
724 heap_->barrier(), 716 heap_->barrier(),
725 heap_->barrier_done()); 717 heap_->barrier_done());
726 // Used to coordinate draining among tasks; all start out as 'busy'. 718 // Used to coordinate draining among tasks; all start out as 'busy'.
727 uintptr_t num_busy = num_tasks; 719 uintptr_t num_busy = num_tasks;
728 // Phase 1: Iterate over roots and drain marking stack in tasks. 720 // Phase 1: Iterate over roots and drain marking stack in tasks.
(...skipping 15 matching lines...) Expand all
744 // Note: we need to have two barriers here because we want all markers 736 // Note: we need to have two barriers here because we want all markers
745 // and main thread to make decisions in lock step. 737 // and main thread to make decisions in lock step.
746 barrier.Sync(); 738 barrier.Sync();
747 more_to_mark = AtomicOperations::LoadRelaxed(&num_busy) > 0; 739 more_to_mark = AtomicOperations::LoadRelaxed(&num_busy) > 0;
748 barrier.Sync(); 740 barrier.Sync();
749 } while (more_to_mark); 741 } while (more_to_mark);
750 742
751 // Phase 2: Weak processing on main thread. 743 // Phase 2: Weak processing on main thread.
752 { 744 {
753 TIMELINE_FUNCTION_GC_DURATION(thread, "WeakHandleProcessing"); 745 TIMELINE_FUNCTION_GC_DURATION(thread, "WeakHandleProcessing");
754 FinalizationQueue* queue = new FinalizationQueue(); 746 MarkingWeakVisitor mark_weak;
755 MarkingWeakVisitor mark_weak(thread, queue);
756 IterateWeakRoots(isolate, &mark_weak); 747 IterateWeakRoots(isolate, &mark_weak);
757 if (queue->length() > 0) {
758 Dart::thread_pool()->Run(new BackgroundFinalizer(isolate, queue));
759 } else {
760 delete queue;
761 }
762 } 748 }
763 barrier.Sync(); 749 barrier.Sync();
764 750
765 // Phase 3: Finalize results from all markers (detach code, etc.). 751 // Phase 3: Finalize results from all markers (detach code, etc.).
766 barrier.Exit(); 752 barrier.Exit();
767 } 753 }
768 ProcessWeakTables(page_space); 754 ProcessWeakTables(page_space);
769 ProcessObjectIdTable(isolate); 755 ProcessObjectIdTable(isolate);
770 } 756 }
771 Epilogue(isolate, invoke_api_callbacks); 757 Epilogue(isolate, invoke_api_callbacks);
772 } 758 }
773 759
774 } // namespace dart 760 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_state.cc ('k') | runtime/vm/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698