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

Side by Side Diff: src/heap/mark-compact.cc

Issue 2576453002: [heap] Create a thin wrapper around wrapper tracing in V8 to avoid misuse (Closed)
Patch Set: Use mocks Created 4 years 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/heap/mark-compact.h" 5 #include "src/heap/mark-compact.h"
6 6
7 #include "src/base/atomicops.h" 7 #include "src/base/atomicops.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/base/sys-info.h" 9 #include "src/base/sys-info.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 789
790 // Clear marking bits if incremental marking is aborted. 790 // Clear marking bits if incremental marking is aborted.
791 if (was_marked_incrementally_ && heap_->ShouldAbortIncrementalMarking()) { 791 if (was_marked_incrementally_ && heap_->ShouldAbortIncrementalMarking()) {
792 heap()->incremental_marking()->Stop(); 792 heap()->incremental_marking()->Stop();
793 heap()->incremental_marking()->AbortBlackAllocation(); 793 heap()->incremental_marking()->AbortBlackAllocation();
794 ClearMarkbits(); 794 ClearMarkbits();
795 AbortWeakCollections(); 795 AbortWeakCollections();
796 AbortWeakCells(); 796 AbortWeakCells();
797 AbortTransitionArrays(); 797 AbortTransitionArrays();
798 AbortCompaction(); 798 AbortCompaction();
799 if (heap_->UsingEmbedderHeapTracer()) { 799 heap_->local_embedder_heap_tracer()->AbortTracing();
800 heap_->embedder_heap_tracer()->AbortTracing();
801 heap_->clear_wrappers_to_trace();
802 }
803 marking_deque()->Clear(); 800 marking_deque()->Clear();
804 was_marked_incrementally_ = false; 801 was_marked_incrementally_ = false;
805 } 802 }
806 803
807 if (!was_marked_incrementally_) { 804 if (!was_marked_incrementally_) {
808 if (heap_->UsingEmbedderHeapTracer()) { 805 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_PROLOGUE);
809 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_PROLOGUE); 806 heap_->local_embedder_heap_tracer()->TracePrologue();
810 heap_->embedder_heap_tracer()->TracePrologue();
811 }
812 } 807 }
813 808
814 if (heap_->UsingEmbedderHeapTracer()) { 809 heap_->local_embedder_heap_tracer()->EnterFinalPause();
815 heap_->embedder_heap_tracer()->EnterFinalPause();
816 }
817 810
818 // Don't start compaction if we are in the middle of incremental 811 // Don't start compaction if we are in the middle of incremental
819 // marking cycle. We did not collect any slots. 812 // marking cycle. We did not collect any slots.
820 if (!FLAG_never_compact && !was_marked_incrementally_) { 813 if (!FLAG_never_compact && !was_marked_incrementally_) {
821 StartCompaction(); 814 StartCompaction();
822 } 815 }
823 816
824 PagedSpaces spaces(heap()); 817 PagedSpaces spaces(heap());
825 for (PagedSpace* space = spaces.next(); space != NULL; 818 for (PagedSpace* space = spaces.next(); space != NULL;
826 space = spaces.next()) { 819 space = spaces.next()) {
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 DCHECK(marking_deque()->IsEmpty()); 2126 DCHECK(marking_deque()->IsEmpty());
2134 } 2127 }
2135 2128
2136 // Mark all objects reachable (transitively) from objects on the marking 2129 // Mark all objects reachable (transitively) from objects on the marking
2137 // stack including references only considered in the atomic marking pause. 2130 // stack including references only considered in the atomic marking pause.
2138 void MarkCompactCollector::ProcessEphemeralMarking( 2131 void MarkCompactCollector::ProcessEphemeralMarking(
2139 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) { 2132 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) {
2140 DCHECK(marking_deque()->IsEmpty() && !marking_deque()->overflowed()); 2133 DCHECK(marking_deque()->IsEmpty() && !marking_deque()->overflowed());
2141 bool work_to_do = true; 2134 bool work_to_do = true;
2142 while (work_to_do) { 2135 while (work_to_do) {
2143 if (heap_->UsingEmbedderHeapTracer()) { 2136 {
2144 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_TRACING); 2137 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_TRACING);
2145 heap_->RegisterWrappersWithEmbedderHeapTracer(); 2138 heap_->local_embedder_heap_tracer()->Trace(
2146 heap_->embedder_heap_tracer()->AdvanceTracing(
2147 0, EmbedderHeapTracer::AdvanceTracingActions( 2139 0, EmbedderHeapTracer::AdvanceTracingActions(
2148 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION)); 2140 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION));
2149 } 2141 }
2150 if (!only_process_harmony_weak_collections) { 2142 if (!only_process_harmony_weak_collections) {
2151 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_OBJECT_GROUPING); 2143 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_OBJECT_GROUPING);
2152 isolate()->global_handles()->IterateObjectGroups( 2144 isolate()->global_handles()->IterateObjectGroups(
2153 visitor, &IsUnmarkedHeapObjectWithHeap); 2145 visitor, &IsUnmarkedHeapObjectWithHeap);
2154 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject); 2146 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject);
2155 } 2147 }
2156 ProcessWeakCollections(); 2148 ProcessWeakCollections();
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 } 2478 }
2487 2479
2488 // Repeat Harmony weak maps marking to mark unmarked objects reachable from 2480 // Repeat Harmony weak maps marking to mark unmarked objects reachable from
2489 // the weak roots we just marked as pending destruction. 2481 // the weak roots we just marked as pending destruction.
2490 // 2482 //
2491 // We only process harmony collections, as all object groups have been fully 2483 // We only process harmony collections, as all object groups have been fully
2492 // processed and no weakly reachable node can discover new objects groups. 2484 // processed and no weakly reachable node can discover new objects groups.
2493 { 2485 {
2494 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE_HARMONY); 2486 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE_HARMONY);
2495 ProcessEphemeralMarking(&root_visitor, true); 2487 ProcessEphemeralMarking(&root_visitor, true);
2496 if (heap_->UsingEmbedderHeapTracer()) { 2488 {
2497 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_EPILOGUE); 2489 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_EPILOGUE);
2498 heap()->embedder_heap_tracer()->TraceEpilogue(); 2490 heap()->local_embedder_heap_tracer()->TraceEpilogue();
2499 } 2491 }
2500 } 2492 }
2501 } 2493 }
2502 } 2494 }
2503 2495
2504 2496
2505 void MarkCompactCollector::ClearNonLiveReferences() { 2497 void MarkCompactCollector::ClearNonLiveReferences() {
2506 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_CLEAR); 2498 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_CLEAR);
2507 2499
2508 { 2500 {
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
4079 // The target is always in old space, we don't have to record the slot in 4071 // The target is always in old space, we don't have to record the slot in
4080 // the old-to-new remembered set. 4072 // the old-to-new remembered set.
4081 DCHECK(!heap()->InNewSpace(target)); 4073 DCHECK(!heap()->InNewSpace(target));
4082 RecordRelocSlot(host, &rinfo, target); 4074 RecordRelocSlot(host, &rinfo, target);
4083 } 4075 }
4084 } 4076 }
4085 } 4077 }
4086 4078
4087 } // namespace internal 4079 } // namespace internal
4088 } // namespace v8 4080 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698