| Index: Source/platform/heap/Heap.cpp
|
| diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp
|
| index 12ec6247943ac8cd996870e4130d65cf48508c2c..3b77309dd2369f8eee6f802a6265fbb66bef65da 100644
|
| --- a/Source/platform/heap/Heap.cpp
|
| +++ b/Source/platform/heap/Heap.cpp
|
| @@ -2079,23 +2079,7 @@
|
|
|
| prepareForGC();
|
|
|
| - // 1. trace persistent roots.
|
| - ThreadState::visitPersistentRoots(s_markingVisitor);
|
| -
|
| - // 2. trace objects reachable from the persistent roots including ephemerons.
|
| - processMarkingStack<GlobalMarking>();
|
| -
|
| - // 3. trace objects reachable from the stack. We do this independent of the
|
| - // given stackState since other threads might have a different stack state.
|
| - ThreadState::visitStackRoots(s_markingVisitor);
|
| -
|
| - // 4. trace objects reachable from the stack "roots" including ephemerons.
|
| - // Only do the processing if we found a pointer to an object on one of the
|
| - // thread stacks.
|
| - if (lastGCWasConservative())
|
| - processMarkingStack<GlobalMarking>();
|
| -
|
| - globalWeakProcessingAndCleanup();
|
| + traceRootsAndPerformGlobalWeakProcessing<GlobalMarking>();
|
|
|
| // After a global marking we know that any orphaned page that was not reached
|
| // cannot be reached in a subsequent GC. This is due to a thread either having
|
| @@ -2132,23 +2116,7 @@
|
| state->enterGC();
|
| state->prepareForGC();
|
|
|
| - // 1. trace the thread local persistent roots. For thread local GCs we
|
| - // don't trace the stack (ie. no conservative scanning) since this is
|
| - // only called during thread shutdown where there should be no objects
|
| - // on the stack.
|
| - // We also assume that orphaned pages have no objects reachable from
|
| - // persistent handles on other threads or CrossThreadPersistents. The
|
| - // only cases where this could happen is if a subsequent conservative
|
| - // global GC finds a "pointer" on the stack or due to a programming
|
| - // error where an object has a dangling cross-thread pointer to an
|
| - // object on this heap.
|
| - state->visitPersistents(s_markingVisitor);
|
| -
|
| - // 2. trace objects reachable from the thread's persistent roots
|
| - // including ephemerons.
|
| - processMarkingStack<ThreadLocalMarking>();
|
| -
|
| - globalWeakProcessingAndCleanup();
|
| + traceRootsAndPerformGlobalWeakProcessing<ThreadLocalMarking>();
|
|
|
| state->leaveGC();
|
| }
|
| @@ -2156,14 +2124,18 @@
|
| }
|
|
|
| template<CallbackInvocationMode Mode>
|
| -void Heap::processMarkingStack()
|
| -{
|
| +void Heap::traceRootsAndPerformGlobalWeakProcessing()
|
| +{
|
| + if (Mode == ThreadLocalMarking)
|
| + ThreadState::current()->visitLocalRoots(s_markingVisitor);
|
| + else
|
| + ThreadState::visitRoots(s_markingVisitor);
|
| +
|
| // Ephemeron fixed point loop.
|
| do {
|
| - // Iteratively mark all objects that are reachable from the objects
|
| - // currently pushed onto the marking stack. If Mode is ThreadLocalMarking
|
| - // don't continue tracing if the trace hits an object on another thread's
|
| - // heap.
|
| + // Recursively mark all objects that are reachable from the roots for
|
| + // this thread. If Mode is ThreadLocalMarking don't continue tracing if
|
| + // the trace hits an object on another thread's heap.
|
| while (popAndInvokeTraceCallback<Mode>(s_markingVisitor)) { }
|
|
|
| // Mark any strong pointers that have now become reachable in ephemeron
|
| @@ -2172,10 +2144,7 @@
|
|
|
| // Rerun loop if ephemeron processing queued more objects for tracing.
|
| } while (!s_markingStack->isEmpty());
|
| -}
|
| -
|
| -void Heap::globalWeakProcessingAndCleanup()
|
| -{
|
| +
|
| // Call weak callbacks on objects that may now be pointing to dead
|
| // objects and call ephemeronIterationDone callbacks on weak tables
|
| // to do cleanup (specifically clear the queued bits for weak hash
|
|
|