Revision: 6105
Author: [email protected]
Date: Wed Dec 22 02:59:24 2010
Log: Merge bleeding edge r6035 to 2.4 branch. Fix push of random value in
connection with try-catch in the full code generator.

Review URL: http://codereview.chromium.org/6068002
http://code.google.com/p/v8/source/detail?r=6105

Added:
 /branches/2.4/test/mjsunit/regress/regress-974.js
Modified:
 /branches/2.4/src/arm/full-codegen-arm.cc
 /branches/2.4/src/full-codegen.cc
 /branches/2.4/src/full-codegen.h
 /branches/2.4/src/ia32/full-codegen-ia32.cc
 /branches/2.4/src/version.cc
 /branches/2.4/src/x64/full-codegen-x64.cc

=======================================
--- /dev/null
+++ /branches/2.4/test/mjsunit/regress/regress-974.js Wed Dec 22 02:59:24 2010
@@ -0,0 +1,32 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --expose-gc
+
+// Verify that GC is safe in a finally block entered by falling off the try
+// block.
+eval("(function(){try {  } catch(x) {  } finally { gc() }})")();
=======================================
--- /branches/2.4/src/arm/full-codegen-arm.cc   Mon Sep 27 05:32:04 2010
+++ /branches/2.4/src/arm/full-codegen-arm.cc   Wed Dec 22 02:59:24 2010
@@ -196,6 +196,11 @@
   }
   EmitReturnSequence();
 }
+
+
+void FullCodeGenerator::ClearAccumulator() {
+  __ mov(r0, Operand(Smi::FromInt(0)));
+}


 void FullCodeGenerator::EmitReturnSequence() {
=======================================
--- /branches/2.4/src/full-codegen.cc   Wed Oct 13 01:35:23 2010
+++ /branches/2.4/src/full-codegen.cc   Wed Dec 22 02:59:24 2010
@@ -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);
 }

=======================================
--- /branches/2.4/src/full-codegen.h    Wed Oct 13 01:35:23 2010
+++ /branches/2.4/src/full-codegen.h    Wed Dec 22 02:59:24 2010
@@ -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);
=======================================
--- /branches/2.4/src/ia32/full-codegen-ia32.cc Mon Sep 27 05:32:04 2010
+++ /branches/2.4/src/ia32/full-codegen-ia32.cc Wed Dec 22 02:59:24 2010
@@ -187,6 +187,11 @@
     EmitReturnSequence();
   }
 }
+
+
+void FullCodeGenerator::ClearAccumulator() {
+  __ Set(eax, Immediate(Smi::FromInt(0)));
+}


 void FullCodeGenerator::EmitReturnSequence() {
=======================================
--- /branches/2.4/src/version.cc        Fri Dec 17 05:42:32 2010
+++ /branches/2.4/src/version.cc        Wed Dec 22 02:59:24 2010
@@ -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
=======================================
--- /branches/2.4/src/x64/full-codegen-x64.cc   Mon Oct  4 01:54:21 2010
+++ /branches/2.4/src/x64/full-codegen-x64.cc   Wed Dec 22 02:59:24 2010
@@ -188,6 +188,11 @@
     EmitReturnSequence();
   }
 }
+
+
+void FullCodeGenerator::ClearAccumulator() {
+  __ xor(rax, rax);
+}


 void FullCodeGenerator::EmitReturnSequence() {

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

Reply via email to