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

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: Include 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
« no previous file with comments | « src/heap/incremental-marking.cc ('k') | src/heap/objects-visiting.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 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 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 (!only_process_harmony_weak_collections) { 2136 if (!only_process_harmony_weak_collections) {
2144 if (heap_->UsingEmbedderHeapTracer()) { 2137 if (heap_->local_embedder_heap_tracer()->InUse()) {
2145 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_TRACING); 2138 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_TRACING);
2146 heap_->RegisterWrappersWithEmbedderHeapTracer(); 2139 heap_->local_embedder_heap_tracer()->Trace(
2147 heap_->embedder_heap_tracer()->AdvanceTracing(
2148 0, 2140 0,
2149 EmbedderHeapTracer::AdvanceTracingActions( 2141 EmbedderHeapTracer::AdvanceTracingActions(
2150 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION)); 2142 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION));
2151 } else { 2143 } else {
2152 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_OBJECT_GROUPING); 2144 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_OBJECT_GROUPING);
2153 isolate()->global_handles()->IterateObjectGroups( 2145 isolate()->global_handles()->IterateObjectGroups(
2154 visitor, &IsUnmarkedHeapObjectWithHeap); 2146 visitor, &IsUnmarkedHeapObjectWithHeap);
2155 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject); 2147 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject);
2156 } 2148 }
2157 } else { 2149 } else {
2158 // TODO(mlippautz): We currently do not trace through blink when 2150 // TODO(mlippautz): We currently do not trace through blink when
2159 // discovering new objects reachable from weak roots (that have been made 2151 // discovering new objects reachable from weak roots (that have been made
2160 // strong). This is a limitation of not having a separate handle type 2152 // strong). This is a limitation of not having a separate handle type
2161 // that doesn't require zapping before this phase. See crbug.com/668060. 2153 // that doesn't require zapping before this phase. See crbug.com/668060.
2162 heap_->clear_wrappers_to_trace(); 2154 heap_->local_embedder_heap_tracer()->ClearCachedWrappersToTrace();
2163 } 2155 }
2164 ProcessWeakCollections(); 2156 ProcessWeakCollections();
2165 work_to_do = !marking_deque()->IsEmpty(); 2157 work_to_do = !marking_deque()->IsEmpty();
2166 ProcessMarkingDeque<MarkCompactMode::FULL>(); 2158 ProcessMarkingDeque<MarkCompactMode::FULL>();
2167 } 2159 }
2168 CHECK(heap_->MarkingDequesAreEmpty()); 2160 CHECK(heap_->MarkingDequesAreEmpty());
2169 } 2161 }
2170 2162
2171 void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) { 2163 void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) {
2172 for (StackFrameIterator it(isolate(), isolate()->thread_local_top()); 2164 for (StackFrameIterator it(isolate(), isolate()->thread_local_top());
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
2495 } 2487 }
2496 2488
2497 // Repeat Harmony weak maps marking to mark unmarked objects reachable from 2489 // Repeat Harmony weak maps marking to mark unmarked objects reachable from
2498 // the weak roots we just marked as pending destruction. 2490 // the weak roots we just marked as pending destruction.
2499 // 2491 //
2500 // We only process harmony collections, as all object groups have been fully 2492 // We only process harmony collections, as all object groups have been fully
2501 // processed and no weakly reachable node can discover new objects groups. 2493 // processed and no weakly reachable node can discover new objects groups.
2502 { 2494 {
2503 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE_HARMONY); 2495 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE_HARMONY);
2504 ProcessEphemeralMarking(&root_visitor, true); 2496 ProcessEphemeralMarking(&root_visitor, true);
2505 if (heap_->UsingEmbedderHeapTracer()) { 2497 {
2506 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_EPILOGUE); 2498 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_EPILOGUE);
2507 heap()->embedder_heap_tracer()->TraceEpilogue(); 2499 heap()->local_embedder_heap_tracer()->TraceEpilogue();
2508 } 2500 }
2509 } 2501 }
2510 } 2502 }
2511 } 2503 }
2512 2504
2513 2505
2514 void MarkCompactCollector::ClearNonLiveReferences() { 2506 void MarkCompactCollector::ClearNonLiveReferences() {
2515 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_CLEAR); 2507 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_CLEAR);
2516 2508
2517 { 2509 {
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
4088 // The target is always in old space, we don't have to record the slot in 4080 // The target is always in old space, we don't have to record the slot in
4089 // the old-to-new remembered set. 4081 // the old-to-new remembered set.
4090 DCHECK(!heap()->InNewSpace(target)); 4082 DCHECK(!heap()->InNewSpace(target));
4091 RecordRelocSlot(host, &rinfo, target); 4083 RecordRelocSlot(host, &rinfo, target);
4092 } 4084 }
4093 } 4085 }
4094 } 4086 }
4095 4087
4096 } // namespace internal 4088 } // namespace internal
4097 } // namespace v8 4089 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/incremental-marking.cc ('k') | src/heap/objects-visiting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698