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

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

Issue 2691073004: Remove SafePointAwareMutexLocker (Closed)
Patch Set: 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.h
diff --git a/third_party/WebKit/Source/platform/heap/SafePoint.h b/third_party/WebKit/Source/platform/heap/SafePoint.h
index 4b1bfcd12243ebf1167ba2c9534a3678eaf74101..4fe8a901e77c70f38e4a3c5dd0a313ec86330c90 100644
--- a/third_party/WebKit/Source/platform/heap/SafePoint.h
+++ b/third_party/WebKit/Source/platform/heap/SafePoint.h
@@ -33,61 +33,6 @@ class SafePointScope final {
ThreadState* m_state;
};
-// The SafePointAwareMutexLocker is used to enter a safepoint while waiting for
-// a mutex lock. It also ensures that the lock is not held while waiting for a
-// GC to complete in the leaveSafePoint method, by releasing the lock if the
-// leaveSafePoint method cannot complete without blocking, see
-// SafePointBarrier::checkAndPark.
-class SafePointAwareMutexLocker final {
- STACK_ALLOCATED();
- WTF_MAKE_NONCOPYABLE(SafePointAwareMutexLocker);
-
- public:
- explicit SafePointAwareMutexLocker(
- MutexBase& mutex,
- BlinkGC::StackState stackState = BlinkGC::HeapPointersOnStack)
- : m_mutex(mutex), m_locked(false) {
- ThreadState* state = ThreadState::current();
- do {
- bool leaveSafePoint = false;
- // We cannot enter a safepoint if we are currently sweeping. In that
- // case we just try to acquire the lock without being at a safepoint.
- // If another thread tries to do a GC at that time it might time out
- // due to this thread not being at a safepoint and waiting on the lock.
- if (!state->sweepForbidden() && !state->isAtSafePoint()) {
- state->enterSafePoint(stackState, this);
- leaveSafePoint = true;
- }
- m_mutex.lock();
- m_locked = true;
- if (leaveSafePoint) {
- // When leaving the safepoint we might end up release the mutex
- // if another thread is requesting a GC, see
- // SafePointBarrier::checkAndPark. This is the case where we
- // loop around to reacquire the lock.
- state->leaveSafePoint(this);
- }
- } while (!m_locked);
- }
-
- ~SafePointAwareMutexLocker() {
- ASSERT(m_locked);
- m_mutex.unlock();
- }
-
- private:
- friend class SafePointBarrier;
-
- void reset() {
- ASSERT(m_locked);
- m_mutex.unlock();
- m_locked = false;
- }
-
- MutexBase& m_mutex;
- bool m_locked;
-};
-
class SafePointBarrier final {
USING_FAST_MALLOC(SafePointBarrier);
WTF_MAKE_NONCOPYABLE(SafePointBarrier);
@@ -97,7 +42,7 @@ class SafePointBarrier final {
~SafePointBarrier();
void enterSafePoint(ThreadState*);
- void leaveSafePoint(ThreadState*, SafePointAwareMutexLocker* = nullptr);
+ void leaveSafePoint();
private:
void doPark(ThreadState*, intptr_t* stackEnd);

Powered by Google App Engine
This is Rietveld 408576698