Reviewers: Søren Gjesse, Kevin Millikin,

Description:
Merge bleeding edge r6035 to 2.4 branch. Fix push of random value in
connection with try-catch in the full code generator.


Please review this at http://codereview.chromium.org/6068002/

SVN Base: http://v8.googlecode.com/svn/branches/2.4/

Affected files:
  M     src/arm/full-codegen-arm.cc
  M     src/full-codegen.h
  M     src/full-codegen.cc
  M     src/ia32/full-codegen-ia32.cc
  M     src/version.cc
  M     src/x64/full-codegen-x64.cc
  A  +  test/mjsunit/regress/regress-974.js


### BEGIN SVN COPY METADATA
#$ cp branches/bleeding_edge/test/mjsunit/regress/regress-974.js test/mjsunit/regress/regress-974.js
### END SVN COPY METADATA
Index: src/arm/full-codegen-arm.cc
===================================================================
--- src/arm/full-codegen-arm.cc (revision 6071)
+++ src/arm/full-codegen-arm.cc (working copy)
@@ -198,6 +198,11 @@
 }


+void FullCodeGenerator::ClearAccumulator() {
+  __ mov(r0, Operand(Smi::FromInt(0)));
+}
+
+
 void FullCodeGenerator::EmitReturnSequence() {
   Comment cmnt(masm_, "[ Return sequence");
   if (return_label_.is_bound()) {
Index: src/full-codegen.cc
===================================================================
--- src/full-codegen.cc (revision 6071)
+++ src/full-codegen.cc (working copy)
@@ -799,6 +799,11 @@
   SetStatementPosition(stmt);
   NestedStatement* current = nesting_stack_;
   int stack_depth = 0;
+  // When continuing, we clobber the unpredictable value in the accumulator
+  // with one that's safe for GC.  If we hit an exit from the try block of
+  // try...finally on our way out, we will unconditionally preserve the
+  // accumulator on the stack.
+  ClearAccumulator();
   while (!current->IsContinueTarget(stmt->target())) {
     stack_depth = current->Exit(stack_depth);
     current = current->outer();
@@ -815,6 +820,11 @@
   SetStatementPosition(stmt);
   NestedStatement* current = nesting_stack_;
   int stack_depth = 0;
+  // When breaking, we clobber the unpredictable value in the accumulator
+  // with one that's safe for GC.  If we hit an exit from the try block of
+  // try...finally on our way out, we will unconditionally preserve the
+  // accumulator on the stack.
+  ClearAccumulator();
   while (!current->IsBreakTarget(stmt->target())) {
     stack_depth = current->Exit(stack_depth);
     current = current->outer();
@@ -1104,7 +1114,10 @@
     Visit(stmt->try_block());
     __ PopTryHandler();
   }
-  // Execute the finally block on the way out.
+  // Execute the finally block on the way out.  Clobber the unpredictable
+  // value in the accumulator with one that's safe for GC.  The finally
+  // block will unconditionally preserve the accumulator on the stack.
+  ClearAccumulator();
   __ Call(&finally_entry);
 }

Index: src/full-codegen.h
===================================================================
--- src/full-codegen.h  (revision 6071)
+++ src/full-codegen.h  (working copy)
@@ -241,6 +241,10 @@

   static const InlineFunctionGenerator kInlineFunctionGenerators[];

+  // A platform-specific utility to overwrite the accumulator register
+  // with a GC-safe value.
+  void ClearAccumulator();
+
   // Compute the frame pointer relative offset for a given local or
   // parameter slot.
   int SlotOffset(Slot* slot);
Index: src/ia32/full-codegen-ia32.cc
===================================================================
--- src/ia32/full-codegen-ia32.cc       (revision 6071)
+++ src/ia32/full-codegen-ia32.cc       (working copy)
@@ -189,6 +189,11 @@
 }


+void FullCodeGenerator::ClearAccumulator() {
+  __ Set(eax, Immediate(Smi::FromInt(0)));
+}
+
+
 void FullCodeGenerator::EmitReturnSequence() {
   Comment cmnt(masm_, "[ Return sequence");
   if (return_label_.is_bound()) {
Index: src/version.cc
===================================================================
--- src/version.cc      (revision 6071)
+++ src/version.cc      (working copy)
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     2
 #define MINOR_VERSION     4
 #define BUILD_NUMBER      9
-#define PATCH_LEVEL       17
+#define PATCH_LEVEL       18
 #define CANDIDATE_VERSION false

 // Define SONAME to have the SCons build the put a specific SONAME into the
Index: src/x64/full-codegen-x64.cc
===================================================================
--- src/x64/full-codegen-x64.cc (revision 6071)
+++ src/x64/full-codegen-x64.cc (working copy)
@@ -190,6 +190,11 @@
 }


+void FullCodeGenerator::ClearAccumulator() {
+  __ xor(rax, rax);
+}
+
+
 void FullCodeGenerator::EmitReturnSequence() {
   Comment cmnt(masm_, "[ Return sequence");
   if (return_label_.is_bound()) {
Index: test/mjsunit/regress/regress-974.js


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

Reply via email to