From 15f6fdeb3e3b5eea93218fb07635c92ec8047868 Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Fri, 6 Sep 2013 11:02:43 +0000 Subject: [PATCH] Fix multiple V8::Dispose calls since r16563. R=svenpanne@chromium.org BUG=v8:2744 TEST=cctest/test-api/InitializeAndDisposeMultiple Review URL: https://codereview.chromium.org/23775007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16565 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/isolate.h | 1 + src/v8.cc | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/isolate.h b/src/isolate.h index 741c4c0..5ca776d 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -1383,6 +1383,7 @@ class Isolate { friend class v8::Isolate; friend class v8::Locker; friend class v8::Unlocker; + friend class V8; DISALLOW_COPY_AND_ASSIGN(Isolate); }; diff --git a/src/v8.cc b/src/v8.cc index d9ce840..c4ce062 100644 --- a/src/v8.cc +++ b/src/v8.cc @@ -63,8 +63,8 @@ bool V8::Initialize(Deserializer* des) { // The current thread may not yet had entered an isolate to run. // Note the Isolate::Current() may be non-null because for various - // initialization purposes an initializing thread may be assigned an isolate - // but not actually enter it. + // initialization purposes an initializing thread may be assigned an + // isolate but not actually enter it. if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { i::Isolate::EnterDefaultIsolate(); } @@ -84,6 +84,15 @@ bool V8::Initialize(Deserializer* des) { void V8::TearDown() { + // The current thread may not yet had entered an isolate to run or may + // have already disposed the entered isolated before. + // Note the Isolate::Current() may be non-null because for various + // initialization purposes an initializing thread may be assigned an + // isolate but not actually enter it. + if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { + return; + } + Isolate* isolate = Isolate::Current(); ASSERT(isolate->IsDefaultIsolate()); if (!isolate->IsInitialized()) return; @@ -91,6 +100,7 @@ void V8::TearDown() { // The isolate has to be torn down before clearing the LOperand // caches so that the optimizing compiler thread (if running) // doesn't see an inconsistent view of the lithium instructions. + Isolate::SetIsolateThreadLocals(isolate, NULL); isolate->TearDown(); delete isolate; -- 2.7.4