Fix missing tagging of stack value in finally block.
authormstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 16 Jul 2012 13:38:17 +0000 (13:38 +0000)
committermstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 16 Jul 2012 13:38:17 +0000 (13:38 +0000)
R=yangguo@chromium.org
BUG=chromium:137496
TEST=cctest/test-api/Regress137496

Review URL: https://chromiumcodereview.appspot.com/10787017

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

src/arm/full-codegen-arm.cc
src/ia32/full-codegen-ia32.cc
src/mips/full-codegen-mips.cc
src/x64/full-codegen-x64.cc
test/cctest/test-api.cc

index aadff7a..d8f64ac 100644 (file)
@@ -4509,6 +4509,7 @@ void FullCodeGenerator::EnterFinallyBlock() {
       ExternalReference::address_of_has_pending_message(isolate());
   __ mov(ip, Operand(has_pending_message));
   __ ldr(r1, MemOperand(ip));
+  __ SmiTag(r1);
   __ push(r1);
 
   ExternalReference pending_message_script =
@@ -4529,6 +4530,7 @@ void FullCodeGenerator::ExitFinallyBlock() {
   __ str(r1, MemOperand(ip));
 
   __ pop(r1);
+  __ SmiUntag(r1);
   ExternalReference has_pending_message =
       ExternalReference::address_of_has_pending_message(isolate());
   __ mov(ip, Operand(has_pending_message));
index 2867d5e..5d639d8 100644 (file)
@@ -4485,6 +4485,7 @@ void FullCodeGenerator::EnterFinallyBlock() {
   ExternalReference has_pending_message =
       ExternalReference::address_of_has_pending_message(isolate());
   __ mov(edx, Operand::StaticVariable(has_pending_message));
+  __ SmiTag(edx);
   __ push(edx);
 
   ExternalReference pending_message_script =
@@ -4503,6 +4504,7 @@ void FullCodeGenerator::ExitFinallyBlock() {
   __ mov(Operand::StaticVariable(pending_message_script), edx);
 
   __ pop(edx);
+  __ SmiUntag(edx);
   ExternalReference has_pending_message =
       ExternalReference::address_of_has_pending_message(isolate());
   __ mov(Operand::StaticVariable(has_pending_message), edx);
index 246fe2a..55b37b4 100644 (file)
@@ -4545,6 +4545,7 @@ void FullCodeGenerator::EnterFinallyBlock() {
       ExternalReference::address_of_has_pending_message(isolate());
   __ li(at, Operand(has_pending_message));
   __ lw(a1, MemOperand(at));
+  __ SmiTag(a1);
   __ push(a1);
 
   ExternalReference pending_message_script =
@@ -4565,6 +4566,7 @@ void FullCodeGenerator::ExitFinallyBlock() {
   __ sw(a1, MemOperand(at));
 
   __ pop(a1);
+  __ SmiUntag(a1);
   ExternalReference has_pending_message =
       ExternalReference::address_of_has_pending_message(isolate());
   __ li(at, Operand(has_pending_message));
index 1259160..c68bd5d 100644 (file)
@@ -4477,6 +4477,7 @@ void FullCodeGenerator::EnterFinallyBlock() {
   ExternalReference has_pending_message =
       ExternalReference::address_of_has_pending_message(isolate());
   __ Load(rdx, has_pending_message);
+  __ Integer32ToSmi(rdx, rdx);
   __ push(rdx);
 
   ExternalReference pending_message_script =
@@ -4496,6 +4497,7 @@ void FullCodeGenerator::ExitFinallyBlock() {
   __ Store(pending_message_script, rdx);
 
   __ pop(rdx);
+  __ SmiToInteger32(rdx, rdx);
   ExternalReference has_pending_message =
       ExternalReference::address_of_has_pending_message(isolate());
   __ Store(has_pending_message, rdx);
index 136832c..05c0150 100644 (file)
@@ -16856,3 +16856,17 @@ THREADED_TEST(Regress137002b) {
              "var result = f(obj);");
   CHECK(context->Global()->Get(v8_str("result"))->IsUndefined());
 }
+
+
+THREADED_TEST(Regress137496) {
+  i::FLAG_expose_gc = true;
+  v8::HandleScope scope;
+  LocalContext context;
+
+  // Compile a try-finally clause where the finally block causes a GC
+  // while there still is a message pending for external reporting.
+  TryCatch try_catch;
+  try_catch.SetVerbose(true);
+  CompileRun("try { throw new Error(); } finally { gc(); }");
+  CHECK(try_catch.HasCaught());
+}