Fix and re-enable test-api/InitializeAndDispose.

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
parent 7e6f6537
...@@ -413,6 +413,7 @@ void RegisteredExtension::UnregisterAll() { ...@@ -413,6 +413,7 @@ void RegisteredExtension::UnregisterAll() {
delete re; delete re;
re = next; re = next;
} }
first_extension_ = NULL;
} }
......
...@@ -937,8 +937,11 @@ void ExternalReference::InitializeMathExpData() { ...@@ -937,8 +937,11 @@ void ExternalReference::InitializeMathExpData() {
void ExternalReference::TearDownMathExpData() { void ExternalReference::TearDownMathExpData() {
delete[] math_exp_constants_array; delete[] math_exp_constants_array;
math_exp_constants_array = NULL;
delete[] math_exp_log_table_array; delete[] math_exp_log_table_array;
math_exp_log_table_array = NULL;
delete math_exp_data_mutex; delete math_exp_data_mutex;
math_exp_data_mutex = NULL;
} }
......
...@@ -99,10 +99,15 @@ void Bootstrapper::InitializeOncePerProcess() { ...@@ -99,10 +99,15 @@ void Bootstrapper::InitializeOncePerProcess() {
void Bootstrapper::TearDownExtensions() { void Bootstrapper::TearDownExtensions() {
delete free_buffer_extension_; delete free_buffer_extension_;
free_buffer_extension_ = NULL;
delete gc_extension_; delete gc_extension_;
gc_extension_ = NULL;
delete externalize_string_extension_; delete externalize_string_extension_;
externalize_string_extension_ = NULL;
delete statistics_extension_; delete statistics_extension_;
statistics_extension_ = NULL;
delete trigger_failure_extension_; delete trigger_failure_extension_;
trigger_failure_extension_ = NULL;
} }
......
...@@ -75,6 +75,7 @@ void SubKindOperand<kOperandKind, kNumCachedOperands>::SetUpCache() { ...@@ -75,6 +75,7 @@ void SubKindOperand<kOperandKind, kNumCachedOperands>::SetUpCache() {
template <InstructionOperand::Kind kOperandKind, int kNumCachedOperands> template <InstructionOperand::Kind kOperandKind, int kNumCachedOperands>
void SubKindOperand<kOperandKind, kNumCachedOperands>::TearDownCache() { void SubKindOperand<kOperandKind, kNumCachedOperands>::TearDownCache() {
delete[] cache; delete[] cache;
cache = NULL;
} }
......
...@@ -120,7 +120,7 @@ ELEMENTS_LIST(ELEMENTS_TRAITS) ...@@ -120,7 +120,7 @@ ELEMENTS_LIST(ELEMENTS_TRAITS)
#undef ELEMENTS_TRAITS #undef ELEMENTS_TRAITS
ElementsAccessor** ElementsAccessor::elements_accessors_; ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
static bool HasKey(Handle<FixedArray> array, Handle<Object> key_handle) { static bool HasKey(Handle<FixedArray> array, Handle<Object> key_handle) {
...@@ -1735,6 +1735,7 @@ void ElementsAccessor::InitializeOncePerProcess() { ...@@ -1735,6 +1735,7 @@ void ElementsAccessor::InitializeOncePerProcess() {
void ElementsAccessor::TearDown() { void ElementsAccessor::TearDown() {
if (elements_accessors_ == NULL) return;
#define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind]; #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind];
ELEMENTS_LIST(ACCESSOR_DELETE) ELEMENTS_LIST(ACCESSOR_DELETE)
#undef ACCESSOR_DELETE #undef ACCESSOR_DELETE
......
...@@ -1592,6 +1592,7 @@ void Isolate::TearDown() { ...@@ -1592,6 +1592,7 @@ void Isolate::TearDown() {
void Isolate::GlobalTearDown() { void Isolate::GlobalTearDown() {
delete thread_data_table_; delete thread_data_table_;
thread_data_table_ = NULL;
} }
......
...@@ -145,6 +145,7 @@ void LSubKindOperand<kOperandKind, kNumCachedOperands>::SetUpCache() { ...@@ -145,6 +145,7 @@ void LSubKindOperand<kOperandKind, kNumCachedOperands>::SetUpCache() {
template<LOperand::Kind kOperandKind, int kNumCachedOperands> template<LOperand::Kind kOperandKind, int kNumCachedOperands>
void LSubKindOperand<kOperandKind, kNumCachedOperands>::TearDownCache() { void LSubKindOperand<kOperandKind, kNumCachedOperands>::TearDownCache() {
delete[] cache; delete[] cache;
cache = NULL;
} }
......
...@@ -276,7 +276,7 @@ class SimulatorHelper { ...@@ -276,7 +276,7 @@ class SimulatorHelper {
class SignalHandler : public AllStatic { class SignalHandler : public AllStatic {
public: public:
static void SetUp() { if (!mutex_) mutex_ = new base::Mutex(); } static void SetUp() { if (!mutex_) mutex_ = new base::Mutex(); }
static void TearDown() { delete mutex_; } static void TearDown() { delete mutex_; mutex_ = NULL; }
static void IncreaseSamplerCount() { static void IncreaseSamplerCount() {
base::LockGuard<base::Mutex> lock_guard(mutex_); base::LockGuard<base::Mutex> lock_guard(mutex_);
......
...@@ -52,7 +52,6 @@ void V8::TearDown() { ...@@ -52,7 +52,6 @@ void V8::TearDown() {
ExternalReference::TearDownMathExpData(); ExternalReference::TearDownMathExpData();
RegisteredExtension::UnregisterAll(); RegisteredExtension::UnregisterAll();
Isolate::GlobalTearDown(); Isolate::GlobalTearDown();
Sampler::TearDown(); Sampler::TearDown();
FlagList::ResetAllFlags(); // Frees memory held by string arguments. FlagList::ResetAllFlags(); // Frees memory held by string arguments.
} }
......
...@@ -35,10 +35,6 @@ ...@@ -35,10 +35,6 @@
# BUG(382): Weird test. Can't guarantee that it never times out. # BUG(382): Weird test. Can't guarantee that it never times out.
'test-api/ApplyInterruption': [PASS, TIMEOUT], '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 # These tests always fail. They are here to test test.py. If
# they don't fail then test.py has failed. # they don't fail then test.py has failed.
'test-serialize/TestThatAlwaysFails': [FAIL], 'test-serialize/TestThatAlwaysFails': [FAIL],
......
...@@ -130,19 +130,18 @@ static void SignatureCallback( ...@@ -130,19 +130,18 @@ static void SignatureCallback(
// Tests that call v8::V8::Dispose() cannot be threaded. // Tests that call v8::V8::Dispose() cannot be threaded.
TEST(InitializeAndDisposeOnce) { UNINITIALIZED_TEST(InitializeAndDisposeOnce) {
CHECK(v8::V8::Initialize()); CHECK(v8::V8::Initialize());
CHECK(v8::V8::Dispose()); CHECK(v8::V8::Dispose());
} }
// Tests that call v8::V8::Dispose() cannot be threaded. // 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::Dispose());
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()); 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()); for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment