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() {
void HTMLParserThread::postTask(std::unique_ptr<CrossThreadClosure> closure) {
ASSERT(isMainThread());
if (!m_thread) {
m_thread = WebThreadSupportingGC::create("HTMLParserThread",
BlinkGC::PerThreadHeapMode);
m_thread = WebThreadSupportingGC::create("HTMLParserThread");
postTask(crossThreadBind(&HTMLParserThread::setupHTMLParserThread,
crossThreadUnretained(this)));
}
......
......@@ -46,16 +46,13 @@ static void removeWorkerIsolate(v8::Isolate* isolate) {
WorkerBackingThread::WorkerBackingThread(const char* name,
bool shouldCallGCOnShutdown)
: m_backingThread(
WebThreadSupportingGC::create(name, BlinkGC::PerThreadHeapMode)),
: m_backingThread(WebThreadSupportingGC::create(name)),
m_isOwningThread(true),
m_shouldCallGCOnShutdown(shouldCallGCOnShutdown) {}
WorkerBackingThread::WorkerBackingThread(WebThread* thread,
bool shouldCallGCOnShutdown)
: m_backingThread(
WebThreadSupportingGC::createForThread(thread,
BlinkGC::PerThreadHeapMode)),
: m_backingThread(WebThreadSupportingGC::createForThread(thread)),
m_isOwningThread(false),
m_shouldCallGCOnShutdown(shouldCallGCOnShutdown) {}
......
......@@ -40,8 +40,7 @@ class WaitingHandle final : public WebDataConsumerHandle {
DataConsumerHandleTestUtil::Thread::Thread(
const char* name,
InitializationPolicy initializationPolicy)
: m_thread(
WebThreadSupportingGC::create(name, BlinkGC::MainThreadHeapMode)),
: m_thread(WebThreadSupportingGC::create(name)),
m_initializationPolicy(initializationPolicy),
m_waitableEvent(WTF::makeUnique<WaitableEvent>()) {
m_thread->postTask(
......
......@@ -60,8 +60,7 @@ void DatabaseThread::start() {
ASSERT(isMainThread());
if (m_thread)
return;
m_thread = WebThreadSupportingGC::create("WebCore: Database",
BlinkGC::PerThreadHeapMode);
m_thread = WebThreadSupportingGC::create("WebCore: Database");
m_thread->postTask(BLINK_FROM_HERE,
crossThreadBind(&DatabaseThread::setupDatabaseThread,
wrapCrossThreadPersistent(this)));
......
......@@ -13,24 +13,18 @@
namespace blink {
std::unique_ptr<WebThreadSupportingGC> WebThreadSupportingGC::create(
const char* name,
BlinkGC::ThreadHeapMode threadHeapMode) {
return WTF::wrapUnique(
new WebThreadSupportingGC(name, nullptr, threadHeapMode));
const char* name) {
return WTF::wrapUnique(new WebThreadSupportingGC(name, nullptr));
}
std::unique_ptr<WebThreadSupportingGC> WebThreadSupportingGC::createForThread(
WebThread* thread,
BlinkGC::ThreadHeapMode threadHeapMode) {
return WTF::wrapUnique(
new WebThreadSupportingGC(nullptr, thread, threadHeapMode));
WebThread* thread) {
return WTF::wrapUnique(new WebThreadSupportingGC(nullptr, thread));
}
WebThreadSupportingGC::WebThreadSupportingGC(
const char* name,
WebThread* thread,
BlinkGC::ThreadHeapMode threadHeapMode)
: m_thread(thread), m_threadHeapMode(threadHeapMode) {
WebThreadSupportingGC::WebThreadSupportingGC(const char* name,
WebThread* thread)
: m_thread(thread) {
DCHECK(!name || !thread);
#if DCHECK_IS_ON()
// We call this regardless of whether an existing thread is given or not,
......@@ -53,7 +47,7 @@ WebThreadSupportingGC::~WebThreadSupportingGC() {
}
void WebThreadSupportingGC::initialize() {
ThreadState::attachCurrentThread(m_threadHeapMode);
ThreadState::attachCurrentThread();
m_gcTaskRunner = WTF::makeUnique<GCTaskRunner>(m_thread);
}
......
......@@ -29,11 +29,8 @@ class PLATFORM_EXPORT WebThreadSupportingGC final {
WTF_MAKE_NONCOPYABLE(WebThreadSupportingGC);
public:
static std::unique_ptr<WebThreadSupportingGC> create(const char* name,
BlinkGC::ThreadHeapMode);
static std::unique_ptr<WebThreadSupportingGC> createForThread(
WebThread*,
BlinkGC::ThreadHeapMode);
static std::unique_ptr<WebThreadSupportingGC> create(const char* name);
static std::unique_ptr<WebThreadSupportingGC> createForThread(WebThread*);
~WebThreadSupportingGC();
void postTask(const WebTraceLocation& location,
......@@ -79,7 +76,7 @@ class PLATFORM_EXPORT WebThreadSupportingGC final {
}
private:
WebThreadSupportingGC(const char* name, WebThread*, BlinkGC::ThreadHeapMode);
WebThreadSupportingGC(const char* name, WebThread*);
std::unique_ptr<GCTaskRunner> m_gcTaskRunner;
......@@ -88,7 +85,6 @@ class PLATFORM_EXPORT WebThreadSupportingGC final {
// existing thread via createForThread().
WebThread* m_thread = nullptr;
std::unique_ptr<WebThread> m_owningThread;
const BlinkGC::ThreadHeapMode m_threadHeapMode;
};
} // namespace blink
......
......@@ -105,11 +105,6 @@ class PLATFORM_EXPORT BlinkGC final {
V8MinorGC,
V8MajorGC,
};
enum ThreadHeapMode {
MainThreadHeapMode,
PerThreadHeapMode,
};
};
} // namespace blink
......
......@@ -256,12 +256,6 @@ void ThreadHeap::detach(ThreadState* thread) {
m_threads.remove(thread);
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())
DCHECK_EQ(heapStats().allocatedSpace(), 0u);
if (isLastThread)
......
......@@ -139,7 +139,7 @@ class ParkThreadsScope final {
bool m_shouldResumeThreads;
};
ThreadState::ThreadState(BlinkGC::ThreadHeapMode threadHeapMode)
ThreadState::ThreadState()
: m_thread(currentThread()),
m_persistentRegion(WTF::makeUnique<PersistentRegion>()),
#if OS(WIN) && COMPILER(MSVC)
......@@ -159,7 +159,6 @@ ThreadState::ThreadState(BlinkGC::ThreadHeapMode threadHeapMode)
m_accumulatedSweepingTime(0),
m_vectorBackingArenaIndex(BlinkGC::Vector1ArenaIndex),
m_currentArenaAges(0),
m_threadHeapMode(threadHeapMode),
m_isTerminating(false),
m_gcMixinMarker(nullptr),
m_shouldFlushHeapDoesNotContainCache(false),
......@@ -181,25 +180,17 @@ ThreadState::ThreadState(BlinkGC::ThreadHeapMode threadHeapMode)
ASSERT(!**s_threadSpecific);
**s_threadSpecific = this;
switch (m_threadHeapMode) {
case BlinkGC::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 BlinkGC::PerThreadHeapMode:
m_heap = new ThreadHeap();
break;
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();
ASSERT(m_heap);
m_heap->attach(this);
......@@ -265,12 +256,12 @@ size_t ThreadState::threadStackSize() {
void ThreadState::attachMainThread() {
RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete);
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);
new ThreadState(threadHeapMode);
new ThreadState();
}
void ThreadState::cleanupPages() {
......
......@@ -167,8 +167,6 @@ class PLATFORM_EXPORT ThreadState {
void lockThreadAttachMutex();
void unlockThreadAttachMutex();
BlinkGC::ThreadHeapMode threadHeapMode() const { return m_threadHeapMode; }
bool isTerminating() { return m_isTerminating; }
static void attachMainThread();
......@@ -178,7 +176,7 @@ class PLATFORM_EXPORT ThreadState {
// Associate ThreadState object with the current thread. After this
// call thread can start using the garbage collected heap infrastructure.
// 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
// can no longer use the garbage collected heap after this call.
......@@ -588,7 +586,7 @@ class PLATFORM_EXPORT ThreadState {
friend class PrefinalizerRegistration;
enum SnapshotType { HeapSnapshot, FreelistSnapshot };
explicit ThreadState(BlinkGC::ThreadHeapMode);
ThreadState();
~ThreadState();
NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope();
......@@ -704,7 +702,6 @@ class PLATFORM_EXPORT ThreadState {
size_t m_arenaAges[BlinkGC::NumberOfArenas];
size_t m_currentArenaAges;
const BlinkGC::ThreadHeapMode m_threadHeapMode;
bool m_isTerminating;
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