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

Unified Diff: Source/heap/ThreadState.cpp

Issue 100433005: [oilpan] Rename PauseScope to SafePointScope (Closed) Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/heap/ThreadState.cpp
diff --git a/Source/heap/ThreadState.cpp b/Source/heap/ThreadState.cpp
index e915d48d8a5cdb429e9933d239808f1c25b73972..7feac15c2ab3340fa37833c00acaa13d37530aff 100644
--- a/Source/heap/ThreadState.cpp
+++ b/Source/heap/ThreadState.cpp
@@ -59,7 +59,7 @@ static Mutex& threadAttachMutex()
}
static void parkAfterPushRegisters(SafePointBarrier*, ThreadState*, intptr_t* stackEnd);
-static void notifyPausedAfterPushRegisters(SafePointBarrier*, ThreadState*, intptr_t* stackEnd);
+static void enterSafePointAfterPushRegisters(SafePointBarrier*, ThreadState*, intptr_t* stackEnd);
class SafePointBarrier {
public:
@@ -73,12 +73,12 @@ public:
{
}
- // Request other attached and non-paused threads to park themselves on safepoints.
+ // Request other attached and not-in-safe-point threads to park themselves on safepoints.
Mads Ager (chromium) 2013/12/05 09:22:24 Request other attached threads that are not at saf
haraken 2013/12/05 09:37:40 Done.
void parkOthers(ThreadState::StackState stackState)
{
- // Mark current thread as paused before attempting to lock the threadAttachMutex(). This will
+ // Enter safe point before attempting to lock the threadAttachMutex(). This will
// allow to avoid dead-lock if two threads arrive into parkOthers() simultaneously.
- ThreadState::Current()->paused(stackState);
+ ThreadState::Current()->enterSafePoint(stackState);
// Lock threadAttachMutex() to prevent threads from attaching.
threadAttachMutex().lock();
@@ -104,7 +104,7 @@ public:
NoBarrier_AtomicIncrement(&m_unparkedThreadCount, -threads.size());
Release_Store(&m_canResume, 1);
{
- // FIXME(oilpan) resumed threads will all contend for
+ // FIXME(oilpan): Resumed threads will all contend for
// m_mutex just to unlock it later which is a waste of
// resources.
MutexLocker locker(m_mutex);
@@ -117,7 +117,7 @@ public:
}
threadAttachMutex().unlock();
- ThreadState::Current()->resumed();
+ ThreadState::Current()->leaveSafePoint();
}
void doPark(ThreadState* state, intptr_t* stackEnd)
@@ -140,7 +140,7 @@ public:
}
}
- void doNotifyPaused(ThreadState* state, intptr_t* stackEnd)
+ void doEnterSafePoint(ThreadState* state, intptr_t* stackEnd)
{
state->recordStackEnd(stackEnd);
if (!NoBarrier_AtomicIncrement(&m_unparkedThreadCount, -1)) {
@@ -149,13 +149,13 @@ public:
}
}
- void notifyPaused(ThreadState* state)
+ void enterSafePoint(ThreadState* state)
{
ASSERT(!state->isSweepInProgress());
- pushAllRegisters(this, state, notifyPausedAfterPushRegisters);
+ pushAllRegisters(this, state, enterSafePointAfterPushRegisters);
}
- void notifyResumed(ThreadState* state)
+ void leaveSafePoint(ThreadState* state)
{
if (NoBarrier_AtomicIncrement(&m_unparkedThreadCount, 1) > 0)
checkAndPark(state);
@@ -211,14 +211,14 @@ void ThreadState::attach(intptr_t* startOfStack)
void ThreadState::detach()
{
ThreadState* current = Current();
- // Mark current thread as paused before trying to acquire threadAttachMutex
+ // Enter safe point before trying to acquire threadAttachMutex
// to avoid dead lock if another thread is preparing for GC, has acquired
// threadAttachMutex and waiting for other threads to pause or reach a
// safepoint.
- if (!current->isPaused())
- current->paused(NoHeapPointersOnStack);
+ if (!current->isInSafePoint())
+ current->enterSafePoint(NoHeapPointersOnStack);
MutexLocker locker(threadAttachMutex());
- current->resumed();
+ current->leaveSafePoint();
current->destroy();
attachedThreads().remove(current);
delete current;
@@ -267,24 +267,24 @@ void ThreadState::destroy()
m_interruptor = 0;
}
-void ThreadState::paused(StackState stackState)
+void ThreadState::enterSafePoint(StackState stackState)
{
if (stackState == NoHeapPointersOnStack && gcRequested())
Heap::collectGarbage(NoHeapPointersOnStack);
checkThread();
- ASSERT(!m_isPaused);
- m_isPaused = true;
+ ASSERT(!m_inSafePoint);
+ m_inSafePoint = true;
m_stackState = stackState;
- s_safePointBarrier->notifyPaused(this);
+ s_safePointBarrier->enterSafePoint(this);
}
-void ThreadState::resumed()
+void ThreadState::leaveSafePoint()
{
checkThread();
- ASSERT(m_isPaused);
- m_isPaused = false;
+ ASSERT(m_inSafePoint);
+ m_inSafePoint = false;
m_stackState = HeapPointersOnStack;
- s_safePointBarrier->notifyResumed(this);
+ s_safePointBarrier->leaveSafePoint(this);
}
void ThreadState::visitRoots(Visitor* visitor)
@@ -447,10 +447,10 @@ void ThreadState::setGCRequested(bool gcRequested)
void ThreadState::setInterruptor(Interruptor* interruptor)
{
- bool wasPaused = false;
- if (!isPaused()) {
- paused(HeapPointersOnStack);
- wasPaused = true;
+ bool wasInSafePoint = false;
Mads Ager (chromium) 2013/12/05 09:22:24 wasAtSafePoint?
+ if (!isInSafePoint()) {
+ enterSafePoint(HeapPointersOnStack);
+ wasInSafePoint = true;
}
{
@@ -459,8 +459,8 @@ void ThreadState::setInterruptor(Interruptor* interruptor)
m_interruptor = interruptor;
}
- if (wasPaused)
- resumed();
+ if (wasInSafePoint)
+ leaveSafePoint();
}
bool ThreadState::inFinalizeAll()
@@ -501,7 +501,7 @@ void ThreadState::Interruptor::onInterrupted()
{
ThreadState* state = ThreadState::Current();
ASSERT(state);
- ASSERT(!state->isPaused());
+ ASSERT(!state->isInSafePoint());
state->safePoint();
}
@@ -546,9 +546,9 @@ static void parkAfterPushRegisters(SafePointBarrier* barrier, ThreadState* state
barrier->doPark(state, stackEnd);
}
-static void notifyPausedAfterPushRegisters(SafePointBarrier* barrier, ThreadState* state, intptr_t* stackEnd)
+static void enterSafePointAfterPushRegisters(SafePointBarrier* barrier, ThreadState* state, intptr_t* stackEnd)
{
- barrier->doNotifyPaused(state, stackEnd);
+ barrier->doEnterSafePoint(state, stackEnd);
}

Powered by Google App Engine
This is Rietveld 408576698