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

Unified Diff: src/isolate.cc

Issue 6788023: Per-isolate v8::Locker and v8::Unlocker (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: New tests for IsLocker 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
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index e42d78ecdcba94ca9355b69b201fdbbf0fcbe092..88ccf5a1210df4ed11540c2ebdeb44545c891118 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -310,6 +310,20 @@ Isolate::PerIsolateThreadData*
return per_thread;
}
Vitaly Repeshko 2011/04/15 00:29:39 nit: Two blank lines between functions.
Dmitry Lomov 2011/04/19 01:50:47 Done.
+Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThisThread() {
+ ThreadId thread_id = ThreadId::Current();
+ PerIsolateThreadData* per_thread = NULL;
+ {
+ ScopedLock lock(process_wide_mutex_);
+ per_thread = thread_data_table_->Lookup(this, thread_id);
+ }
+ return per_thread;
+}
+
+void Isolate::EnsurePreinitializedForThisThread() {
Vitaly Repeshko 2011/04/15 00:29:39 ForThisThread doesn't make much sense, since the i
Dmitry Lomov 2011/04/19 01:50:47 I just removed this.
+ ScopedLock lock(process_wide_mutex_);
Vitaly Repeshko 2011/04/15 00:29:39 I don't think we really need a process-wide mutex
+ CHECK(PreInit());
+}
void Isolate::EnsureDefaultIsolate() {
ScopedLock lock(process_wide_mutex_);
@@ -320,10 +334,12 @@ void Isolate::EnsureDefaultIsolate() {
thread_data_table_ = new Isolate::ThreadDataTable();
default_isolate_ = new Isolate();
}
+ CHECK(default_isolate_->PreInit());
// Can't use SetIsolateThreadLocals(default_isolate_, NULL) here
// becase a non-null thread data may be already set.
- Thread::SetThreadLocal(isolate_key_, default_isolate_);
- CHECK(default_isolate_->PreInit());
+ if (Thread::GetThreadLocal(isolate_key_) == NULL) {
+ Thread::SetThreadLocal(isolate_key_, default_isolate_);
+ }
}
@@ -640,8 +656,6 @@ bool Isolate::PreInit() {
TRACE_ISOLATE(preinit);
- ASSERT(Isolate::Current() == this);
Vitaly Repeshko 2011/04/15 00:29:39 Removing this is dangerous (at least for now), bec
Dmitry Lomov 2011/04/19 01:50:47 Done.
-
#ifdef ENABLE_DEBUGGER_SUPPORT
debug_ = new Debug(this);
debugger_ = new Debugger();
@@ -658,7 +672,7 @@ bool Isolate::PreInit() {
heap_.SetStackLimits();
#ifdef DEBUG
- DisallowAllocationFailure disallow_allocation_failure;
+ DisallowAllocationFailure disallow_allocation_failure(&heap_);
#endif
#define C(name) isolate_addresses_[Isolate::k_##name] = \
@@ -681,9 +695,8 @@ bool Isolate::PreInit() {
write_input_buffer_ = new StringInputBuffer();
global_handles_ = new GlobalHandles(this);
bootstrapper_ = new Bootstrapper();
- handle_scope_implementer_ = new HandleScopeImplementer();
+ handle_scope_implementer_ = new HandleScopeImplementer(this);
stub_cache_ = new StubCache(this);
- ast_sentinels_ = new AstSentinels();
regexp_stack_ = new RegExpStack();
regexp_stack_->isolate_ = this;
@@ -698,6 +711,7 @@ bool Isolate::PreInit() {
void Isolate::InitializeThreadLocal() {
+ thread_local_top_.isolate_ = this;
thread_local_top_.Initialize();
clear_pending_exception();
clear_pending_message();
@@ -741,11 +755,14 @@ bool Isolate::Init(Deserializer* des) {
#ifdef DEBUG
// The initialization process does not handle memory exhaustion.
- DisallowAllocationFailure disallow_allocation_failure;
+ DisallowAllocationFailure disallow_allocation_failure(&heap_);
#endif
if (state_ == UNINITIALIZED && !PreInit()) return false;
+ // AstSentinels initialization requires Isolate::Current to be set
+ ast_sentinels_ = new AstSentinels();
+
// Enable logging before setting up the heap
logger_->Setup();

Powered by Google App Engine
This is Rietveld 408576698