Reviewers: jochen,

Description:
Simplify v8/Isolate teardown.

This implies that one better has a v8::V8::Initialize when v8::V8::Dispose is
used.


BUG=359977
LOG=y

Please review this at https://codereview.chromium.org/238353015/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+19, -22 lines):
  M samples/lineprocessor.cc
  M samples/process.cc
  M samples/shell.cc
  M src/api.cc
  M src/arm/assembler-arm.cc
  M src/d8.cc
  M src/isolate.cc
  M src/mips/assembler-mips.cc
  M src/mksnapshot.cc
  M src/v8.cc
  M test/cctest/cctest.cc
  M test/cctest/test-api.cc
  M test/cctest/test-microtask-delivery.cc
  M tools/lexer-shell.cc
  M tools/parser-shell.cc


Index: samples/lineprocessor.cc
diff --git a/samples/lineprocessor.cc b/samples/lineprocessor.cc
index a8ad0318d88efa151ca1a88c81817ea0d8f02732..16cfb1f2596e903bde5d2ec4008401d69ea11a3c 100644
--- a/samples/lineprocessor.cc
+++ b/samples/lineprocessor.cc
@@ -328,6 +328,7 @@ bool RunCppCycle(v8::Handle<v8::Script> script,

 int main(int argc, char* argv[]) {
   v8::V8::InitializeICU();
+  v8::V8::Initialize();
   int result = RunMain(argc, argv);
   v8::V8::Dispose();
   return result;
Index: samples/process.cc
diff --git a/samples/process.cc b/samples/process.cc
index 37b4d3920897b1a613d8fb8a6d7e10568a11e07a..1a88226ad75b792f9bcdd4ee96e6d57ab0885bdb 100644
--- a/samples/process.cc
+++ b/samples/process.cc
@@ -644,6 +644,7 @@ void PrintMap(map<string, string>* m) {

 int main(int argc, char* argv[]) {
   v8::V8::InitializeICU();
+  v8::V8::Initialize();
   map<string, string> options;
   string file;
   ParseOptions(argc, argv, options, &file);
Index: samples/shell.cc
diff --git a/samples/shell.cc b/samples/shell.cc
index f8d2c84594bde007892b8bc4b657a3b343f731b4..ea49d7ef2d255ead91a096dc75d48c07e53a53e2 100644
--- a/samples/shell.cc
+++ b/samples/shell.cc
@@ -67,6 +67,7 @@ static bool run_shell;

 int main(int argc, char* argv[]) {
   v8::V8::InitializeICU();
+  v8::V8::Initialize();
   v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
   run_shell = (argc == 1);
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 00e90d859a649e95873956a0cadda54cf3049497..3f41646e998a51ed6de0e30e381ebd94c5be1eeb 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -4995,12 +4995,6 @@ void v8::V8::SetArrayBufferAllocator(


 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;
 }
Index: src/arm/assembler-arm.cc
diff --git a/src/arm/assembler-arm.cc b/src/arm/assembler-arm.cc
index a3231e2c89a22013d6b377a79ef79b6303a6f773..a44627f588266edf6fc85c225bdb172d6ee2f83d 100644
--- a/src/arm/assembler-arm.cc
+++ b/src/arm/assembler-arm.cc
@@ -103,7 +103,8 @@ const char* DwVfpRegister::AllocationIndexToString(int index) {
 void CpuFeatures::Probe() {
   uint64_t standard_features = static_cast<unsigned>(
       OS::CpuFeaturesImpliedByPlatform()) | CpuFeaturesImpliedByCompiler();
-  ASSERT(supported_ == 0 || supported_ == standard_features);
+  ASSERT(supported_ == 0 ||
+         (supported_ & standard_features) == standard_features);
 #ifdef DEBUG
   initialized_ = true;
 #endif
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 4e14cd5b0aa65f1607f3b2a9491f3970a4e95095..675ef5b8cf96738db7adb25052c04de5d204c18d 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1678,6 +1678,7 @@ class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
 int Shell::Main(int argc, char* argv[]) {
   if (!SetOptions(argc, argv)) return 1;
   v8::V8::InitializeICU(options.icu_data_file);
+  v8::V8::Initialize();
 #ifndef V8_SHARED
   i::FLAG_trace_hydrogen_file = "hydrogen.cfg";
   i::FLAG_redirect_code_traces_to = "code.asm";
@@ -1692,7 +1693,7 @@ int Shell::Main(int argc, char* argv[]) {
     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(),
@@ -1703,6 +1704,7 @@ int Shell::Main(int argc, char* argv[]) {
   DumbLineEditor dumb_line_editor(isolate);
   {
     Initialize(isolate);
+    Isolate::Scope isolate_scope(isolate);
 #ifdef ENABLE_VTUNE_JIT_INTERFACE
     vTune::InitializeVtuneForV8();
 #endif
@@ -1765,6 +1767,7 @@ int Shell::Main(int argc, char* argv[]) {
       RunShell(isolate);
     }
   }
+  isolate->Dispose();
   V8::Dispose();

   OnExit();
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index 5feb48eeff19f00c404e55603d357a9722a4b8fa..18aab6f56b7b32b0771df965d42e0ff1f5f49626 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1551,9 +1551,7 @@ void Isolate::TearDown() {
     serialize_partial_snapshot_cache_ = NULL;
   }

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

   // Restore the previous current isolate.
   SetIsolateThreadLocals(saved_isolate, saved_data);
Index: src/mips/assembler-mips.cc
diff --git a/src/mips/assembler-mips.cc b/src/mips/assembler-mips.cc
index cc45cda5f3c76ce817429329fc7c23d6fe76192a..29df222f40c78f76b72c9f6be79b1ad89adfa7c4 100644
--- a/src/mips/assembler-mips.cc
+++ b/src/mips/assembler-mips.cc
@@ -105,7 +105,8 @@ const char* DoubleRegister::AllocationIndexToString(int index) {
 void CpuFeatures::Probe() {
   unsigned standard_features = (OS::CpuFeaturesImpliedByPlatform() |
                                 CpuFeaturesImpliedByCompiler());
-  ASSERT(supported_ == 0 || supported_ == standard_features);
+  ASSERT(supported_ == 0 ||
+         (supported_ & standard_features) == standard_features);
 #ifdef DEBUG
   initialized_ = true;
 #endif
Index: src/mksnapshot.cc
diff --git a/src/mksnapshot.cc b/src/mksnapshot.cc
index 07b057549237f14ab2f75ecebf858b7345620bd3..1cbabaa5850dc710fbf376e4e1bf3f6827aaffec 100644
--- a/src/mksnapshot.cc
+++ b/src/mksnapshot.cc
@@ -267,6 +267,8 @@ void DumpException(Handle<Message> message) {

 int main(int argc, char** argv) {
   V8::InitializeICU();
+  // TODO(svenpanne) We can't do this here currently, although we should!
+  // v8::V8::Initialize();
   i::Isolate::SetCrashIfDefaultIsolateInitialized();

   // By default, log code create information in the snapshot.
Index: src/v8.cc
diff --git a/src/v8.cc b/src/v8.cc
index bc1fb2e2fb4bad263be67c8b206c2070dbdd3aa5..e073cd6ba094ed7f4b2bbe651231c763e6bf2b8c 100644
--- a/src/v8.cc
+++ b/src/v8.cc
@@ -77,16 +77,6 @@ bool V8::Initialize(Deserializer* des) {


 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();
Index: test/cctest/cctest.cc
diff --git a/test/cctest/cctest.cc b/test/cctest/cctest.cc
index b1cf5abb4e62284c2d9ea75942b2f2d0e6f253ef..1b39b417d3489e60e529ac13557054cb018cf93c 100644
--- a/test/cctest/cctest.cc
+++ b/test/cctest/cctest.cc
@@ -138,6 +138,7 @@ static void SuggestTestHarness(int tests) {

 int main(int argc, char* argv[]) {
   v8::V8::InitializeICU();
+  v8::V8::Initialize();
   i::Isolate::SetCrashIfDefaultIsolateInitialized();

   v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index e90dd4e2677d53e9abb2e471734f7d977b09c245..9e503073d0a318f186fd678b45f32bbabb10db86 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -22313,6 +22313,7 @@ TEST(EventLogging) {

 TEST(Promises) {
   i::FLAG_harmony_promises = true;
+  i::FlagList::EnforceFlagImplications();

   LocalContext context;
   v8::Isolate* isolate = context->GetIsolate();
Index: test/cctest/test-microtask-delivery.cc
diff --git a/test/cctest/test-microtask-delivery.cc b/test/cctest/test-microtask-delivery.cc index 108337ae3f627e19d42c46846c99584eca7368dd..4c08682b9dca3bdf069ec4cc1d907ae27b6fe824 100644
--- a/test/cctest/test-microtask-delivery.cc
+++ b/test/cctest/test-microtask-delivery.cc
@@ -37,6 +37,7 @@ class HarmonyIsolate {
  public:
   HarmonyIsolate() {
     i::FLAG_harmony_promises = true;
+    i::FlagList::EnforceFlagImplications();
     isolate_ = Isolate::New();
     isolate_->Enter();
   }
Index: tools/lexer-shell.cc
diff --git a/tools/lexer-shell.cc b/tools/lexer-shell.cc
index e2e4a9c2521f55a4074214afe82492c2096d4031..2c3dedd665ed7336218c94dcfc521379d550814f 100644
--- a/tools/lexer-shell.cc
+++ b/tools/lexer-shell.cc
@@ -184,6 +184,7 @@ TimeDelta ProcessFile(

 int main(int argc, char* argv[]) {
   v8::V8::InitializeICU();
+  v8::V8::Initialize();
   v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
   Encoding encoding = LATIN1;
   bool print_tokens = false;
Index: tools/parser-shell.cc
diff --git a/tools/parser-shell.cc b/tools/parser-shell.cc
index 2d95918a33d4b8aca1210c8d11960e20283ee00c..d530c3abe8e0ceab9ad49ce737a1dd5281e9244f 100644
--- a/tools/parser-shell.cc
+++ b/tools/parser-shell.cc
@@ -107,6 +107,7 @@ std::pair<TimeDelta, TimeDelta> RunBaselineParser(

 int main(int argc, char* argv[]) {
   v8::V8::InitializeICU();
+  v8::V8::Initialize();
   v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
   Encoding encoding = LATIN1;
   std::vector<std::string> fnames;


--
--
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