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

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

Issue 260723003: [oilpan]: Make parking threads for GC timeout in the case parking exceeds 100 MS (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 | Source/platform/heap/HeapTest.cpp » ('j') | Source/platform/heap/ThreadState.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Heap.cpp
diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp
index 6803660f46a1e7e0de3cde134f42fc5eb62910a0..c36d9ed3e01e44ebc596d7d5a7a0b6fe18596e4c 100644
--- a/Source/platform/heap/Heap.cpp
+++ b/Source/platform/heap/Heap.cpp
@@ -288,6 +288,7 @@ public:
explicit GCScope(ThreadState::StackState stackState)
: m_state(ThreadState::current())
, m_safePointScope(stackState)
+ , m_parkedAllThreads(false)
{
m_state->checkThread();
@@ -296,20 +297,29 @@ public:
// a row.
RELEASE_ASSERT(!m_state->isInGC());
RELEASE_ASSERT(!m_state->isSweepInProgress());
- ThreadState::stopThreads();
- m_state->enterGC();
+ if (LIKELY(ThreadState::stopThreads())) {
+ m_parkedAllThreads = true;
+ m_state->enterGC();
+ }
}
+ bool allThreadsParked() { return m_parkedAllThreads; }
+
~GCScope()
{
- m_state->leaveGC();
- ASSERT(!m_state->isInGC());
- ThreadState::resumeThreads();
+ // Only cleanup if we parked all threads in which case the GC happened
+ // and we need to resume the other threads.
+ if (LIKELY(m_parkedAllThreads)) {
+ m_state->leaveGC();
+ ASSERT(!m_state->isInGC());
+ ThreadState::resumeThreads();
+ }
}
private:
ThreadState* m_state;
ThreadState::SafePointScope m_safePointScope;
+ bool m_parkedAllThreads; // False if we fail to park all threads
};
NO_SANITIZE_ADDRESS
@@ -1578,7 +1588,11 @@ void Heap::collectGarbage(ThreadState::StackState stackState)
ThreadState::current()->clearGCRequested();
GCScope gcScope(stackState);
-
+ // Check if we successfully parked the other threads. If not we bail out of the GC.
+ if (!gcScope.allThreadsParked()) {
+ ThreadState::current()->setGCRequested();
+ return;
+ }
#if ENABLE(GC_TRACING)
static_cast<MarkingVisitor*>(s_markingVisitor)->objectGraph().clear();
#endif
« no previous file with comments | « no previous file | Source/platform/heap/HeapTest.cpp » ('j') | Source/platform/heap/ThreadState.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698