Also, add a check for debug mode.
BUG=none
R=dcarney@chromium.org
LOG=n
Review URL: https://codereview.chromium.org/
758043002
Cr-Commit-Position: refs/heads/master@{#25507}
/**
* Returns the entered isolate for the current thread or NULL in
* case there is no current isolate.
+ *
+ * This method must not be invoked before V8::Initialize() was invoked.
*/
static Isolate* GetCurrent();
base::LazyMutex Isolate::thread_data_table_mutex_ = LAZY_MUTEX_INITIALIZER;
Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL;
base::Atomic32 Isolate::isolate_counter_ = 0;
+#if DEBUG
+base::Atomic32 Isolate::isolate_key_created_ = 0;
+#endif
Isolate::PerIsolateThreadData*
Isolate::FindOrAllocatePerThreadDataForThisThread() {
base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer());
CHECK(thread_data_table_ == NULL);
isolate_key_ = base::Thread::CreateThreadLocalKey();
+#if DEBUG
+ base::NoBarrier_Store(&isolate_key_created_, 1);
+#endif
thread_id_key_ = base::Thread::CreateThreadLocalKey();
per_isolate_thread_data_key_ = base::Thread::CreateThreadLocalKey();
thread_data_table_ = new Isolate::ThreadDataTable();
// Returns the isolate inside which the current thread is running.
INLINE(static Isolate* Current()) {
+ DCHECK(base::NoBarrier_Load(&isolate_key_created_) == 1);
Isolate* isolate = reinterpret_cast<Isolate*>(
base::Thread::GetExistingThreadLocal(isolate_key_));
DCHECK(isolate != NULL);
}
INLINE(static Isolate* UncheckedCurrent()) {
+ DCHECK(base::NoBarrier_Load(&isolate_key_created_) == 1);
return reinterpret_cast<Isolate*>(
base::Thread::GetThreadLocal(isolate_key_));
}
// A global counter for all generated Isolates, might overflow.
static base::Atomic32 isolate_counter_;
+#if DEBUG
+ static base::Atomic32 isolate_key_created_;
+#endif
+
void Deinit();
static void SetIsolateThreadLocals(Isolate* isolate,