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

Unified Diff: Source/platform/heap/ThreadState.cpp

Issue 1007773002: Improve debuggability of failed GCState transitions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | 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 78dbd72ebbbb69142a7e5922dbb6e00826598b5b..ee4371b6feb516b13100408854cb651b9fcffd96 100644
--- a/Source/platform/heap/ThreadState.cpp
+++ b/Source/platform/heap/ThreadState.cpp
@@ -627,42 +627,72 @@ void ThreadState::schedulePreciseGC()
setGCState(PreciseGCScheduled);
}
+namespace {
+
+#define UNEXPECTED_GCSTATE(s) case ThreadState::s: RELEASE_ASSERT_WITH_MESSAGE(false, "Unexpected transition while in GCState " #s); return
+
+void unexpectedGCState(ThreadState::GCState gcState)
+{
+ switch (gcState) {
+ UNEXPECTED_GCSTATE(NoGCScheduled);
sof 2015/03/13 10:49:32 The presubmit script enforced this indentation.
+ UNEXPECTED_GCSTATE(IdleGCScheduled);
+ UNEXPECTED_GCSTATE(PreciseGCScheduled);
+ UNEXPECTED_GCSTATE(GCScheduledForTesting);
+ UNEXPECTED_GCSTATE(StoppingOtherThreads);
+ UNEXPECTED_GCSTATE(GCRunning);
+ UNEXPECTED_GCSTATE(EagerSweepScheduled);
+ UNEXPECTED_GCSTATE(LazySweepScheduled);
+ UNEXPECTED_GCSTATE(Sweeping);
+ UNEXPECTED_GCSTATE(SweepingAndIdleGCScheduled);
+ UNEXPECTED_GCSTATE(SweepingAndPreciseGCScheduled);
+ default:
+ ASSERT_NOT_REACHED();
+ return;
+ }
+}
+
+#undef UNEXPECTED_GCSTATE
+
+} // namespace
+
+#define VERIFY_STATE_TRANSITION(condition) if (UNLIKELY(!(condition))) unexpectedGCState(m_gcState)
+
void ThreadState::setGCState(GCState gcState)
{
switch (gcState) {
case NoGCScheduled:
checkThread();
- RELEASE_ASSERT(m_gcState == StoppingOtherThreads || m_gcState == Sweeping || m_gcState == SweepingAndIdleGCScheduled);
+ VERIFY_STATE_TRANSITION(m_gcState == StoppingOtherThreads || m_gcState == Sweeping || m_gcState == SweepingAndIdleGCScheduled);
break;
case IdleGCScheduled:
case PreciseGCScheduled:
case GCScheduledForTesting:
checkThread();
- RELEASE_ASSERT(m_gcState == NoGCScheduled || m_gcState == IdleGCScheduled || m_gcState == PreciseGCScheduled || m_gcState == GCScheduledForTesting || m_gcState == StoppingOtherThreads || m_gcState == SweepingAndIdleGCScheduled || m_gcState == SweepingAndPreciseGCScheduled);
+ VERIFY_STATE_TRANSITION(m_gcState == NoGCScheduled || m_gcState == IdleGCScheduled || m_gcState == PreciseGCScheduled || m_gcState == GCScheduledForTesting || m_gcState == StoppingOtherThreads || m_gcState == SweepingAndIdleGCScheduled || m_gcState == SweepingAndPreciseGCScheduled);
completeSweep();
break;
case StoppingOtherThreads:
checkThread();
- RELEASE_ASSERT(m_gcState == NoGCScheduled || m_gcState == IdleGCScheduled || m_gcState == PreciseGCScheduled || m_gcState == GCScheduledForTesting || m_gcState == Sweeping || m_gcState == SweepingAndIdleGCScheduled || m_gcState == SweepingAndPreciseGCScheduled);
+ VERIFY_STATE_TRANSITION(m_gcState == NoGCScheduled || m_gcState == IdleGCScheduled || m_gcState == PreciseGCScheduled || m_gcState == GCScheduledForTesting || m_gcState == Sweeping || m_gcState == SweepingAndIdleGCScheduled || m_gcState == SweepingAndPreciseGCScheduled);
completeSweep();
break;
case GCRunning:
ASSERT(!isInGC());
- RELEASE_ASSERT(m_gcState != GCRunning);
+ VERIFY_STATE_TRANSITION(m_gcState != GCRunning);
break;
case EagerSweepScheduled:
case LazySweepScheduled:
ASSERT(isInGC());
- RELEASE_ASSERT(m_gcState == GCRunning);
+ VERIFY_STATE_TRANSITION(m_gcState == GCRunning);
break;
case Sweeping:
checkThread();
- RELEASE_ASSERT(m_gcState == EagerSweepScheduled || m_gcState == LazySweepScheduled);
+ VERIFY_STATE_TRANSITION(m_gcState == EagerSweepScheduled || m_gcState == LazySweepScheduled);
break;
case SweepingAndIdleGCScheduled:
case SweepingAndPreciseGCScheduled:
checkThread();
- RELEASE_ASSERT(m_gcState == Sweeping || m_gcState == SweepingAndIdleGCScheduled || m_gcState == SweepingAndPreciseGCScheduled || m_gcState == StoppingOtherThreads);
+ VERIFY_STATE_TRANSITION(m_gcState == Sweeping || m_gcState == SweepingAndIdleGCScheduled || m_gcState == SweepingAndPreciseGCScheduled || m_gcState == StoppingOtherThreads);
break;
default:
ASSERT_NOT_REACHED();
@@ -670,6 +700,8 @@ void ThreadState::setGCState(GCState gcState)
m_gcState = gcState;
}
+#undef VERIFY_STATE_TRANSITION
+
ThreadState::GCState ThreadState::gcState() const
{
return m_gcState;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698