Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1485)

Unified Diff: src/v8threads.cc

Issue 6788023: Per-isolate v8::Locker and v8::Unlocker (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixing order of Entering/Exiting and Restoring/Archiving thread Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/test-lockers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
+ }
}
« no previous file with comments | « no previous file | test/cctest/test-lockers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698