Reviewers: titzer,

Message:
PTAL.

Description:
ia32: Fix comparisons of two constant double operands when exactly one of them
is in new space.

Please review this at https://codereview.chromium.org/46883008/

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

Affected files (+30, -11 lines):
  M src/ia32/lithium-ia32.cc
  A + test/mjsunit/regress/regress-compare-constant-doubles.js


Index: src/ia32/lithium-ia32.cc
diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc
index 0800823fdb3e2401d9cda7c6d34eb26fa7f1500a..b4ebe6dea4ad1ba74d059f50d8487e4bcc5a565f 100644
--- a/src/ia32/lithium-ia32.cc
+++ b/src/ia32/lithium-ia32.cc
@@ -1728,9 +1728,12 @@ LInstruction* LChunkBuilder::DoCompareNumericAndBranch(
     ASSERT(instr->right()->representation().IsDouble());
     LOperand* left;
     LOperand* right;
-    if (instr->left()->IsConstant() && instr->right()->IsConstant()) {
-      left = UseRegisterOrConstantAtStart(instr->left());
-      right = UseRegisterOrConstantAtStart(instr->right());
+    if (CanBeImmediateConstant(instr->left()) &&
+        CanBeImmediateConstant(instr->right())) {
+      // The code generator requires either both inputs to be constant
+      // operands, or neither.
+      left = UseConstant(instr->left());
+      right = UseConstant(instr->right());
     } else {
       left = UseRegisterAtStart(instr->left());
       right = UseRegisterAtStart(instr->right());
Index: test/mjsunit/regress/regress-compare-constant-doubles.js
diff --git a/test/mjsunit/constant-compare-nil-value.js b/test/mjsunit/regress/regress-compare-constant-doubles.js
similarity index 78%
copy from test/mjsunit/constant-compare-nil-value.js
copy to test/mjsunit/regress/regress-compare-constant-doubles.js
index 9f5b2adb063abc0c7920d8dee30edb7ee6eb1ff9..0f8ffe307d154178993da4db370c7201552504a7 100644
--- a/test/mjsunit/constant-compare-nil-value.js
+++ b/test/mjsunit/regress/regress-compare-constant-doubles.js
@@ -27,16 +27,32 @@

 // Flags: --allow-natives-syntax

-function inlined() {
-    return 1;
-}
+var left = 1.5;
+var right;
+
+var keepalive;

 function foo() {
-    if ((inlined() + 0.5) == null) return "null";
-    return "non-null";
+  // Fill XMM registers with cruft.
+  var a1 = Math.sin(1) + 10;
+  var a2 = a1 + 1;
+  var a3 = a2 + 1;
+  var a4 = a3 + 1;
+  var a5 = a4 + 1;
+  var a6 = a5 + 1;
+  keepalive = [a1, a2, a3, a4, a5, a6];
+
+  // Actual test.
+  if (left < right) return "ok";
+  return "bad";
+}
+
+function prepare(base) {
+  right = 0.5 * base;
 }

-assertEquals("non-null", foo());
-assertEquals("non-null", foo());
+prepare(21);
+assertEquals("ok", foo());
+assertEquals("ok", foo());
 %OptimizeFunctionOnNextCall(foo);
-assertEquals("non-null", foo());
+assertEquals("ok", foo());


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to