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

Unified Diff: third_party/WebKit/Source/platform/heap/SafePoint.cpp

Issue 2690893002: Remove SafePointBarrier::parkOthers (Closed)
Patch Set: temp Created 3 years, 10 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
Index: third_party/WebKit/Source/platform/heap/SafePoint.cpp
diff --git a/third_party/WebKit/Source/platform/heap/SafePoint.cpp b/third_party/WebKit/Source/platform/heap/SafePoint.cpp
index 451a4251f06ec8fdc59ad57e63bc7e639938d091..b2e1958304b31cd0984837ba3a012fbb1208bc4b 100644
--- a/third_party/WebKit/Source/platform/heap/SafePoint.cpp
+++ b/third_party/WebKit/Source/platform/heap/SafePoint.cpp
@@ -5,8 +5,6 @@
#include "platform/heap/SafePoint.h"
#include "platform/heap/Heap.h"
-#include "wtf/Atomics.h"
-#include "wtf/CurrentTime.h"
namespace blink {
@@ -17,83 +15,10 @@ extern "C" void pushAllRegisters(SafePointBarrier*,
ThreadState*,
PushAllRegistersCallback);
-static double lockingTimeout() {
- // Wait time for parking all threads is at most 100 ms.
- return 0.100;
-}
-
-SafePointBarrier::SafePointBarrier()
- : m_unparkedThreadCount(0), m_parkingRequested(0) {}
+SafePointBarrier::SafePointBarrier() {}
SafePointBarrier::~SafePointBarrier() {}
-bool SafePointBarrier::parkOthers() {
- ASSERT(ThreadState::current()->isAtSafePoint());
-
- ThreadState* current = ThreadState::current();
- // Lock threadAttachMutex() to prevent threads from attaching.
- current->lockThreadAttachMutex();
- const ThreadStateSet& threads = current->heap().threads();
-
- MutexLocker locker(m_mutex);
- atomicAdd(&m_unparkedThreadCount, threads.size());
- releaseStore(&m_parkingRequested, 1);
-
- for (ThreadState* state : threads) {
- if (state == current)
- continue;
-
- for (auto& interruptor : state->interruptors())
- interruptor->requestInterrupt();
- }
-
- while (acquireLoad(&m_unparkedThreadCount) > 0) {
- double expirationTime = currentTime() + lockingTimeout();
- if (!m_parked.timedWait(m_mutex, expirationTime)) {
- // One of the other threads did not return to a safepoint within the
- // maximum time we allow for threads to be parked. Abandon the GC and
- // resume the currently parked threads.
- resumeOthers(true);
- return false;
- }
- }
- return true;
-}
-
-void SafePointBarrier::resumeOthers(bool barrierLocked) {
- ThreadState* current = ThreadState::current();
- const ThreadStateSet& threads = current->heap().threads();
- atomicSubtract(&m_unparkedThreadCount, threads.size());
- releaseStore(&m_parkingRequested, 0);
-
- if (UNLIKELY(barrierLocked)) {
- m_resume.broadcast();
- } else {
- // FIXME: Resumed threads will all contend for m_mutex just
- // to unlock it later which is a waste of resources.
- MutexLocker locker(m_mutex);
- m_resume.broadcast();
- }
-
- current->unlockThreadAttachMutex();
- ASSERT(ThreadState::current()->isAtSafePoint());
-}
-
-void SafePointBarrier::checkAndPark(ThreadState* state,
- SafePointAwareMutexLocker* locker) {
- ASSERT(!state->sweepForbidden());
- if (acquireLoad(&m_parkingRequested)) {
- // 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);
- }
-}
-
void SafePointBarrier::enterSafePoint(ThreadState* state) {
ASSERT(!state->sweepForbidden());
pushAllRegisters(this, state, enterSafePointAfterPushRegisters);
@@ -101,28 +26,12 @@ void SafePointBarrier::enterSafePoint(ThreadState* state) {
void SafePointBarrier::leaveSafePoint(ThreadState* state,
SafePointAwareMutexLocker* locker) {
- if (atomicIncrement(&m_unparkedThreadCount) > 0)
- checkAndPark(state, locker);
-}
-
-void SafePointBarrier::doPark(ThreadState* state, intptr_t* stackEnd) {
- state->recordStackEnd(stackEnd);
- MutexLocker locker(m_mutex);
- if (!atomicDecrement(&m_unparkedThreadCount))
- m_parked.signal();
- while (acquireLoad(&m_parkingRequested))
- m_resume.wait(m_mutex);
- atomicIncrement(&m_unparkedThreadCount);
}
void SafePointBarrier::doEnterSafePoint(ThreadState* state,
intptr_t* stackEnd) {
state->recordStackEnd(stackEnd);
state->copyStackUntilSafePointScope();
- if (!atomicDecrement(&m_unparkedThreadCount)) {
- MutexLocker locker(m_mutex);
- m_parked.signal(); // Safe point reached.
- }
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/heap/SafePoint.h ('k') | third_party/WebKit/Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698