Author: [EMAIL PROTECTED]
Date: Wed Oct 1 00:43:00 2008
New Revision: 400
Added:
branches/bleeding_edge/test/mjsunit/regress/regress-86.js (contents,
props changed)
- copied, changed from r399,
/branches/bleeding_edge/test/mjsunit/bugs/bug-86.js
Removed:
branches/bleeding_edge/test/mjsunit/bugs/bug-86.js
Modified:
branches/bleeding_edge/src/codegen-arm.cc
branches/bleeding_edge/src/codegen-ia32.cc
Log:
Fix issue 86 by keeping track of the fact that finally blocks
are evaluated with an extra element on the stack, which needs
to be taken into account when breaking and continuing.
I'll clean up the code and add an abstraction for manipulating
the break stack height in a future CL -- I want to try to get
rid of the separate local variable we keep around for the "state"
when running in a finally block.
Review URL: http://codereview.chromium.org/5625
Modified: branches/bleeding_edge/src/codegen-arm.cc
==============================================================================
--- branches/bleeding_edge/src/codegen-arm.cc (original)
+++ branches/bleeding_edge/src/codegen-arm.cc Wed Oct 1 00:43:00 2008
@@ -3182,6 +3182,12 @@
// --- Finally block ---
__ bind(&finally_block);
+ // We keep a single element on the stack - the (possibly faked)
+ // result - while evaluating the finally block. Record it, so that a
+ // break/continue crossing this statement can restore the stack.
+ const int kFinallyStackSize = 1 * kPointerSize;
+ break_stack_height_ += kFinallyStackSize;
+
// Push the state on the stack. If necessary move the state to a
// local variable to avoid having extra values on the stack while
// evaluating the finally block.
@@ -3203,7 +3209,12 @@
}
__ pop(r2);
- __ pop(r0); // Restore value or faked TOS.
+ // Restore return value or faked TOS.
+ __ pop(r0);
+
+ // Record the fact that the result has been removed from the stack.
+ break_stack_height_ -= kFinallyStackSize;
+
// Generate code that jumps to the right destination for all used
// shadow labels.
for (int i = 0; i <= nof_escapes; i++) {
Modified: branches/bleeding_edge/src/codegen-ia32.cc
==============================================================================
--- branches/bleeding_edge/src/codegen-ia32.cc (original)
+++ branches/bleeding_edge/src/codegen-ia32.cc Wed Oct 1 00:43:00 2008
@@ -3492,7 +3492,7 @@
__ PushTryHandler(IN_JAVASCRIPT, TRY_FINALLY_HANDLER);
// TODO(1222589): remove the reliance of PushTryHandler on a cached TOS
- __ push(eax); //
+ __ push(eax);
// Introduce shadow labels for all escapes from the try block,
// including returns. We should probably try to unify the escaping
@@ -3558,6 +3558,12 @@
// --- Finally block ---
__ bind(&finally_block);
+ // We keep a single element on the stack - the (possibly faked)
+ // result - while evaluating the finally block. Record it, so that a
+ // break/continue crossing this statement can restore the stack.
+ const int kFinallyStackSize = 1 * kPointerSize;
+ break_stack_height_ += kFinallyStackSize;
+
// Push the state on the stack. If necessary move the state to a
// local variable to avoid having extra values on the stack while
// evaluating the finally block.
@@ -3582,6 +3588,9 @@
// Restore return value or faked TOS.
__ pop(eax);
+
+ // Record the fact that the result has been removed from the stack.
+ break_stack_height_ -= kFinallyStackSize;
// Generate code that jumps to the right destination for all used
// shadow labels.
Copied: branches/bleeding_edge/test/mjsunit/regress/regress-86.js (from
r399, /branches/bleeding_edge/test/mjsunit/bugs/bug-86.js)
==============================================================================
--- /branches/bleeding_edge/test/mjsunit/bugs/bug-86.js (original)
+++ branches/bleeding_edge/test/mjsunit/regress/regress-86.js Wed Oct 1
00:43:00 2008
@@ -28,8 +28,9 @@
var aList = [1, 2, 3];
var loopCount = 0;
var leftThroughFinally = false;
+var enteredFinally = false;
for (x in aList) {
- leftThroughFinally = false;
+ leftThroughFinally = true;
try {
throw "ex1";
} catch(er1) {
@@ -40,5 +41,6 @@
}
leftThroughFinally = false;
}
-assertEquals(loopCount, 3);
+assertEquals(3, loopCount);
assertTrue(enteredFinally);
+assertTrue(leftThroughFinally);
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---