| Index: src/isolate.cc | 
| diff --git a/src/isolate.cc b/src/isolate.cc | 
| index e96044532115b42e71c674384537a634f0eb377e..66733cb67514c5012a79c022875145f86e3f261b 100644 | 
| --- a/src/isolate.cc | 
| +++ b/src/isolate.cc | 
| @@ -48,6 +48,7 @@ int ThreadId::AllocateThreadId() { | 
|  | 
|  | 
| int ThreadId::GetCurrentThreadId() { | 
| +  Isolate::EnsureInitialized(); | 
| int thread_id = base::Thread::GetThreadLocalInt(Isolate::thread_id_key_); | 
| if (thread_id == 0) { | 
| thread_id = AllocateThreadId(); | 
| @@ -113,16 +114,17 @@ base::Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; | 
| #ifdef DEBUG | 
| base::Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; | 
| #endif  // DEBUG | 
| -base::LazyMutex Isolate::thread_data_table_mutex_ = LAZY_MUTEX_INITIALIZER; | 
| +base::LazyMutex Isolate::process_wide_mutex_ = LAZY_MUTEX_INITIALIZER; | 
| Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL; | 
| base::Atomic32 Isolate::isolate_counter_ = 0; | 
|  | 
| Isolate::PerIsolateThreadData* | 
| Isolate::FindOrAllocatePerThreadDataForThisThread() { | 
| +  EnsureInitialized(); | 
| ThreadId thread_id = ThreadId::Current(); | 
| PerIsolateThreadData* per_thread = NULL; | 
| { | 
| -    base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); | 
| +    base::LockGuard<base::Mutex> lock_guard(process_wide_mutex_.Pointer()); | 
| per_thread = thread_data_table_->Lookup(this, thread_id); | 
| if (per_thread == NULL) { | 
| per_thread = new PerIsolateThreadData(this, thread_id); | 
| @@ -142,26 +144,28 @@ Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThisThread() { | 
|  | 
| Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThread( | 
| ThreadId thread_id) { | 
| +  EnsureInitialized(); | 
| PerIsolateThreadData* per_thread = NULL; | 
| { | 
| -    base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); | 
| +    base::LockGuard<base::Mutex> lock_guard(process_wide_mutex_.Pointer()); | 
| per_thread = thread_data_table_->Lookup(this, thread_id); | 
| } | 
| return per_thread; | 
| } | 
|  | 
|  | 
| -void Isolate::InitializeOncePerProcess() { | 
| -  base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); | 
| -  CHECK(thread_data_table_ == NULL); | 
| -  isolate_key_ = base::Thread::CreateThreadLocalKey(); | 
| -  thread_id_key_ = base::Thread::CreateThreadLocalKey(); | 
| -  per_isolate_thread_data_key_ = base::Thread::CreateThreadLocalKey(); | 
| +void Isolate::EnsureInitialized() { | 
| +  base::LockGuard<base::Mutex> lock_guard(process_wide_mutex_.Pointer()); | 
| +  if (thread_data_table_ == NULL) { | 
| +    isolate_key_ = base::Thread::CreateThreadLocalKey(); | 
| +    thread_id_key_ = base::Thread::CreateThreadLocalKey(); | 
| +    per_isolate_thread_data_key_ = base::Thread::CreateThreadLocalKey(); | 
| #ifdef DEBUG | 
| -  PerThreadAssertScopeBase::thread_local_key = | 
| -      base::Thread::CreateThreadLocalKey(); | 
| +    PerThreadAssertScopeBase::thread_local_key = | 
| +        base::Thread::CreateThreadLocalKey(); | 
| #endif  // DEBUG | 
| -  thread_data_table_ = new Isolate::ThreadDataTable(); | 
| +    thread_data_table_ = new Isolate::ThreadDataTable(); | 
| +  } | 
| } | 
|  | 
|  | 
| @@ -1517,10 +1521,6 @@ Isolate::Isolate() | 
| stress_deopt_count_(0), | 
| next_optimization_id_(0), | 
| use_counter_callback_(NULL) { | 
| -  { | 
| -    base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); | 
| -    CHECK(thread_data_table_); | 
| -  } | 
| id_ = base::NoBarrier_AtomicIncrement(&isolate_counter_, 1); | 
| TRACE_ISOLATE(constructor); | 
|  | 
| @@ -1571,7 +1571,7 @@ void Isolate::TearDown() { | 
| Deinit(); | 
|  | 
| { | 
| -    base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); | 
| +    base::LockGuard<base::Mutex> lock_guard(process_wide_mutex_.Pointer()); | 
| thread_data_table_->RemoveAllThreads(this); | 
| } | 
|  | 
| @@ -1676,6 +1676,7 @@ void Isolate::PushToPartialSnapshotCache(Object* obj) { | 
|  | 
| void Isolate::SetIsolateThreadLocals(Isolate* isolate, | 
| PerIsolateThreadData* data) { | 
| +  EnsureInitialized(); | 
| base::Thread::SetThreadLocal(isolate_key_, isolate); | 
| base::Thread::SetThreadLocal(per_isolate_thread_data_key_, data); | 
| } | 
|  |