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
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);
}
}
-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);
}
// 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();