Reviewers: Yang,

Description:
Fix missing tagging of stack value in finally block.

[email protected]
BUG=chromium:137496
TEST=cctest/test-api/Regress137496


Please review this at https://chromiumcodereview.appspot.com/10787017/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/arm/full-codegen-arm.cc
  M src/ia32/full-codegen-ia32.cc
  M src/mips/full-codegen-mips.cc
  M src/x64/full-codegen-x64.cc
  M test/cctest/test-api.cc


Index: src/arm/full-codegen-arm.cc
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc
index aadff7ada84fb5d7095e9a6a8cc064cf9bee4920..d8f64acbc0a1c7cf8a83e71597a548bc2adf880e 100644
--- a/src/arm/full-codegen-arm.cc
+++ b/src/arm/full-codegen-arm.cc
@@ -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: src/ia32/full-codegen-ia32.cc
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
index 2867d5ec7203c1ab76b725ed6f0187e46e0dd4a7..5d639d8c8ca8b69db7b40869e36d0767e043344b 100644
--- a/src/ia32/full-codegen-ia32.cc
+++ b/src/ia32/full-codegen-ia32.cc
@@ -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: src/mips/full-codegen-mips.cc
diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc
index 246fe2a13f2a9a8b4f8de9b624070ef37b46b1ff..55b37b45df7c9144a97de9ccb1381ff861bbe2d9 100644
--- a/src/mips/full-codegen-mips.cc
+++ b/src/mips/full-codegen-mips.cc
@@ -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: src/x64/full-codegen-x64.cc
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index 1259160c5efb36da624c95a456f8436a86a90930..c68bd5dc5bf453b8fcd96c9b0021bb4baced76bb 100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -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: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 136832c7cbdf939e477d4d8ab7d26e7914efc838..05c01504fb8bace0d564e2b4438e6b5fc3c26671 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -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());
+}


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to