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

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: 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
« Source/platform/heap/ThreadState.h ('K') | « 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..1b28e26edaac27933a5485dace518ad79f7c5550 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)
haraken 2014/06/17 12:25:41 Does the |locker| need to be an optional parameter
wibling-chromium 2014/06/17 12:38:21 I prefer it that way to avoid having to pass in 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
+ // lock to be acquired in the sweep phase, e.g. during weak processing
Mads Ager (chromium) 2014/06/17 11:57:19 lock to be -> the lock to be
wibling-chromium 2014/06/17 12:06:40 Done.
+ // 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);
haraken 2014/06/17 12:25:41 Just to confirm: The SafePointAwareLocker is reent
wibling-chromium 2014/06/17 12:38:21 The SafePointAwareLocker is only entering the safe
haraken 2014/06/17 14:25:36 Thanks, makes a lot of sense!
m_stackState = stackState;
+ m_atSafePoint = true;
s_safePointBarrier->checkAndPark(this);
+ m_atSafePoint = false;
haraken 2014/06/17 12:25:41 Nice catch. We should have had these lines...
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();
« Source/platform/heap/ThreadState.h ('K') | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698