Fix and re-enable test-api/InitializeAndDispose.
authormstarzinger@chromium.org <mstarzinger@chromium.org>
Tue, 26 Aug 2014 13:07:18 +0000 (13:07 +0000)
committermstarzinger@chromium.org <mstarzinger@chromium.org>
Tue, 26 Aug 2014 13:07:18 +0000 (13:07 +0000)
R=svenpanne@chromium.org
TEST=cctest/test-api/InitializeAndDispose

Review URL: https://codereview.chromium.org/504093002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23401 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/api.cc
src/assembler.cc
src/bootstrapper.cc
src/compiler/instruction.cc
src/elements.cc
src/isolate.cc
src/lithium.cc
src/sampler.cc
src/v8.cc
test/cctest/cctest.status
test/cctest/test-api.cc

index 041d86be7a1ea71588c3a264487b0bd047e69557..667f9afcbceb3471ea1e77c17673002910b1a096 100644 (file)
@@ -413,6 +413,7 @@ void RegisteredExtension::UnregisterAll() {
     delete re;
     re = next;
   }
+  first_extension_ = NULL;
 }
 
 
index 4187675f1f0cff8a042823884917be342c489d7d..d2c8bd67772faf846ae1e4f1900be1d369eca68b 100644 (file)
@@ -937,8 +937,11 @@ void ExternalReference::InitializeMathExpData() {
 
 void ExternalReference::TearDownMathExpData() {
   delete[] math_exp_constants_array;
+  math_exp_constants_array = NULL;
   delete[] math_exp_log_table_array;
+  math_exp_log_table_array = NULL;
   delete math_exp_data_mutex;
+  math_exp_data_mutex = NULL;
 }
 
 
index 09e56d991bbb51eada311f24863f61bb9655cd5f..45d2f14347afe181421fd966a05ce27f32635687 100644 (file)
@@ -99,10 +99,15 @@ void Bootstrapper::InitializeOncePerProcess() {
 
 void Bootstrapper::TearDownExtensions() {
   delete free_buffer_extension_;
+  free_buffer_extension_ = NULL;
   delete gc_extension_;
+  gc_extension_ = NULL;
   delete externalize_string_extension_;
+  externalize_string_extension_ = NULL;
   delete statistics_extension_;
+  statistics_extension_ = NULL;
   delete trigger_failure_extension_;
+  trigger_failure_extension_ = NULL;
 }
 
 
index a2f4ed4f47f6b56ff5cd87cdc66af4b68a9d7860..dd80cad4cfd839c6d8e19e109077d299645180ee 100644 (file)
@@ -75,6 +75,7 @@ void SubKindOperand<kOperandKind, kNumCachedOperands>::SetUpCache() {
 template <InstructionOperand::Kind kOperandKind, int kNumCachedOperands>
 void SubKindOperand<kOperandKind, kNumCachedOperands>::TearDownCache() {
   delete[] cache;
+  cache = NULL;
 }
 
 
index 76b9b03bf62d51a0ff4a59127f809f8f441fef84..121dd7d25eb0661dbe77432eb8345c11874b60ff 100644 (file)
@@ -120,7 +120,7 @@ ELEMENTS_LIST(ELEMENTS_TRAITS)
 #undef ELEMENTS_TRAITS
 
 
-ElementsAccessor** ElementsAccessor::elements_accessors_;
+ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
 
 
 static bool HasKey(Handle<FixedArray> array, Handle<Object> key_handle) {
@@ -1735,6 +1735,7 @@ void ElementsAccessor::InitializeOncePerProcess() {
 
 
 void ElementsAccessor::TearDown() {
+  if (elements_accessors_ == NULL) return;
 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind];
   ELEMENTS_LIST(ACCESSOR_DELETE)
 #undef ACCESSOR_DELETE
index abd2e3413167ba17347e722cd3386798fed05936..95c5290c950a4fa74d93ca53b4fc2da479483c94 100644 (file)
@@ -1592,6 +1592,7 @@ void Isolate::TearDown() {
 
 void Isolate::GlobalTearDown() {
   delete thread_data_table_;
+  thread_data_table_ = NULL;
 }
 
 
index a8d4d22ab5cad967e732826aa2510d7266754dce..26d07b3c4a2075546e823905b0b696711b31ba11 100644 (file)
@@ -145,6 +145,7 @@ void LSubKindOperand<kOperandKind, kNumCachedOperands>::SetUpCache() {
 template<LOperand::Kind kOperandKind, int kNumCachedOperands>
 void LSubKindOperand<kOperandKind, kNumCachedOperands>::TearDownCache() {
   delete[] cache;
+  cache = NULL;
 }
 
 
index 413b6be9060daa43c41bb6e41414ef419d1a299b..29fe27fd35866ffe62e26105fadbe728bfdc7666 100644 (file)
@@ -276,7 +276,7 @@ class SimulatorHelper {
 class SignalHandler : public AllStatic {
  public:
   static void SetUp() { if (!mutex_) mutex_ = new base::Mutex(); }
-  static void TearDown() { delete mutex_; }
+  static void TearDown() { delete mutex_; mutex_ = NULL; }
 
   static void IncreaseSamplerCount() {
     base::LockGuard<base::Mutex> lock_guard(mutex_);
index 5276949c0dbfc5a9cd689caeb80f16fb8027fce2..d4f59a107a695c9c621e8c631e7f5b1132341189 100644 (file)
--- a/src/v8.cc
+++ b/src/v8.cc
@@ -52,7 +52,6 @@ void V8::TearDown() {
   ExternalReference::TearDownMathExpData();
   RegisteredExtension::UnregisterAll();
   Isolate::GlobalTearDown();
-
   Sampler::TearDown();
   FlagList::ResetAllFlags();  // Frees memory held by string arguments.
 }
index 90617c920a1ef8069e3c1f9365acd31aff6ce361..f2bb922c4f3c8cfecc3266fdcb349881c7ad266a 100644 (file)
   # BUG(382): Weird test. Can't guarantee that it never times out.
   'test-api/ApplyInterruption': [PASS, TIMEOUT],
 
-  # TODO(mstarzinger): Fail gracefully on multiple V8::Dispose calls.
-  'test-api/InitializeAndDisposeOnce': [SKIP],
-  'test-api/InitializeAndDisposeMultiple': [SKIP],
-
   # These tests always fail.  They are here to test test.py.  If
   # they don't fail then test.py has failed.
   'test-serialize/TestThatAlwaysFails': [FAIL],
index 407de662acb887db3c8e69d28d865cac026d4293..f74c1a2b7906d8bae131e87acd8009914b171c5b 100644 (file)
@@ -130,19 +130,18 @@ static void SignatureCallback(
 
 
 // Tests that call v8::V8::Dispose() cannot be threaded.
-TEST(InitializeAndDisposeOnce) {
+UNINITIALIZED_TEST(InitializeAndDisposeOnce) {
   CHECK(v8::V8::Initialize());
   CHECK(v8::V8::Dispose());
 }
 
 
 // Tests that call v8::V8::Dispose() cannot be threaded.
-TEST(InitializeAndDisposeMultiple) {
+UNINITIALIZED_TEST(InitializeAndDisposeMultiple) {
   for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose());
   for (int i = 0; i < 3; ++i) CHECK(v8::V8::Initialize());
   for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose());
-  // TODO(mstarzinger): This should fail gracefully instead of asserting.
-  // for (int i = 0; i < 3; ++i) CHECK(v8::V8::Initialize());
+  for (int i = 0; i < 3; ++i) CHECK(v8::V8::Initialize());
   for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose());
 }