Commit 41f92828 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Enable embedder heap tracing in combination with finalizers

Bug: v8:7176
Change-Id: I83d68a7e792b656d9f40a142b5403ac98c4f44c4
Reviewed-on: https://chromium-review.googlesource.com/814116Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49936}
parent d26f8c31
...@@ -1654,28 +1654,16 @@ void MarkCompactCollector::ProcessMarkingWorklist() { ...@@ -1654,28 +1654,16 @@ void MarkCompactCollector::ProcessMarkingWorklist() {
DCHECK(marking_worklist()->IsBailoutEmpty()); DCHECK(marking_worklist()->IsBailoutEmpty());
} }
// Mark all objects reachable (transitively) from objects on the marking void MarkCompactCollector::ProcessEphemeralMarking() {
// stack including references only considered in the atomic marking pause.
void MarkCompactCollector::ProcessEphemeralMarking(
bool only_process_harmony_weak_collections) {
DCHECK(marking_worklist()->IsEmpty()); DCHECK(marking_worklist()->IsEmpty());
bool work_to_do = true; bool work_to_do = true;
while (work_to_do) { while (work_to_do) {
if (!only_process_harmony_weak_collections) { if (heap_->local_embedder_heap_tracer()->InUse()) {
if (heap_->local_embedder_heap_tracer()->InUse()) { TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_TRACING);
TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_TRACING); heap_->local_embedder_heap_tracer()->RegisterWrappersWithRemoteTracer();
heap_->local_embedder_heap_tracer()->RegisterWrappersWithRemoteTracer(); heap_->local_embedder_heap_tracer()->Trace(
heap_->local_embedder_heap_tracer()->Trace( 0, EmbedderHeapTracer::AdvanceTracingActions(
0, EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION));
EmbedderHeapTracer::AdvanceTracingActions(
EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION));
}
} else {
// TODO(mlippautz): We currently do not trace through blink when
// discovering new objects reachable from weak roots (that have been made
// strong). This is a limitation of not having a separate handle type
// that doesn't require zapping before this phase. See crbug.com/668060.
heap_->local_embedder_heap_tracer()->ClearCachedWrappersToTrace();
} }
ProcessWeakCollections(); ProcessWeakCollections();
work_to_do = !marking_worklist()->IsEmpty(); work_to_do = !marking_worklist()->IsEmpty();
...@@ -2400,20 +2388,20 @@ void MarkCompactCollector::MarkLiveObjects() { ...@@ -2400,20 +2388,20 @@ void MarkCompactCollector::MarkLiveObjects() {
DCHECK(marking_worklist()->IsEmpty()); DCHECK(marking_worklist()->IsEmpty());
// The objects reachable from the roots are marked, yet unreachable // The objects reachable from the roots are marked, yet unreachable objects
// objects are unmarked. Mark objects reachable due to host // are unmarked. Mark objects reachable due to embedder heap tracing or
// application specific logic or through Harmony weak maps. // harmony weak maps.
{ {
TRACE_GC(heap()->tracer(), TRACE_GC(heap()->tracer(),
GCTracer::Scope::MC_MARK_WEAK_CLOSURE_EPHEMERAL); GCTracer::Scope::MC_MARK_WEAK_CLOSURE_EPHEMERAL);
ProcessEphemeralMarking(false); ProcessEphemeralMarking();
DCHECK(marking_worklist()->IsEmpty()); DCHECK(marking_worklist()->IsEmpty());
} }
// The objects reachable from the roots, weak maps or object groups // The objects reachable from the roots, weak maps, and embedder heap
// are marked. Objects pointed to only by weak global handles cannot be // tracing are marked. Objects pointed to only by weak global handles cannot
// immediately reclaimed. Instead, we have to mark them as pending and mark // be immediately reclaimed. Instead, we have to mark them as pending and
// objects reachable from them. // mark objects reachable from them.
// //
// First we identify nonlive weak handles and mark them as pending // First we identify nonlive weak handles and mark them as pending
// destruction. // destruction.
...@@ -2425,6 +2413,8 @@ void MarkCompactCollector::MarkLiveObjects() { ...@@ -2425,6 +2413,8 @@ void MarkCompactCollector::MarkLiveObjects() {
ProcessMarkingWorklist(); ProcessMarkingWorklist();
} }
// Process finalizers, effectively keeping them alive until the next
// garbage collection.
{ {
TRACE_GC(heap()->tracer(), TRACE_GC(heap()->tracer(),
GCTracer::Scope::MC_MARK_WEAK_CLOSURE_WEAK_ROOTS); GCTracer::Scope::MC_MARK_WEAK_CLOSURE_WEAK_ROOTS);
...@@ -2433,14 +2423,10 @@ void MarkCompactCollector::MarkLiveObjects() { ...@@ -2433,14 +2423,10 @@ void MarkCompactCollector::MarkLiveObjects() {
ProcessMarkingWorklist(); ProcessMarkingWorklist();
} }
// Repeat Harmony weak maps marking to mark unmarked objects reachable from // Repeat ephemeral processing from the newly marked objects.
// the weak roots we just marked as pending destruction.
//
// We only process harmony collections, as all object groups have been fully
// processed and no weakly reachable node can discover new objects groups.
{ {
TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE_HARMONY); TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE_HARMONY);
ProcessEphemeralMarking(true); ProcessEphemeralMarking();
{ {
TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_EPILOGUE); TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_EPILOGUE);
heap()->local_embedder_heap_tracer()->TraceEpilogue(); heap()->local_embedder_heap_tracer()->TraceEpilogue();
......
...@@ -751,13 +751,8 @@ class MarkCompactCollector final : public MarkCompactCollectorBase { ...@@ -751,13 +751,8 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
// the string table are weak. // the string table are weak.
void MarkStringTable(ObjectVisitor* visitor); void MarkStringTable(ObjectVisitor* visitor);
// Mark objects reachable (transitively) from objects in the marking stack // Marks object reachable from harmony weak maps and wrapper tracing.
// or overflowed in the heap. This respects references only considered in void ProcessEphemeralMarking();
// the final atomic marking pause including the following:
// - Processing of objects reachable through Harmony WeakMaps.
// - Objects reachable due to host application logic like object groups,
// implicit references' groups, or embedder heap tracing.
void ProcessEphemeralMarking(bool only_process_harmony_weak_collections);
// If the call-site of the top optimized code was not prepared for // If the call-site of the top optimized code was not prepared for
// deoptimization, then treat embedded pointers in the code as strong as // deoptimization, then treat embedded pointers in the code as strong as
......
...@@ -88,9 +88,6 @@ ...@@ -88,9 +88,6 @@
# BUG(2340). Preprocessing stack traces is disabled at the moment. # BUG(2340). Preprocessing stack traces is disabled at the moment.
'test-heap/PreprocessStackTrace': [FAIL], 'test-heap/PreprocessStackTrace': [FAIL],
# BUG(7176). Embedder heap tracer doesn't support finalizers.
'test-embedder-tracing/TracingInRevivedSubgraph': [FAIL],
# BUG(4333). Function name inferrer does not work for ES6 clases. # BUG(4333). Function name inferrer does not work for ES6 clases.
'test-func-name-inference/UpperCaseClass': [FAIL], 'test-func-name-inference/UpperCaseClass': [FAIL],
'test-func-name-inference/LowerCaseClass': [FAIL], 'test-func-name-inference/LowerCaseClass': [FAIL],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment