Revision: 21167
Author:   [email protected]
Date:     Tue May  6 11:48:26 2014 UTC
Log:      Removed default Isolate.

There is probably room for more cleanup after this...

BUG=359977
LOG=y
[email protected]

Review URL: https://codereview.chromium.org/262163006
http://code.google.com/p/v8/source/detail?r=21167

Modified:
 /branches/bleeding_edge/src/api.cc
 /branches/bleeding_edge/src/d8.cc
 /branches/bleeding_edge/src/isolate.cc
 /branches/bleeding_edge/src/isolate.h
 /branches/bleeding_edge/src/log.cc
 /branches/bleeding_edge/src/mksnapshot.cc
 /branches/bleeding_edge/src/v8.cc
 /branches/bleeding_edge/test/cctest/cctest.cc
 /branches/bleeding_edge/test/cctest/test-api.cc
 /branches/bleeding_edge/test/cctest/test-microtask-delivery.cc

=======================================
--- /branches/bleeding_edge/src/api.cc  Mon May  5 16:33:23 2014 UTC
+++ /branches/bleeding_edge/src/api.cc  Tue May  6 11:48:26 2014 UTC
@@ -4958,12 +4958,6 @@


 bool v8::V8::Dispose() {
-  i::Isolate* isolate = i::Isolate::Current();
-  if (!Utils::ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(),
-                       "v8::V8::Dispose()",
- "Use v8::Isolate::Dispose() for non-default isolate.")) {
-    return false;
-  }
   i::V8::TearDown();
   return true;
 }
=======================================
--- /branches/bleeding_edge/src/d8.cc   Tue Apr 29 06:42:26 2014 UTC
+++ /branches/bleeding_edge/src/d8.cc   Tue May  6 11:48:26 2014 UTC
@@ -1659,7 +1659,7 @@
     v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
   }
   int result = 0;
-  Isolate* isolate = Isolate::GetCurrent();
+  Isolate* isolate = Isolate::New();
 #ifndef V8_SHARED
   v8::ResourceConstraints constraints;
   constraints.ConfigureDefaults(i::OS::TotalPhysicalMemory(),
@@ -1669,6 +1669,7 @@
 #endif
   DumbLineEditor dumb_line_editor(isolate);
   {
+    Isolate::Scope scope(isolate);
     Initialize(isolate);
 #ifdef ENABLE_VTUNE_JIT_INTERFACE
     vTune::InitializeVtuneForV8();
=======================================
--- /branches/bleeding_edge/src/isolate.cc      Tue May  6 11:25:37 2014 UTC
+++ /branches/bleeding_edge/src/isolate.cc      Tue May  6 11:48:26 2014 UTC
@@ -103,7 +103,6 @@
 }


-Isolate* Isolate::default_isolate_ = NULL;
 Thread::LocalStorageKey Isolate::isolate_key_;
 Thread::LocalStorageKey Isolate::thread_id_key_;
 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_;
@@ -166,7 +165,7 @@
 void Isolate::EnsureDefaultIsolate() {
   LockGuard<Mutex> lock_guard(&process_wide_mutex_);
   CHECK(default_isolate_status_ != kDefaultIsolateCrashIfInitialized);
-  if (default_isolate_ == NULL) {
+  if (thread_data_table_ == NULL) {
     isolate_key_ = Thread::CreateThreadLocalKey();
     thread_id_key_ = Thread::CreateThreadLocalKey();
     per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey();
@@ -174,12 +173,6 @@
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_);
   }
 }

@@ -1523,9 +1516,7 @@
     serialize_partial_snapshot_cache_ = NULL;
   }

-  if (!IsDefaultIsolate()) {
-    delete this;
-  }
+  delete this;

   // Restore the previous current isolate.
   SetIsolateThreadLocals(saved_isolate, saved_data);
=======================================
--- /branches/bleeding_edge/src/isolate.h       Tue May  6 11:25:37 2014 UTC
+++ /branches/bleeding_edge/src/isolate.h       Tue May  6 11:48:26 2014 UTC
@@ -477,8 +477,6 @@
   void TearDown();

   static void GlobalTearDown();
-
-  bool IsDefaultIsolate() const { return this == default_isolate_; }

   static void SetCrashIfDefaultIsolateInitialized();
   // Ensures that process-wide resources and the default isolate have been
@@ -1134,14 +1132,12 @@
     DISALLOW_COPY_AND_ASSIGN(EntryStackItem);
   };

-  // This mutex protects highest_thread_id_, thread_data_table_ and
-  // default_isolate_.
+  // This mutex protects highest_thread_id_ and thread_data_table_.
   static Mutex process_wide_mutex_;

   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.
=======================================
--- /branches/bleeding_edge/src/log.cc  Tue May  6 09:28:08 2014 UTC
+++ /branches/bleeding_edge/src/log.cc  Tue May  6 11:48:26 2014 UTC
@@ -1936,58 +1936,48 @@


 static void AddIsolateIdIfNeeded(Isolate* isolate, StringStream* stream) {
-  if (isolate->IsDefaultIsolate() || !FLAG_logfile_per_isolate) return;
-  stream->Add("isolate-%p-", isolate);
+  if (FLAG_logfile_per_isolate) stream->Add("isolate-%p-", isolate);
 }


 static SmartArrayPointer<const char> PrepareLogFileName(
     Isolate* isolate, const char* file_name) {
-  if (strchr(file_name, '%') != NULL || !isolate->IsDefaultIsolate()) {
-    // If there's a '%' in the log file name we have to expand
-    // placeholders.
-    HeapStringAllocator allocator;
-    StringStream stream(&allocator);
-    AddIsolateIdIfNeeded(isolate, &stream);
-    for (const char* p = file_name; *p; p++) {
-      if (*p == '%') {
-        p++;
-        switch (*p) {
-          case '\0':
-            // If there's a % at the end of the string we back up
-            // one character so we can escape the loop properly.
-            p--;
-            break;
-          case 'p':
-            stream.Add("%d", OS::GetCurrentProcessId());
-            break;
-          case 't': {
-            // %t expands to the current time in milliseconds.
-            double time = OS::TimeCurrentMillis();
-            stream.Add("%.0f", FmtElm(time));
-            break;
-          }
-          case '%':
-            // %% expands (contracts really) to %.
-            stream.Put('%');
-            break;
-          default:
-            // All other %'s expand to themselves.
-            stream.Put('%');
-            stream.Put(*p);
-            break;
+  HeapStringAllocator allocator;
+  StringStream stream(&allocator);
+  AddIsolateIdIfNeeded(isolate, &stream);
+  for (const char* p = file_name; *p; p++) {
+    if (*p == '%') {
+      p++;
+      switch (*p) {
+        case '\0':
+          // If there's a % at the end of the string we back up
+          // one character so we can escape the loop properly.
+          p--;
+          break;
+        case 'p':
+          stream.Add("%d", OS::GetCurrentProcessId());
+          break;
+        case 't': {
+          // %t expands to the current time in milliseconds.
+          double time = OS::TimeCurrentMillis();
+          stream.Add("%.0f", FmtElm(time));
+          break;
         }
-      } else {
-        stream.Put(*p);
+        case '%':
+          // %% expands (contracts really) to %.
+          stream.Put('%');
+          break;
+        default:
+          // All other %'s expand to themselves.
+          stream.Put('%');
+          stream.Put(*p);
+          break;
       }
+    } else {
+      stream.Put(*p);
     }
-    return SmartArrayPointer<const char>(stream.ToCString());
   }
-  int length = StrLength(file_name);
-  char* str = NewArray<char>(length + 1);
-  OS::MemCopy(str, file_name, length);
-  str[length] = '\0';
-  return SmartArrayPointer<const char>(str);
+  return SmartArrayPointer<const char>(stream.ToCString());
 }


=======================================
--- /branches/bleeding_edge/src/mksnapshot.cc   Tue Apr 29 06:42:26 2014 UTC
+++ /branches/bleeding_edge/src/mksnapshot.cc   Tue May  6 11:48:26 2014 UTC
@@ -393,6 +393,10 @@

   isolate->Exit();
   isolate->Dispose();
-  V8::Dispose();
+  // TODO(svenpanne) Alas, we can't cleanly dispose V8 here, because
+ // Serializer::code_address_map_ is static (a.k.a. a global variable), and
+  // disposing that would involve accessing the Isolate just disposed.
+  // code_address_map_ really has to be an instance variable...
+  // V8::Dispose();
   return 0;
 }
=======================================
--- /branches/bleeding_edge/src/v8.cc   Tue May  6 11:14:37 2014 UTC
+++ /branches/bleeding_edge/src/v8.cc   Tue May  6 11:48:26 2014 UTC
@@ -53,16 +53,6 @@


 void V8::TearDown() {
-  Isolate* isolate = Isolate::Current();
-  ASSERT(isolate->IsDefaultIsolate());
-  if (!isolate->IsInitialized()) return;
-
-  // 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.
-  isolate->TearDown();
-  delete isolate;
-
   Bootstrapper::TearDownExtensions();
   ElementsAccessor::TearDown();
   LOperand::TearDownCaches();
=======================================
--- /branches/bleeding_edge/test/cctest/cctest.cc Tue Apr 22 10:45:43 2014 UTC +++ /branches/bleeding_edge/test/cctest/cctest.cc Tue May 6 11:48:26 2014 UTC
@@ -152,6 +152,7 @@
   i::TraceExtension trace_extension;
   v8::RegisterExtension(&trace_extension);

+  v8::V8::Initialize();
   int tests_run = 0;
   bool print_run_count = true;
   for (int i = 1; i < argc; i++) {
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Mon May 5 18:27:57 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-api.cc Tue May 6 11:48:26 2014 UTC
@@ -19269,7 +19269,6 @@
   v8::Isolate* current_isolate = CcTest::isolate();
   v8::Isolate* isolate = v8::Isolate::New();
   CHECK(isolate != NULL);
-  CHECK(!reinterpret_cast<i::Isolate*>(isolate)->IsDefaultIsolate());
   CHECK(current_isolate != isolate);
   CHECK(current_isolate == CcTest::isolate());

@@ -22339,6 +22338,7 @@

 TEST(Promises) {
   i::FLAG_harmony_promises = true;
+  i::FLAG_harmony_weak_collections = true;  // Implied

   LocalContext context;
   v8::Isolate* isolate = context->GetIsolate();
=======================================
--- /branches/bleeding_edge/test/cctest/test-microtask-delivery.cc Fri May 2 19:30:54 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-microtask-delivery.cc Tue May 6 11:48:26 2014 UTC
@@ -37,6 +37,7 @@
  public:
   HarmonyIsolate() {
     i::FLAG_harmony_promises = true;
+    i::FLAG_harmony_weak_collections = true;  // Implied
     isolate_ = Isolate::New();
     isolate_->Enter();
   }

--
--
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/d/optout.

Reply via email to