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

Unified Diff: Source/platform/heap/ThreadState.cpp

Issue 332393002: [oilpan]: Add SafePointAwareMutexLocker to allow GC when waiting for lock. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review feedback Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/ThreadState.cpp
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp
index 75a6c81ed865246377001d1202159aba14d2abff..bf773e9940ee8cf7bc2cfaa5c287ac83c95eb0a3 100644
--- a/Source/platform/heap/ThreadState.cpp
+++ b/Source/platform/heap/ThreadState.cpp
@@ -104,7 +104,7 @@ static Mutex& threadAttachMutex()
static double lockingTimeout()
{
- // Wait time for parking all threads is at most 500 MS.
+ // Wait time for parking all threads is at most 100 MS.
return 0.100;
}
@@ -186,10 +186,17 @@ public:
ASSERT(ThreadState::current()->isAtSafePoint());
}
- void checkAndPark(ThreadState* state)
+ void checkAndPark(ThreadState* state, SafePointAwareMutexLocker* locker = 0)
{
ASSERT(!state->isSweepInProgress());
if (!acquireLoad(&m_canResume)) {
+ // If we are leaving the safepoint from a SafePointAwareMutexLocker
+ // call out to release the lock before going to sleep. This enables the
+ // lock to be acquired in the sweep phase, e.g. during weak processing
+ // or finalization. The SafePointAwareLocker will reenter the safepoint
+ // and reacquire the lock after leaving this safepoint.
+ if (locker)
+ locker->reset();
pushAllRegisters(this, state, parkAfterPushRegisters);
state->performPendingSweep();
}
@@ -201,10 +208,10 @@ public:
pushAllRegisters(this, state, enterSafePointAfterPushRegisters);
}
- void leaveSafePoint(ThreadState* state)
+ void leaveSafePoint(ThreadState* state, SafePointAwareMutexLocker* locker = 0)
{
if (atomicIncrement(&m_unparkedThreadCount) > 0)
- checkAndPark(state);
+ checkAndPark(state, locker);
}
private:
@@ -745,8 +752,11 @@ void ThreadState::safePoint(StackState stackState)
{
checkThread();
performPendingGC(stackState);
+ ASSERT(!m_atSafePoint);
m_stackState = stackState;
+ m_atSafePoint = true;
s_safePointBarrier->checkAndPark(this);
+ m_atSafePoint = false;
m_stackState = HeapPointersOnStack;
}
@@ -791,11 +801,11 @@ void ThreadState::enterSafePoint(StackState stackState, void* scopeMarker)
s_safePointBarrier->enterSafePoint(this);
}
-void ThreadState::leaveSafePoint()
+void ThreadState::leaveSafePoint(SafePointAwareMutexLocker* locker)
{
checkThread();
ASSERT(m_atSafePoint);
- s_safePointBarrier->leaveSafePoint(this);
+ s_safePointBarrier->leaveSafePoint(this, locker);
m_atSafePoint = false;
m_stackState = HeapPointersOnStack;
clearSafePointScopeMarker();
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698