Revision: 17066
Author: [email protected]
Date: Wed Oct 2 09:01:40 2013 UTC
Log: Revert "lazy instantiation of the default isolate" and "build fix
for 17049".
This reverts r17049 and r17060.
[email protected]
Review URL: https://codereview.chromium.org/25697002
http://code.google.com/p/v8/source/detail?r=17066
Modified:
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/isolate.cc
/branches/bleeding_edge/src/isolate.h
/branches/bleeding_edge/src/v8.cc
/branches/bleeding_edge/src/v8.h
=======================================
--- /branches/bleeding_edge/src/api.cc Wed Oct 2 07:55:52 2013 UTC
+++ /branches/bleeding_edge/src/api.cc Wed Oct 2 09:01:40 2013 UTC
@@ -5007,13 +5007,14 @@
bool v8::V8::Dispose() {
- i::Isolate* isolate = i::Isolate::UncheckedCurrent();
- if (!ApiCheck(isolate == NULL || isolate->IsDefaultIsolate(),
+ i::Isolate* isolate = i::Isolate::Current();
+ if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(),
"v8::V8::Dispose()",
"Use v8::Isolate::Dispose() for a non-default isolate.")) {
return false;
}
- return i::V8::TearDown();
+ i::V8::TearDown();
+ return true;
}
@@ -6487,10 +6488,6 @@
Isolate* Isolate::GetCurrent() {
i::Isolate* isolate = i::Isolate::UncheckedCurrent();
- if (isolate == NULL) {
- isolate = i::Isolate::EnsureDefaultIsolate(true);
- ASSERT(isolate == i::Isolate::UncheckedCurrent());
- }
return reinterpret_cast<Isolate*>(isolate);
}
=======================================
--- /branches/bleeding_edge/src/isolate.cc Wed Oct 2 07:55:52 2013 UTC
+++ /branches/bleeding_edge/src/isolate.cc Wed Oct 2 09:01:40 2013 UTC
@@ -330,6 +330,7 @@
storage->LinkTo(&free_list_);
}
+Isolate* Isolate::default_isolate_ = NULL;
Thread::LocalStorageKey Isolate::isolate_key_;
Thread::LocalStorageKey Isolate::thread_id_key_;
Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_;
@@ -347,7 +348,6 @@
= kDefaultIsolateUninitialized;
Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL;
Atomic32 Isolate::isolate_counter_ = 0;
-Atomic32 Isolate::living_isolates_ = 0;
Isolate::PerIsolateThreadData*
Isolate::FindOrAllocatePerThreadDataForThisThread() {
@@ -390,75 +390,61 @@
}
-Isolate* Isolate::EnsureDefaultIsolate(bool must_be_null) {
- static Isolate* default_isolate_ = NULL;
+void Isolate::EnsureDefaultIsolate() {
LockGuard<Mutex> lock_guard(&process_wide_mutex_);
CHECK(default_isolate_status_ != kDefaultIsolateCrashIfInitialized);
- if (must_be_null) {
- CHECK(default_isolate_ == NULL);
- }
if (default_isolate_ == NULL) {
- default_isolate_ = new Isolate(true);
+ isolate_key_ = Thread::CreateThreadLocalKey();
+ thread_id_key_ = Thread::CreateThreadLocalKey();
+ per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey();
+#ifdef DEBUG
+ PerThreadAssertScopeBase::thread_local_key =
Thread::CreateThreadLocalKey();
+#endif // DEBUG
+ thread_data_table_ = new Isolate::ThreadDataTable();
+ default_isolate_ = new Isolate();
}
// Can't use SetIsolateThreadLocals(default_isolate_, NULL) here
// because a non-null thread data may be already set.
if (Thread::GetThreadLocal(isolate_key_) == NULL) {
Thread::SetThreadLocal(isolate_key_, default_isolate_);
}
-
- return default_isolate_;
}
-
-void Isolate::InitializeThreadLocalStorage() {
- // Double checked locking on existence of thread_data_table_.
- if (thread_data_table_ != NULL) return;
- LockGuard<Mutex> lock_guard(&process_wide_mutex_);
- if (thread_data_table_ != NULL) return;
- isolate_key_ = Thread::CreateThreadLocalKey();
- thread_id_key_ = Thread::CreateThreadLocalKey();
- per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey();
-#ifdef DEBUG
- PerThreadAssertScopeBase::thread_local_key =
Thread::CreateThreadLocalKey();
-#endif // DEBUG
- thread_data_table_ = new Isolate::ThreadDataTable();
- CHECK(thread_data_table_ != NULL);
-}
-
-
-// TODO(dcarney): Remove this with default_isolate_ and Isolate::Current.
struct StaticInitializer {
StaticInitializer() {
- Isolate::InitializeThreadLocalStorage();
+ Isolate::EnsureDefaultIsolate();
}
} static_initializer;
#ifdef ENABLE_DEBUGGER_SUPPORT
Debugger* Isolate::GetDefaultIsolateDebugger() {
- return EnsureDefaultIsolate()->debugger();
+ EnsureDefaultIsolate();
+ return default_isolate_->debugger();
}
#endif
StackGuard* Isolate::GetDefaultIsolateStackGuard() {
- return EnsureDefaultIsolate()->stack_guard();
+ EnsureDefaultIsolate();
+ return default_isolate_->stack_guard();
}
void Isolate::EnterDefaultIsolate() {
- Isolate* default_isolate = EnsureDefaultIsolate();
- ASSERT(default_isolate != NULL);
+ EnsureDefaultIsolate();
+ ASSERT(default_isolate_ != NULL);
PerIsolateThreadData* data = CurrentPerIsolateThreadData();
// If not yet in default isolate - enter it.
- if (data == NULL || data->isolate() != default_isolate) {
- default_isolate->Enter();
+ if (data == NULL || data->isolate() != default_isolate_) {
+ default_isolate_->Enter();
}
}
v8::Isolate* Isolate::GetDefaultIsolateForLocking() {
- return reinterpret_cast<v8::Isolate*>(EnsureDefaultIsolate());
+ EnsureDefaultIsolate();
+ return reinterpret_cast<v8::Isolate*>(default_isolate_);
}
@@ -1748,7 +1734,7 @@
#endif
-Isolate::Isolate(bool is_default_isolate)
+Isolate::Isolate()
: state_(UNINITIALIZED),
embedder_data_(NULL),
entry_stack_(NULL),
@@ -1798,7 +1784,6 @@
has_fatal_error_(false),
use_crankshaft_(true),
initialized_from_snapshot_(false),
- is_default_isolate_(is_default_isolate),
cpu_profiler_(NULL),
heap_profiler_(NULL),
function_entry_hook_(NULL),
@@ -1806,10 +1791,7 @@
optimizing_compiler_thread_(NULL),
sweeper_thread_(NULL),
stress_deopt_count_(0) {
- InitializeThreadLocalStorage();
-
id_ = NoBarrier_AtomicIncrement(&isolate_counter_, 1);
- NoBarrier_AtomicIncrement(&living_isolates_, 1);
TRACE_ISOLATE(constructor);
memset(isolate_addresses_, 0,
@@ -1992,7 +1974,7 @@
// The entry stack must be empty when we get here,
// except for the default isolate, where it can
// still contain up to one entry stack item
- ASSERT(entry_stack_ == NULL || is_default_isolate_);
+ ASSERT(entry_stack_ == NULL || this == default_isolate_);
ASSERT(entry_stack_ == NULL || entry_stack_->previous_item == NULL);
delete entry_stack_;
@@ -2077,8 +2059,6 @@
delete debug_;
debug_ = NULL;
#endif
-
- NoBarrier_AtomicIncrement(&living_isolates_, -1);
}
=======================================
--- /branches/bleeding_edge/src/isolate.h Wed Oct 2 08:29:34 2013 UTC
+++ /branches/bleeding_edge/src/isolate.h Wed Oct 2 09:01:40 2013 UTC
@@ -491,17 +491,14 @@
static void GlobalTearDown();
- bool IsDefaultIsolate() const { return is_default_isolate_; }
+ bool IsDefaultIsolate() const { return this == default_isolate_; }
static void SetCrashIfDefaultIsolateInitialized();
// Ensures that process-wide resources and the default isolate have been
// allocated. It is only necessary to call this method in rare cases, for
// example if you are using V8 from within the body of a static
initializer.
// Safe to call multiple times.
- static Isolate* EnsureDefaultIsolate(bool must_be_null = false);
-
- // Initialize all thread local variables
- static void InitializeThreadLocalStorage();
+ static void EnsureDefaultIsolate();
// Find the PerThread for this particular (isolate, thread) combination
// If one does not yet exist, return null.
@@ -1140,12 +1137,8 @@
// Given an address occupied by a live code object, return that object.
Object* FindCodeObject(Address a);
- static Atomic32 GetLivingIsolates() {
- return Acquire_Load(&living_isolates_);
- }
-
private:
- explicit Isolate(bool is_default_isolate = false);
+ Isolate();
friend struct GlobalState;
friend struct InitializeGlobalState;
@@ -1210,11 +1203,11 @@
static Thread::LocalStorageKey per_isolate_thread_data_key_;
static Thread::LocalStorageKey isolate_key_;
static Thread::LocalStorageKey thread_id_key_;
+ static Isolate* default_isolate_;
static ThreadDataTable* thread_data_table_;
// A global counter for all generated Isolates, might overflow.
static Atomic32 isolate_counter_;
- static Atomic32 living_isolates_;
void Deinit();
@@ -1326,9 +1319,6 @@
// True if this isolate was initialized from a snapshot.
bool initialized_from_snapshot_;
- // True only for the default isolate.
- bool is_default_isolate_;
-
// Time stamp at initialization.
double time_millis_at_init_;
=======================================
--- /branches/bleeding_edge/src/v8.cc Tue Oct 1 14:26:53 2013 UTC
+++ /branches/bleeding_edge/src/v8.cc Wed Oct 2 09:01:40 2013 UTC
@@ -79,24 +79,16 @@
}
-bool V8::TearDown() {
- Isolate* isolate = Isolate::UncheckedCurrent();
- if (isolate != NULL) {
- ASSERT(isolate->IsDefaultIsolate());
- if (isolate->IsInitialized()) isolate->TearDown();
- delete isolate;
- }
+void V8::TearDown() {
+ Isolate* isolate = Isolate::Current();
+ ASSERT(isolate->IsDefaultIsolate());
+ if (!isolate->IsInitialized()) return;
- // V8 was never initialized, nothing to do.
- if (Acquire_Load(&init_once) == ONCE_STATE_UNINITIALIZED) return true;
-
- // TODO(dcarney): Everything below this should be in some sort of
mutex...
- Atomic32 living_isolates = Isolate::GetLivingIsolates();
-
- // All isolates have to be torn down before clearing the LOperand
+ // The isolate has to be torn down before clearing the LOperand
// caches so that the optimizing compiler thread (if running)
// doesn't see an inconsistent view of the lithium instructions.
- if (living_isolates != 0) return false;
+ isolate->TearDown();
+ delete isolate;
ElementsAccessor::TearDown();
LOperand::TearDownCaches();
@@ -108,7 +100,6 @@
call_completed_callbacks_ = NULL;
Sampler::TearDown();
- return true;
}
=======================================
--- /branches/bleeding_edge/src/v8.h Tue Oct 1 14:26:53 2013 UTC
+++ /branches/bleeding_edge/src/v8.h Wed Oct 2 09:01:40 2013 UTC
@@ -81,7 +81,7 @@
// initial state is created by reading the deserialized data into an
// empty heap.
static bool Initialize(Deserializer* des);
- static bool TearDown();
+ static void TearDown();
// Report process out of memory. Implementation found in api.cc.
static void FatalProcessOutOfMemory(const char* location,
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.