Index: src/v8threads.cc |
diff --git a/src/v8threads.cc b/src/v8threads.cc |
index e2879748029785c0ec5fa196356cceccbbc11cc6..05a5a59e573b81fbab802f9e1475b841efd6cacc 100644 |
--- a/src/v8threads.cc |
+++ b/src/v8threads.cc |
@@ -61,10 +61,7 @@ Locker::Locker(v8::Isolate* isolate) |
// Make sure that V8 is initialized. Archiving of threads interferes |
// with deserialization by adding additional root pointers, so we must |
// initialize here, before anyone can call ~Locker() or Unlocker(). |
- if (isolate_->IsDefaultIsolate()) { |
- // This only enters if not yet entered. |
- internal::Isolate::EnterDefaultIsolate(); |
- } else if (!isolate_->IsInitialized()) { |
+ if (!isolate_->IsInitialized()) { |
isolate_->Enter(); |
V8::Initialize(); |
isolate_->Exit(); |
@@ -79,6 +76,10 @@ Locker::Locker(v8::Isolate* isolate) |
isolate_->stack_guard()->ClearThread(access); |
isolate_->stack_guard()->InitThread(access); |
} |
+ if (isolate_->IsDefaultIsolate()) { |
+ // This only enters if not yet entered. |
+ internal::Isolate::EnterDefaultIsolate(); |
+ } |
} |
ASSERT(isolate_->thread_manager()->IsLockedByCurrentThread()); |
} |
@@ -96,6 +97,9 @@ bool Locker::IsLocked(v8::Isolate* isolate) { |
Locker::~Locker() { |
ASSERT(isolate_->thread_manager()->IsLockedByCurrentThread()); |
if (has_lock_) { |
+ if (isolate_->IsDefaultIsolate()) { |
+ isolate_->Exit(); |
+ } |
if (top_level_) { |
isolate_->thread_manager()->FreeThreadResources(); |
} else { |
@@ -111,8 +115,10 @@ Unlocker::Unlocker(v8::Isolate* isolate) |
if (isolate_ == NULL) { |
isolate_ = i::Isolate::GetDefaultIsolateForLocking(); |
} |
- |
ASSERT(isolate_->thread_manager()->IsLockedByCurrentThread()); |
+ if (isolate_->IsDefaultIsolate()) { |
+ isolate_->Exit(); |
+ } |
isolate_->thread_manager()->ArchiveThread(); |
isolate_->thread_manager()->Unlock(); |
} |
@@ -122,6 +128,9 @@ Unlocker::~Unlocker() { |
ASSERT(!isolate_->thread_manager()->IsLockedByCurrentThread()); |
isolate_->thread_manager()->Lock(); |
isolate_->thread_manager()->RestoreThread(); |
+ if (isolate_->IsDefaultIsolate()) { |
+ isolate_->Enter(); |
Vitaly Repeshko
2011/05/03 16:41:18
Weird indent.
|
+ } |
} |