Beispiel #1
0
void shutdown()
{
#if defined(LEAK_SANITIZER)
    // If LSan is about to perform leak detection, release all the registered
    // static Persistent<> root references to global caches that Blink keeps,
    // followed by GCs to clear out all they referred to. A full v8 GC cycle
    // is needed to flush out all garbage.
    //
    // This is not needed for caches over non-Oilpan objects, as they're
    // not scanned by LSan due to being held in non-global storage
    // ("static" references inside functions/methods.)
    if (ThreadState* threadState = ThreadState::current()) {
        threadState->releaseStaticPersistentNodes();
        Heap::collectAllGarbage();
    }
#endif

    // currentThread() is null if we are running on a thread without a message loop.
    if (Platform::current()->currentThread()) {
        Platform::current()->unregisterMemoryDumpProvider(WebCacheMemoryDumpProvider::instance());
        Platform::current()->unregisterMemoryDumpProvider(FontCacheMemoryDumpProvider::instance());

        // We don't need to (cannot) remove s_endOfTaskRunner from the current
        // message loop, because the message loop is already destructed before
        // the shutdown() is called.
        delete s_endOfTaskRunner;
        s_endOfTaskRunner = nullptr;

        ASSERT(s_gcTaskRunner);
        delete s_gcTaskRunner;
        s_gcTaskRunner = nullptr;
    }

    // Shutdown V8-related background threads before V8 is ramped down. Note
    // that this will wait the thread to stop its operations.
    ScriptStreamerThread::shutdown();

    v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate();
    V8PerIsolateData::willBeDestroyed(isolate);

    // Make sure we stop WorkerThreads before the main thread's ThreadState
    // and later shutdown steps starts freeing up resources needed during
    // worker termination.
    WorkerThread::terminateAndWaitForAllWorkers();

    ModulesInitializer::terminateThreads();

    // Detach the main thread before starting the shutdown sequence
    // so that the main thread won't get involved in a GC during the shutdown.
    ThreadState::detachMainThread();

    V8PerIsolateData::destroy(isolate);

    shutdownWithoutV8();
}
Beispiel #2
0
void shutdown()
{
    // currentThread() is null if we are running on a thread without a message loop.
    if (Platform::current()->currentThread()) {
        // We don't need to (cannot) remove s_endOfTaskRunner from the current
        // message loop, because the message loop is already destructed before
        // the shutdown() is called.
        delete s_endOfTaskRunner;
        s_endOfTaskRunner = 0;
    }

    ASSERT(s_isolateInterruptor);
    ThreadState::current()->removeInterruptor(s_isolateInterruptor);

    // currentThread() is null if we are running on a thread without a message loop.
    if (Platform::current()->currentThread()) {
        ASSERT(s_pendingGCRunner);
        delete s_pendingGCRunner;
        s_pendingGCRunner = 0;

        ASSERT(s_messageLoopInterruptor);
        ThreadState::current()->removeInterruptor(s_messageLoopInterruptor);
        delete s_messageLoopInterruptor;
        s_messageLoopInterruptor = 0;
    }

    // Shutdown V8-related background threads before V8 is ramped down. Note
    // that this will wait the thread to stop its operations.
    ScriptStreamerThread::shutdown();

    v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate();
    V8PerIsolateData::willBeDestroyed(isolate);

    // Make sure we stop WorkerThreads before the main thread's ThreadState
    // and later shutdown steps starts freeing up resources needed during
    // worker termination.
#ifdef MINIBLINK_NOT_IMPLEMENTED
    WorkerThread::terminateAndWaitForAllWorkers();
#endif // MINIBLINK_NOT_IMPLEMENTED
    ModulesInitializer::terminateThreads();

    // Detach the main thread before starting the shutdown sequence
    // so that the main thread won't get involved in a GC during the shutdown.
    ThreadState::detachMainThread();

    V8PerIsolateData::destroy(isolate);

    shutdownWithoutV8();
}
void shutdown()
{
    // currentThread will always be non-null in production, but can be null in Chromium unit tests.
    if (Platform::current()->currentThread()) {
        ASSERT(s_endOfTaskRunner);
#ifndef NDEBUG
        v8::V8::RemoveCallCompletedCallback(&assertV8RecursionScope);
#endif
        Platform::current()->currentThread()->removeTaskObserver(s_endOfTaskRunner);
        delete s_endOfTaskRunner;
        s_endOfTaskRunner = 0;
    }

    shutdownWithoutV8();

    WebCore::V8PerIsolateData::dispose(v8::Isolate::GetCurrent());
    v8::V8::Dispose();
}
Beispiel #4
0
void shutdown()
{
    // currentThread will always be non-null in production, but can be null in Chromium unit tests.
    if (Platform::current()->currentThread()) {
        ASSERT(s_endOfTaskRunner);
        Platform::current()->currentThread()->removeTaskObserver(s_endOfTaskRunner);
        delete s_endOfTaskRunner;
        s_endOfTaskRunner = 0;
    }

    ASSERT(s_isolateInterruptor);
    WebCore::ThreadState::current()->removeInterruptor(s_isolateInterruptor);

    // currentThread will always be non-null in production, but can be null in Chromium unit tests.
    if (Platform::current()->currentThread()) {
        ASSERT(s_pendingGCRunner);
        delete s_pendingGCRunner;
        s_pendingGCRunner = 0;

        ASSERT(s_messageLoopInterruptor);
        WebCore::ThreadState::current()->removeInterruptor(s_messageLoopInterruptor);
        delete s_messageLoopInterruptor;
        s_messageLoopInterruptor = 0;
    }

    // Detach the main thread before starting the shutdown sequence
    // so that the main thread won't get involved in a GC during the shutdown.
    WebCore::ThreadState::detachMainThread();

    v8::Isolate* isolate = WebCore::V8PerIsolateData::mainThreadIsolate();
    WebCore::V8PerIsolateData::dispose(isolate);
    isolate->Exit();
    isolate->Dispose();

    shutdownWithoutV8();
}