Reviewers: Yang,
Message:
yangguo, ptal
Description:
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.
[email protected]
BUG=
Please review this at https://codereview.chromium.org/302603002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+13, -6 lines):
M src/api.cc
M test/cctest/test-api.cc
M test/cctest/test-parsing.cc
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
c33365b931fab61d8513b050df60321fac395877..a8ab53723b7a58ef5d9e3b243a4d5dfa5a4a8545
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -1728,6 +1728,13 @@ Local<UnboundScript> ScriptCompiler::CompileUnbound(
cached_data_mode,
i::NOT_NATIVES_CODE);
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>());
raw_result = *result;
if ((options & kProduceDataToCache) && script_data_impl != NULL) {
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
2ef58fde9da13399cf0461e996e2eb6b601154c4..dc091f3a9cd888da651d4d9e100745cc7e3ae538
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -22431,14 +22431,13 @@ void StoringEventLoggerCallback(const char*
message, int status) {
TEST(EventLogging) {
v8::Isolate* isolate = CcTest::isolate();
isolate->SetEventLogger(StoringEventLoggerCallback);
- v8::internal::HistogramTimer* histogramTimer =
- new v8::internal::HistogramTimer(
- "V8.Test", 0, 10000, 50,
- reinterpret_cast<v8::internal::Isolate*>(isolate));
- histogramTimer->Start();
+ v8::internal::HistogramTimer histogramTimer(
+ "V8.Test", 0, 10000, 50,
+ reinterpret_cast<v8::internal::Isolate*>(isolate));
+ histogramTimer.Start();
CHECK_EQ("V8.Test", last_event_message);
CHECK_EQ(0, last_event_status);
- histogramTimer->Stop();
+ histogramTimer.Stop();
CHECK_EQ("V8.Test", last_event_message);
CHECK_EQ(1, last_event_status);
}
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index
80a116f1155b592213285f4c7e23182dcfcc0646..b95944bf0f036e8c2168d5d3a788057c4f6edade
100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -2009,6 +2009,7 @@ TEST(DontRegressPreParserDataSizes) {
data->function_count());
CHECK(false);
}
+ delete data;
}
}
--
--
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.