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

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

Issue 2355193002: Use enum for per thread heap enabled flag (Closed)
Patch Set: Created 4 years, 3 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/ThreadState.cpp
diff --git a/third_party/WebKit/Source/platform/heap/ThreadState.cpp b/third_party/WebKit/Source/platform/heap/ThreadState.cpp
index 60939a77881ebddff143d09cb22abb5f1fae9553..949d1a83fb6fbafbfd5b3fbdf9bb55724cedc374 100644
--- a/third_party/WebKit/Source/platform/heap/ThreadState.cpp
+++ b/third_party/WebKit/Source/platform/heap/ThreadState.cpp
@@ -145,7 +145,7 @@ private:
bool m_shouldResumeThreads;
};
-ThreadState::ThreadState(bool perThreadHeapEnabled)
+ThreadState::ThreadState(ThreadHeapMode threadHeapMode)
: m_thread(currentThread())
, m_persistentRegion(wrapUnique(new PersistentRegion()))
#if OS(WIN) && COMPILER(MSVC)
@@ -162,7 +162,7 @@ ThreadState::ThreadState(bool perThreadHeapEnabled)
, m_accumulatedSweepingTime(0)
, m_vectorBackingArenaIndex(BlinkGC::Vector1ArenaIndex)
, m_currentArenaAges(0)
- , m_perThreadHeapEnabled(perThreadHeapEnabled)
+ , m_threadHeapMode(threadHeapMode)
, m_isTerminating(false)
, m_gcMixinMarker(nullptr)
, m_shouldFlushHeapDoesNotContainCache(false)
@@ -185,16 +185,23 @@ ThreadState::ThreadState(bool perThreadHeapEnabled)
ASSERT(!**s_threadSpecific);
**s_threadSpecific = this;
- if (m_perThreadHeapEnabled) {
- m_heap = new ThreadHeap();
- } else if (isMainThread()) {
- s_mainThreadStackStart = reinterpret_cast<uintptr_t>(m_startOfStack) - sizeof(void*);
- size_t underestimatedStackSize = StackFrameDepth::getUnderestimatedStackSize();
- if (underestimatedStackSize > sizeof(void*))
- s_mainThreadUnderestimatedStackSize = underestimatedStackSize - sizeof(void*);
+ switch (m_threadHeapMode) {
+ case MainThreadHeapMode:
+ if (isMainThread()) {
+ s_mainThreadStackStart = reinterpret_cast<uintptr_t>(m_startOfStack) - sizeof(void*);
+ size_t underestimatedStackSize = StackFrameDepth::getUnderestimatedStackSize();
+ if (underestimatedStackSize > sizeof(void*))
+ s_mainThreadUnderestimatedStackSize = underestimatedStackSize - sizeof(void*);
+ m_heap = new ThreadHeap();
+ } else {
+ m_heap = &ThreadState::mainThreadState()->heap();
+ }
+ break;
+ case PerThreadHeapMode:
m_heap = new ThreadHeap();
- } else {
- m_heap = &ThreadState::mainThreadState()->heap();
+ break;
+ default:
+ NOTREACHED();
nhiroki 2016/09/21 05:15:26 Is "default" case necessary?
keishi 2016/09/21 07:06:37 Removed.
}
ASSERT(m_heap);
m_heap->attach(this);
@@ -259,13 +266,13 @@ void ThreadState::attachMainThread()
{
RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete);
s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>();
- new (s_mainThreadStateStorage) ThreadState(false);
+ new (s_mainThreadStateStorage) ThreadState(MainThreadHeapMode);
}
-void ThreadState::attachCurrentThread(bool perThreadHeapEnabled)
+void ThreadState::attachCurrentThread(ThreadHeapMode threadHeapMode)
{
RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete);
- new ThreadState(perThreadHeapEnabled);
+ new ThreadState(threadHeapMode);
}
void ThreadState::cleanupPages()

Powered by Google App Engine
This is Rietveld 408576698