Remove obsolete global V8::has_been_fooed flags.
authormstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 5 Sep 2013 18:53:39 +0000 (18:53 +0000)
committermstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 5 Sep 2013 18:53:39 +0000 (18:53 +0000)
R=yangguo@chromium.org
BUG=v8:2744
TEST=cctest/test-api/InitializeAndDispose

Review URL: https://codereview.chromium.org/23453030

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16563 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/v8.cc
src/v8.h
test/cctest/test-api.cc

index 9dea902..d9ce840 100644 (file)
--- a/src/v8.cc
+++ b/src/v8.cc
@@ -50,8 +50,6 @@ namespace internal {
 
 V8_DECLARE_ONCE(init_once);
 
-bool V8::has_been_set_up_ = false;
-bool V8::has_been_disposed_ = false;
 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL;
 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL;
 
@@ -81,9 +79,6 @@ bool V8::Initialize(Deserializer* des) {
   if (isolate->IsDead()) return false;
   if (isolate->IsInitialized()) return true;
 
-  has_been_set_up_ = true;
-  has_been_disposed_ = false;
-
   return isolate->Init(des);
 }
 
@@ -91,8 +86,7 @@ bool V8::Initialize(Deserializer* des) {
 void V8::TearDown() {
   Isolate* isolate = Isolate::Current();
   ASSERT(isolate->IsDefaultIsolate());
-
-  if (!has_been_set_up_ || has_been_disposed_) return;
+  if (!isolate->IsInitialized()) return;
 
   // The isolate has to be torn down before clearing the LOperand
   // caches so that the optimizing compiler thread (if running)
@@ -106,8 +100,6 @@ void V8::TearDown() {
   RegisteredExtension::UnregisterAll();
   Isolate::GlobalTearDown();
 
-  has_been_disposed_ = true;
-
   delete call_completed_callbacks_;
   call_completed_callbacks_ = NULL;
 
index 69f4df9..23277b3 100644 (file)
--- a/src/v8.h
+++ b/src/v8.h
@@ -122,11 +122,6 @@ class V8 : public AllStatic {
   static void InitializeOncePerProcessImpl();
   static void InitializeOncePerProcess();
 
-  // True if V8 has ever been run
-  static bool has_been_set_up_;
-  // True if engine has been shut down
-  // (reset if engine is restarted)
-  static bool has_been_disposed_;
   // List of callbacks when a Call completes.
   static List<CallCompletedCallback>* call_completed_callbacks_;
   // Allocator for external array buffers.
index e190b71..9f79a43 100644 (file)
@@ -166,6 +166,24 @@ static void SignatureCallback(
 }
 
 
+// Tests that call v8::V8::Dispose() cannot be threaded.
+TEST(InitializeAndDisposeOnce) {
+  CHECK(v8::V8::Initialize());
+  CHECK(v8::V8::Dispose());
+}
+
+
+// Tests that call v8::V8::Dispose() cannot be threaded.
+TEST(InitializeAndDisposeMultiple) {
+  for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose());
+  for (int i = 0; i < 3; ++i) CHECK(v8::V8::Initialize());
+  for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose());
+  // TODO(mstarzinger): This should fail gracefully instead of asserting.
+  // for (int i = 0; i < 3; ++i) CHECK(v8::V8::Initialize());
+  for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose());
+}
+
+
 THREADED_TEST(Handles) {
   v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<Context> local_env;