Esempio n. 1
0
void ThreadState::detachMainThread()
{
    // Enter a safe point before trying to acquire threadAttachMutex
    // to avoid dead lock if another thread is preparing for GC, has acquired
    // threadAttachMutex and waiting for other threads to pause or reach a
    // safepoint.
    ThreadState* state = mainThreadState();

    // 1. Finish sweeping.
    state->completeSweep();
    {
        SafePointAwareMutexLocker locker(threadAttachMutex(), NoHeapPointersOnStack);

        // 2. Add the main thread's heap pages to the orphaned pool.
        state->cleanupPages();

        // 3. Detach the main thread.
        ASSERT(attachedThreads().contains(state));
        attachedThreads().remove(state);
        state->~ThreadState();
    }
    shutdownHeapIfNecessary();
}
Esempio n. 2
0
void ThreadState::shutdown()
{
    mainThreadState()->~ThreadState();
}
Esempio n. 3
0
void ThreadState::init(intptr_t* startOfStack)
{
    s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>();
    new(s_mainThreadStateStorage) ThreadState(startOfStack);
    attachedThreads().add(mainThreadState());
}