Revision: 11025
Author:   [email protected]
Date:     Tue Mar 13 08:04:45 2012
Log:      Merged r11022 into 3.8 branch.

Ensure there is a smi check of the receiver for global load and call ICs.

BUG=117794

[email protected]

Review URL: https://chromiumcodereview.appspot.com/9691049
http://code.google.com/p/v8/source/detail?r=11025

Added:
 /branches/3.8/test/mjsunit/regress/regress-117794.js
Modified:
 /branches/3.8/src/arm/stub-cache-arm.cc
 /branches/3.8/src/ia32/stub-cache-ia32.cc
 /branches/3.8/src/mips/stub-cache-mips.cc
 /branches/3.8/src/version.cc
 /branches/3.8/src/x64/stub-cache-x64.cc

=======================================
--- /dev/null
+++ /branches/3.8/test/mjsunit/regress/regress-117794.js Tue Mar 13 08:04:45 2012
@@ -0,0 +1,57 @@
+// Copyright 2012 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.
+
+// Loads specialized to be from the global object should not omit the
+// smi check on the receiver.  The code below should not crash.
+
+print = function() {}
+
+function constructor() {};
+
+function assertHasOwnProperties(object, limit) {
+  for (var i = 0; i < limit; i++) {  }
+}
+
+try {
+  Object.keys();
+} catch(exc2) {
+  print(exc2.stack);
+}
+
+var x1 = new Object();
+
+try {
+  new Function("A Man Called Horse", x1.d);
+} catch(exc3) {
+  print(exc3.stack);
+}
+
+try {
+  (-(true)).toPrecision(0x30, 'lib1-f1');
+} catch(exc1) {
+  print(exc1.stack);
+}
=======================================
--- /branches/3.8/src/arm/stub-cache-arm.cc     Mon Jan 23 06:42:48 2012
+++ /branches/3.8/src/arm/stub-cache-arm.cc     Tue Mar 13 08:04:45 2012
@@ -1320,15 +1320,9 @@

   // Get the receiver from the stack.
   __ ldr(r0, MemOperand(sp, argc * kPointerSize));
-
-  // If the object is the holder then we know that it's a global
-  // object which can only happen for contextual calls. In this case,
-  // the receiver cannot be a smi.
-  if (!object.is_identical_to(holder)) {
-    __ JumpIfSmi(r0, miss);
-  }

   // Check that the maps haven't changed.
+  __ JumpIfSmi(r0, miss);
   CheckPrototypes(object, r0, holder, r3, r1, r4, name, miss);
 }

@@ -2724,15 +2718,9 @@
   //  -- lr    : return address
   // -----------------------------------
   Label miss;
-
-  // If the object is the holder then we know that it's a global
-  // object which can only happen for contextual calls. In this case,
-  // the receiver cannot be a smi.
-  if (!object.is_identical_to(holder)) {
-    __ JumpIfSmi(r0, &miss);
-  }

   // Check that the map of the global has not changed.
+  __ JumpIfSmi(r0, &miss);
   CheckPrototypes(object, r0, holder, r3, r4, r1, name, &miss);

   // Get the value from the cell.
=======================================
--- /branches/3.8/src/ia32/stub-cache-ia32.cc   Mon Jan 23 06:42:48 2012
+++ /branches/3.8/src/ia32/stub-cache-ia32.cc   Tue Mar 13 08:04:45 2012
@@ -1195,14 +1195,9 @@
   // Get the receiver from the stack.
   __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));

-  // If the object is the holder then we know that it's a global
-  // object which can only happen for contextual calls. In this case,
-  // the receiver cannot be a smi.
-  if (!object.is_identical_to(holder)) {
-    __ JumpIfSmi(edx, miss);
-  }

   // Check that the maps haven't changed.
+  __ JumpIfSmi(edx, miss);
   CheckPrototypes(object, edx, holder, ebx, eax, edi, name, miss);
 }

@@ -2755,15 +2750,9 @@
   //  -- esp[0] : return address
   // -----------------------------------
   Label miss;
-
-  // If the object is the holder then we know that it's a global
-  // object which can only happen for contextual loads. In this case,
-  // the receiver cannot be a smi.
-  if (!object.is_identical_to(holder)) {
-    __ JumpIfSmi(eax, &miss);
-  }

   // Check that the maps haven't changed.
+  __ JumpIfSmi(eax, &miss);
   CheckPrototypes(object, eax, holder, ebx, edx, edi, name, &miss);

   // Get the value from the cell.
=======================================
--- /branches/3.8/src/mips/stub-cache-mips.cc   Mon Jan 23 06:42:48 2012
+++ /branches/3.8/src/mips/stub-cache-mips.cc   Tue Mar 13 08:04:45 2012
@@ -1342,15 +1342,9 @@

   // Get the receiver from the stack.
   __ lw(a0, MemOperand(sp, argc * kPointerSize));
-
-  // If the object is the holder then we know that it's a global
-  // object which can only happen for contextual calls. In this case,
-  // the receiver cannot be a smi.
-  if (!object.is_identical_to(holder)) {
-    __ JumpIfSmi(a0, miss);
-  }

   // Check that the maps haven't changed.
+  __ JumpIfSmi(a0, miss);
   CheckPrototypes(object, a0, holder, a3, a1, t0, name, miss);
 }

@@ -2747,15 +2741,9 @@
   //  -- ra    : return address
   // -----------------------------------
   Label miss;
-
-  // If the object is the holder then we know that it's a global
-  // object which can only happen for contextual calls. In this case,
-  // the receiver cannot be a smi.
-  if (!object.is_identical_to(holder)) {
-    __ JumpIfSmi(a0, &miss);
-  }

   // Check that the map of the global has not changed.
+  __ JumpIfSmi(a0, &miss);
   CheckPrototypes(object, a0, holder, a3, t0, a1, name, &miss);

   // Get the value from the cell.
=======================================
--- /branches/3.8/src/version.cc        Tue Mar  6 06:48:47 2012
+++ /branches/3.8/src/version.cc        Tue Mar 13 08:04:45 2012
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     3
 #define MINOR_VERSION     8
 #define BUILD_NUMBER      9
-#define PATCH_LEVEL       13
+#define PATCH_LEVEL       14
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
 #define IS_CANDIDATE_VERSION 0
=======================================
--- /branches/3.8/src/x64/stub-cache-x64.cc     Mon Jan 23 06:42:48 2012
+++ /branches/3.8/src/x64/stub-cache-x64.cc     Tue Mar 13 08:04:45 2012
@@ -1186,14 +1186,9 @@
   // Get the receiver from the stack.
   __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));

-  // If the object is the holder then we know that it's a global
-  // object which can only happen for contextual calls. In this case,
-  // the receiver cannot be a smi.
-  if (!object.is_identical_to(holder)) {
-    __ JumpIfSmi(rdx, miss);
-  }

   // Check that the maps haven't changed.
+  __ JumpIfSmi(rdx, miss);
   CheckPrototypes(object, rdx, holder, rbx, rax, rdi, name, miss);
 }

@@ -2604,15 +2599,9 @@
   //  -- rsp[0] : return address
   // -----------------------------------
   Label miss;
-
-  // If the object is the holder then we know that it's a global
-  // object which can only happen for contextual loads. In this case,
-  // the receiver cannot be a smi.
-  if (!object.is_identical_to(holder)) {
-    __ JumpIfSmi(rax, &miss);
-  }

   // Check that the maps haven't changed.
+  __ JumpIfSmi(rax, &miss);
   CheckPrototypes(object, rax, holder, rbx, rdx, rdi, name, &miss);

   // Get the value from the cell.

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

Reply via email to