build fix for 17049
authordcarney@chromium.org <dcarney@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 2 Oct 2013 07:55:52 +0000 (07:55 +0000)
committerdcarney@chromium.org <dcarney@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 2 Oct 2013 07:55:52 +0000 (07:55 +0000)
instantiate default isolate on v8::Isolate::GetCurrent()

TBR=mstarzinger@chromium.org
BUG=

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

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

src/api.cc
src/isolate.cc
src/isolate.h

index 4d221bf..734a7e9 100644 (file)
@@ -6487,6 +6487,10 @@ void V8::CancelTerminateExecution(Isolate* isolate) {
 
 Isolate* Isolate::GetCurrent() {
   i::Isolate* isolate = i::Isolate::UncheckedCurrent();
+  if (isolate == NULL) {
+    isolate = i::Isolate::EnsureDefaultIsolate(true);
+    ASSERT(isolate == i::Isolate::UncheckedCurrent());
+  }
   return reinterpret_cast<Isolate*>(isolate);
 }
 
index 7e0c36a..f86d5dc 100644 (file)
@@ -390,10 +390,13 @@ void Isolate::SetCrashIfDefaultIsolateInitialized() {
 }
 
 
-Isolate* Isolate::EnsureDefaultIsolate() {
+Isolate* Isolate::EnsureDefaultIsolate(bool must_be_null) {
   static Isolate* default_isolate_ = NULL;
   LockGuard<Mutex> lock_guard(&process_wide_mutex_);
   CHECK(default_isolate_status_ != kDefaultIsolateCrashIfInitialized);
+  if (must_be_null) {
+    CHECK(default_isolate_ == NULL);
+  }
   if (default_isolate_ == NULL) {
     default_isolate_ = new Isolate(true);
   }
index 54d313f..bc38fbf 100644 (file)
@@ -498,7 +498,7 @@ class Isolate {
   // allocated. It is only necessary to call this method in rare cases, for
   // example if you are using V8 from within the body of a static initializer.
   // Safe to call multiple times.
-  static Isolate* EnsureDefaultIsolate();
+  static Isolate* EnsureDefaultIsolate(bool must_be_null = false);
 
   // Initialize all thread local variables
   static void InitializeThreadLocalStorage();