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

Unified Diff: sky/engine/platform/heap/ThreadState.h

Issue 681963002: Remove heap/*.cpp files (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 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 | « sky/engine/platform/heap/HeapLinkedStack.h ('k') | sky/engine/platform/heap/ThreadState.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/platform/heap/ThreadState.h
diff --git a/sky/engine/platform/heap/ThreadState.h b/sky/engine/platform/heap/ThreadState.h
index 63118f92f6b6d39a59cfff14dc4d631811c09652..b07fe3ec0c7cec25bcfe60d54c3137b8ba65e093 100644
--- a/sky/engine/platform/heap/ThreadState.h
+++ b/sky/engine/platform/heap/ThreadState.h
@@ -316,7 +316,6 @@ public:
// can no longer use the garbage collected heap after this call.
static void detach();
- static ThreadState* current() { return **s_threadSpecific; }
static ThreadState* mainThreadState()
{
return reinterpret_cast<ThreadState*>(s_mainThreadStateStorage);
@@ -439,36 +438,6 @@ public:
void leaveSafePoint(SafePointAwareMutexLocker* = 0);
bool isAtSafePoint() const { return m_atSafePoint; }
- class SafePointScope {
- public:
- enum ScopeNesting {
- NoNesting,
- AllowNesting
- };
-
- explicit SafePointScope(StackState stackState, ScopeNesting nesting = NoNesting)
- : m_state(ThreadState::current())
- {
- if (m_state->isAtSafePoint()) {
- RELEASE_ASSERT(nesting == AllowNesting);
- // We can ignore stackState because there should be no heap object
- // pointers manipulation after outermost safepoint was entered.
- m_state = 0;
- } else {
- m_state->enterSafePoint(stackState, this);
- }
- }
-
- ~SafePointScope()
- {
- if (m_state)
- m_state->leaveSafePoint();
- }
-
- private:
- ThreadState* m_state;
- };
-
// If attached thread enters long running loop that can call back
// into Blink and leaving and reentering safepoint at every
// transition between this loop and Blink is deemed too expensive
@@ -613,7 +582,6 @@ private:
~ThreadState();
friend class SafePointBarrier;
- friend class SafePointAwareMutexLocker;
void enterSafePoint(StackState, void*);
NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope();
@@ -705,69 +673,13 @@ public:
static ThreadState* state()
{
// This specialization must only be used from the main thread.
- ASSERT(ThreadState::current()->isMainThread());
return ThreadState::mainThreadState();
}
};
template<> class ThreadStateFor<AnyThread> {
public:
- static ThreadState* state() { return ThreadState::current(); }
-};
-
-// 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 {
- WTF_MAKE_NONCOPYABLE(SafePointAwareMutexLocker);
-public:
- explicit SafePointAwareMutexLocker(MutexBase& mutex, ThreadState::StackState stackState = ThreadState::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->isSweepInProgress() && !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;
+ static ThreadState* state() { return 0; }
};
// Common header for heap pages. Needs to be defined before class Visitor.
« no previous file with comments | « sky/engine/platform/heap/HeapLinkedStack.h ('k') | sky/engine/platform/heap/ThreadState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698