Reviewers: Michael Starzinger,
Description:
Do not leak message object beyond try-catch.
[email protected]
Please review this at https://codereview.chromium.org/1150293002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+36, -0 lines):
M src/full-codegen.h
M src/full-codegen.cc
M src/x64/full-codegen-x64.cc
M test/cctest/test-heap.cc
Index: src/full-codegen.cc
diff --git a/src/full-codegen.cc b/src/full-codegen.cc
index
4ea455edfe9d2f1ac9c0b4f0109cb69d8297ea24..4e04e8556f7c27c227da0b6d20465a06d307a3a8
100644
--- a/src/full-codegen.cc
+++ b/src/full-codegen.cc
@@ -1182,6 +1182,7 @@ void
FullCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) {
Label try_entry, handler_entry, exit;
__ jmp(&try_entry);
__ bind(&handler_entry);
+ EnterCatchBlock();
// Exception handler code, the exception is in the result register.
// Extend the context before executing the catch block.
{ Comment cmnt(masm_, "[ Extend catch context");
Index: src/full-codegen.h
diff --git a/src/full-codegen.h b/src/full-codegen.h
index
34e93eedf444fd81c6154574c4d7ff52ee80ab58..58d35ef7014cdd200f25cf7e872e83bfb1690eb0
100644
--- a/src/full-codegen.h
+++ b/src/full-codegen.h
@@ -709,6 +709,7 @@ class FullCodeGenerator: public AstVisitor {
void ExitTryBlock(int handler_index);
void EnterFinallyBlock();
void ExitFinallyBlock();
+ void EnterCatchBlock();
// Loop nesting counter.
int loop_depth() { return loop_depth_; }
Index: src/x64/full-codegen-x64.cc
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index
6e26e7670cfc357883b16fb55d0f6bf77b7f55db..d6598fd7d27d0cdce9101d860db29315118eba22
100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -5319,6 +5319,14 @@ void FullCodeGenerator::ExitFinallyBlock() {
}
+void FullCodeGenerator::EnterCatchBlock() {
+ ExternalReference pending_message_obj =
+ ExternalReference::address_of_pending_message_obj(isolate());
+ __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex);
+ __ Store(pending_message_obj, kScratchRegister);
+}
+
+
#undef __
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index
d9d2a861ebf30d4644d91f71ee49ceaf10627f47..ee5aa96e94c242b27e96324ae6cc97b0adf9eff9
100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -5558,3 +5558,29 @@ TEST(NewSpaceAllocationThroughput2) {
bytes = tracer->NewSpaceAllocatedBytesInLast(100);
CHECK_EQ((counter3 - counter1) * 100 / (time3 - time1), bytes);
}
+
+
+static void CheckLeak(const v8::FunctionCallbackInfo<v8::Value>& args) {
+ Isolate* isolate = CcTest::i_isolate();
+ Object* message =
+ *reinterpret_cast<Object**>(isolate->pending_message_obj_address());
+ CHECK(message->IsTheHole());
+}
+
+
+TEST(MessageObjectLeak) {
+ CcTest::InitializeVM();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
+ global->Set(v8::String::NewFromUtf8(isolate, "check"),
+ v8::FunctionTemplate::New(isolate, CheckLeak));
+ v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
+ v8::Context::Scope cscope(context);
+ CompileRun(
+ "try {"
+ " throw 'message';"
+ "} catch (e) {"
+ "}"
+ "check();");
+}
--
--
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.