Commit 2b7810c0 authored by marja@chromium.org's avatar marja@chromium.org

Fix mem leaks in tests & ScriptCompiler::CompileUnbound.

- Leak in test-parsing/DontRegressPreParserDataSizes
- Leak in test-api/EventLogging
- Leak in ScriptCompiler::CompileUnbound which won't happen during normal
operation, but exposed by test-apöi/CompiledWithInvalidCachedData.

R=yangguo@chromium.org
BUG=

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21488 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f0527ae6
...@@ -1728,6 +1728,13 @@ Local<UnboundScript> ScriptCompiler::CompileUnbound( ...@@ -1728,6 +1728,13 @@ Local<UnboundScript> ScriptCompiler::CompileUnbound(
cached_data_mode, cached_data_mode,
i::NOT_NATIVES_CODE); i::NOT_NATIVES_CODE);
has_pending_exception = result.is_null(); has_pending_exception = result.is_null();
if (has_pending_exception && cached_data_mode == i::CONSUME_CACHED_DATA) {
// This case won't happen during normal operation; we have compiled
// successfully and produced cached data, and but the second compilation
// of the same source code fails.
delete script_data_impl;
script_data_impl = NULL;
}
EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>()); EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>());
raw_result = *result; raw_result = *result;
if ((options & kProduceDataToCache) && script_data_impl != NULL) { if ((options & kProduceDataToCache) && script_data_impl != NULL) {
......
...@@ -22431,14 +22431,13 @@ void StoringEventLoggerCallback(const char* message, int status) { ...@@ -22431,14 +22431,13 @@ void StoringEventLoggerCallback(const char* message, int status) {
TEST(EventLogging) { TEST(EventLogging) {
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
isolate->SetEventLogger(StoringEventLoggerCallback); isolate->SetEventLogger(StoringEventLoggerCallback);
v8::internal::HistogramTimer* histogramTimer = v8::internal::HistogramTimer histogramTimer(
new v8::internal::HistogramTimer( "V8.Test", 0, 10000, 50,
"V8.Test", 0, 10000, 50, reinterpret_cast<v8::internal::Isolate*>(isolate));
reinterpret_cast<v8::internal::Isolate*>(isolate)); histogramTimer.Start();
histogramTimer->Start();
CHECK_EQ("V8.Test", last_event_message); CHECK_EQ("V8.Test", last_event_message);
CHECK_EQ(0, last_event_status); CHECK_EQ(0, last_event_status);
histogramTimer->Stop(); histogramTimer.Stop();
CHECK_EQ("V8.Test", last_event_message); CHECK_EQ("V8.Test", last_event_message);
CHECK_EQ(1, last_event_status); CHECK_EQ(1, last_event_status);
} }
......
...@@ -2009,6 +2009,7 @@ TEST(DontRegressPreParserDataSizes) { ...@@ -2009,6 +2009,7 @@ TEST(DontRegressPreParserDataSizes) {
data->function_count()); data->function_count());
CHECK(false); CHECK(false);
} }
delete data;
} }
} }
......
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