Commit 5c3ca4cb authored by keishi's avatar keishi Committed by Commit bot

Remove ThreadHeapMode and make per thread heap mandatory

Removes ThreadHeapMode enum and makes per thread heap mandatory.

Remove HeapTests.{GCParkingTimeout,RecursiveMutex,ObjectDeadBit} because they test threads attached to the main thread's heap.

BUG=591606

Review-Url: https://codereview.chromium.org/2625293002
Cr-Commit-Position: refs/heads/master@{#443190}
parent c5138fa2
...@@ -83,8 +83,7 @@ HTMLParserThread* HTMLParserThread::shared() { ...@@ -83,8 +83,7 @@ HTMLParserThread* HTMLParserThread::shared() {
void HTMLParserThread::postTask(std::unique_ptr<CrossThreadClosure> closure) { void HTMLParserThread::postTask(std::unique_ptr<CrossThreadClosure> closure) {
ASSERT(isMainThread()); ASSERT(isMainThread());
if (!m_thread) { if (!m_thread) {
m_thread = WebThreadSupportingGC::create("HTMLParserThread", m_thread = WebThreadSupportingGC::create("HTMLParserThread");
BlinkGC::PerThreadHeapMode);
postTask(crossThreadBind(&HTMLParserThread::setupHTMLParserThread, postTask(crossThreadBind(&HTMLParserThread::setupHTMLParserThread,
crossThreadUnretained(this))); crossThreadUnretained(this)));
} }
......
...@@ -46,16 +46,13 @@ static void removeWorkerIsolate(v8::Isolate* isolate) { ...@@ -46,16 +46,13 @@ static void removeWorkerIsolate(v8::Isolate* isolate) {
WorkerBackingThread::WorkerBackingThread(const char* name, WorkerBackingThread::WorkerBackingThread(const char* name,
bool shouldCallGCOnShutdown) bool shouldCallGCOnShutdown)
: m_backingThread( : m_backingThread(WebThreadSupportingGC::create(name)),
WebThreadSupportingGC::create(name, BlinkGC::PerThreadHeapMode)),
m_isOwningThread(true), m_isOwningThread(true),
m_shouldCallGCOnShutdown(shouldCallGCOnShutdown) {} m_shouldCallGCOnShutdown(shouldCallGCOnShutdown) {}
WorkerBackingThread::WorkerBackingThread(WebThread* thread, WorkerBackingThread::WorkerBackingThread(WebThread* thread,
bool shouldCallGCOnShutdown) bool shouldCallGCOnShutdown)
: m_backingThread( : m_backingThread(WebThreadSupportingGC::createForThread(thread)),
WebThreadSupportingGC::createForThread(thread,
BlinkGC::PerThreadHeapMode)),
m_isOwningThread(false), m_isOwningThread(false),
m_shouldCallGCOnShutdown(shouldCallGCOnShutdown) {} m_shouldCallGCOnShutdown(shouldCallGCOnShutdown) {}
......
...@@ -40,8 +40,7 @@ class WaitingHandle final : public WebDataConsumerHandle { ...@@ -40,8 +40,7 @@ class WaitingHandle final : public WebDataConsumerHandle {
DataConsumerHandleTestUtil::Thread::Thread( DataConsumerHandleTestUtil::Thread::Thread(
const char* name, const char* name,
InitializationPolicy initializationPolicy) InitializationPolicy initializationPolicy)
: m_thread( : m_thread(WebThreadSupportingGC::create(name)),
WebThreadSupportingGC::create(name, BlinkGC::MainThreadHeapMode)),
m_initializationPolicy(initializationPolicy), m_initializationPolicy(initializationPolicy),
m_waitableEvent(WTF::makeUnique<WaitableEvent>()) { m_waitableEvent(WTF::makeUnique<WaitableEvent>()) {
m_thread->postTask( m_thread->postTask(
......
...@@ -60,8 +60,7 @@ void DatabaseThread::start() { ...@@ -60,8 +60,7 @@ void DatabaseThread::start() {
ASSERT(isMainThread()); ASSERT(isMainThread());
if (m_thread) if (m_thread)
return; return;
m_thread = WebThreadSupportingGC::create("WebCore: Database", m_thread = WebThreadSupportingGC::create("WebCore: Database");
BlinkGC::PerThreadHeapMode);
m_thread->postTask(BLINK_FROM_HERE, m_thread->postTask(BLINK_FROM_HERE,
crossThreadBind(&DatabaseThread::setupDatabaseThread, crossThreadBind(&DatabaseThread::setupDatabaseThread,
wrapCrossThreadPersistent(this))); wrapCrossThreadPersistent(this)));
......
...@@ -13,24 +13,18 @@ ...@@ -13,24 +13,18 @@
namespace blink { namespace blink {
std::unique_ptr<WebThreadSupportingGC> WebThreadSupportingGC::create( std::unique_ptr<WebThreadSupportingGC> WebThreadSupportingGC::create(
const char* name, const char* name) {
BlinkGC::ThreadHeapMode threadHeapMode) { return WTF::wrapUnique(new WebThreadSupportingGC(name, nullptr));
return WTF::wrapUnique(
new WebThreadSupportingGC(name, nullptr, threadHeapMode));
} }
std::unique_ptr<WebThreadSupportingGC> WebThreadSupportingGC::createForThread( std::unique_ptr<WebThreadSupportingGC> WebThreadSupportingGC::createForThread(
WebThread* thread, WebThread* thread) {
BlinkGC::ThreadHeapMode threadHeapMode) { return WTF::wrapUnique(new WebThreadSupportingGC(nullptr, thread));
return WTF::wrapUnique(
new WebThreadSupportingGC(nullptr, thread, threadHeapMode));
} }
WebThreadSupportingGC::WebThreadSupportingGC( WebThreadSupportingGC::WebThreadSupportingGC(const char* name,
const char* name, WebThread* thread)
WebThread* thread, : m_thread(thread) {
BlinkGC::ThreadHeapMode threadHeapMode)
: m_thread(thread), m_threadHeapMode(threadHeapMode) {
DCHECK(!name || !thread); DCHECK(!name || !thread);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
// We call this regardless of whether an existing thread is given or not, // We call this regardless of whether an existing thread is given or not,
...@@ -53,7 +47,7 @@ WebThreadSupportingGC::~WebThreadSupportingGC() { ...@@ -53,7 +47,7 @@ WebThreadSupportingGC::~WebThreadSupportingGC() {
} }
void WebThreadSupportingGC::initialize() { void WebThreadSupportingGC::initialize() {
ThreadState::attachCurrentThread(m_threadHeapMode); ThreadState::attachCurrentThread();
m_gcTaskRunner = WTF::makeUnique<GCTaskRunner>(m_thread); m_gcTaskRunner = WTF::makeUnique<GCTaskRunner>(m_thread);
} }
......
...@@ -29,11 +29,8 @@ class PLATFORM_EXPORT WebThreadSupportingGC final { ...@@ -29,11 +29,8 @@ class PLATFORM_EXPORT WebThreadSupportingGC final {
WTF_MAKE_NONCOPYABLE(WebThreadSupportingGC); WTF_MAKE_NONCOPYABLE(WebThreadSupportingGC);
public: public:
static std::unique_ptr<WebThreadSupportingGC> create(const char* name, static std::unique_ptr<WebThreadSupportingGC> create(const char* name);
BlinkGC::ThreadHeapMode); static std::unique_ptr<WebThreadSupportingGC> createForThread(WebThread*);
static std::unique_ptr<WebThreadSupportingGC> createForThread(
WebThread*,
BlinkGC::ThreadHeapMode);
~WebThreadSupportingGC(); ~WebThreadSupportingGC();
void postTask(const WebTraceLocation& location, void postTask(const WebTraceLocation& location,
...@@ -79,7 +76,7 @@ class PLATFORM_EXPORT WebThreadSupportingGC final { ...@@ -79,7 +76,7 @@ class PLATFORM_EXPORT WebThreadSupportingGC final {
} }
private: private:
WebThreadSupportingGC(const char* name, WebThread*, BlinkGC::ThreadHeapMode); WebThreadSupportingGC(const char* name, WebThread*);
std::unique_ptr<GCTaskRunner> m_gcTaskRunner; std::unique_ptr<GCTaskRunner> m_gcTaskRunner;
...@@ -88,7 +85,6 @@ class PLATFORM_EXPORT WebThreadSupportingGC final { ...@@ -88,7 +85,6 @@ class PLATFORM_EXPORT WebThreadSupportingGC final {
// existing thread via createForThread(). // existing thread via createForThread().
WebThread* m_thread = nullptr; WebThread* m_thread = nullptr;
std::unique_ptr<WebThread> m_owningThread; std::unique_ptr<WebThread> m_owningThread;
const BlinkGC::ThreadHeapMode m_threadHeapMode;
}; };
} // namespace blink } // namespace blink
......
...@@ -105,11 +105,6 @@ class PLATFORM_EXPORT BlinkGC final { ...@@ -105,11 +105,6 @@ class PLATFORM_EXPORT BlinkGC final {
V8MinorGC, V8MinorGC,
V8MajorGC, V8MajorGC,
}; };
enum ThreadHeapMode {
MainThreadHeapMode,
PerThreadHeapMode,
};
}; };
} // namespace blink } // namespace blink
......
...@@ -256,12 +256,6 @@ void ThreadHeap::detach(ThreadState* thread) { ...@@ -256,12 +256,6 @@ void ThreadHeap::detach(ThreadState* thread) {
m_threads.remove(thread); m_threads.remove(thread);
isLastThread = m_threads.isEmpty(); isLastThread = m_threads.isEmpty();
} }
// The last thread begin detached should be the owning thread, which would
// be the main thread for the mainThreadHeap and a per thread heap enabled
// thread otherwise.
if (isLastThread)
DCHECK(thread->threadHeapMode() == BlinkGC::PerThreadHeapMode ||
thread->isMainThread());
if (thread->isMainThread()) if (thread->isMainThread())
DCHECK_EQ(heapStats().allocatedSpace(), 0u); DCHECK_EQ(heapStats().allocatedSpace(), 0u);
if (isLastThread) if (isLastThread)
......
...@@ -139,7 +139,7 @@ class ParkThreadsScope final { ...@@ -139,7 +139,7 @@ class ParkThreadsScope final {
bool m_shouldResumeThreads; bool m_shouldResumeThreads;
}; };
ThreadState::ThreadState(BlinkGC::ThreadHeapMode threadHeapMode) ThreadState::ThreadState()
: m_thread(currentThread()), : m_thread(currentThread()),
m_persistentRegion(WTF::makeUnique<PersistentRegion>()), m_persistentRegion(WTF::makeUnique<PersistentRegion>()),
#if OS(WIN) && COMPILER(MSVC) #if OS(WIN) && COMPILER(MSVC)
...@@ -159,7 +159,6 @@ ThreadState::ThreadState(BlinkGC::ThreadHeapMode threadHeapMode) ...@@ -159,7 +159,6 @@ ThreadState::ThreadState(BlinkGC::ThreadHeapMode threadHeapMode)
m_accumulatedSweepingTime(0), m_accumulatedSweepingTime(0),
m_vectorBackingArenaIndex(BlinkGC::Vector1ArenaIndex), m_vectorBackingArenaIndex(BlinkGC::Vector1ArenaIndex),
m_currentArenaAges(0), m_currentArenaAges(0),
m_threadHeapMode(threadHeapMode),
m_isTerminating(false), m_isTerminating(false),
m_gcMixinMarker(nullptr), m_gcMixinMarker(nullptr),
m_shouldFlushHeapDoesNotContainCache(false), m_shouldFlushHeapDoesNotContainCache(false),
...@@ -181,25 +180,17 @@ ThreadState::ThreadState(BlinkGC::ThreadHeapMode threadHeapMode) ...@@ -181,25 +180,17 @@ ThreadState::ThreadState(BlinkGC::ThreadHeapMode threadHeapMode)
ASSERT(!**s_threadSpecific); ASSERT(!**s_threadSpecific);
**s_threadSpecific = this; **s_threadSpecific = this;
switch (m_threadHeapMode) { if (isMainThread()) {
case BlinkGC::MainThreadHeapMode: s_mainThreadStackStart =
if (isMainThread()) { reinterpret_cast<uintptr_t>(m_startOfStack) - sizeof(void*);
s_mainThreadStackStart = size_t underestimatedStackSize =
reinterpret_cast<uintptr_t>(m_startOfStack) - sizeof(void*); StackFrameDepth::getUnderestimatedStackSize();
size_t underestimatedStackSize = if (underestimatedStackSize > sizeof(void*)) {
StackFrameDepth::getUnderestimatedStackSize(); s_mainThreadUnderestimatedStackSize =
if (underestimatedStackSize > sizeof(void*)) underestimatedStackSize - sizeof(void*);
s_mainThreadUnderestimatedStackSize = }
underestimatedStackSize - sizeof(void*);
m_heap = new ThreadHeap();
} else {
m_heap = &ThreadState::mainThreadState()->heap();
}
break;
case BlinkGC::PerThreadHeapMode:
m_heap = new ThreadHeap();
break;
} }
m_heap = new ThreadHeap();
ASSERT(m_heap); ASSERT(m_heap);
m_heap->attach(this); m_heap->attach(this);
...@@ -265,12 +256,12 @@ size_t ThreadState::threadStackSize() { ...@@ -265,12 +256,12 @@ size_t ThreadState::threadStackSize() {
void ThreadState::attachMainThread() { void ThreadState::attachMainThread() {
RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete); RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete);
s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>(); s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>();
new (s_mainThreadStateStorage) ThreadState(BlinkGC::MainThreadHeapMode); new (s_mainThreadStateStorage) ThreadState();
} }
void ThreadState::attachCurrentThread(BlinkGC::ThreadHeapMode threadHeapMode) { void ThreadState::attachCurrentThread() {
RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete); RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete);
new ThreadState(threadHeapMode); new ThreadState();
} }
void ThreadState::cleanupPages() { void ThreadState::cleanupPages() {
......
...@@ -167,8 +167,6 @@ class PLATFORM_EXPORT ThreadState { ...@@ -167,8 +167,6 @@ class PLATFORM_EXPORT ThreadState {
void lockThreadAttachMutex(); void lockThreadAttachMutex();
void unlockThreadAttachMutex(); void unlockThreadAttachMutex();
BlinkGC::ThreadHeapMode threadHeapMode() const { return m_threadHeapMode; }
bool isTerminating() { return m_isTerminating; } bool isTerminating() { return m_isTerminating; }
static void attachMainThread(); static void attachMainThread();
...@@ -178,7 +176,7 @@ class PLATFORM_EXPORT ThreadState { ...@@ -178,7 +176,7 @@ class PLATFORM_EXPORT ThreadState {
// Associate ThreadState object with the current thread. After this // Associate ThreadState object with the current thread. After this
// call thread can start using the garbage collected heap infrastructure. // call thread can start using the garbage collected heap infrastructure.
// It also has to periodically check for safepoints. // It also has to periodically check for safepoints.
static void attachCurrentThread(BlinkGC::ThreadHeapMode); static void attachCurrentThread();
// Disassociate attached ThreadState from the current thread. The thread // Disassociate attached ThreadState from the current thread. The thread
// can no longer use the garbage collected heap after this call. // can no longer use the garbage collected heap after this call.
...@@ -588,7 +586,7 @@ class PLATFORM_EXPORT ThreadState { ...@@ -588,7 +586,7 @@ class PLATFORM_EXPORT ThreadState {
friend class PrefinalizerRegistration; friend class PrefinalizerRegistration;
enum SnapshotType { HeapSnapshot, FreelistSnapshot }; enum SnapshotType { HeapSnapshot, FreelistSnapshot };
explicit ThreadState(BlinkGC::ThreadHeapMode); ThreadState();
~ThreadState(); ~ThreadState();
NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope();
...@@ -704,7 +702,6 @@ class PLATFORM_EXPORT ThreadState { ...@@ -704,7 +702,6 @@ class PLATFORM_EXPORT ThreadState {
size_t m_arenaAges[BlinkGC::NumberOfArenas]; size_t m_arenaAges[BlinkGC::NumberOfArenas];
size_t m_currentArenaAges; size_t m_currentArenaAges;
const BlinkGC::ThreadHeapMode m_threadHeapMode;
bool m_isTerminating; bool m_isTerminating;
GarbageCollectedMixinConstructorMarker* m_gcMixinMarker; GarbageCollectedMixinConstructorMarker* m_gcMixinMarker;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment