|
|
e93883 |
From 3530fa9cd09f8db8101c4649cab03bcdf760c434 Mon Sep 17 00:00:00 2001
|
|
|
e93883 |
From: Fedor Indutny <fedor@indutny.com>
|
|
|
e93883 |
Date: Fri, 21 Dec 2012 17:52:00 +0000
|
|
|
e93883 |
Subject: [PATCH] deps: backport 4ed5fde4f from v8 upstream
|
|
|
e93883 |
|
|
|
e93883 |
Original commit message:
|
|
|
e93883 |
|
|
|
e93883 |
Fix x64 MathMinMax for negative untagged int32 arguments.
|
|
|
e93883 |
|
|
|
e93883 |
An untagged int32 has zeros in the upper half even if it is negative.
|
|
|
e93883 |
Using cmpq to compare such numbers will incorrectly ignore the sign.
|
|
|
e93883 |
|
|
|
e93883 |
BUG=164442
|
|
|
e93883 |
R=mvstanton@chromium.org
|
|
|
e93883 |
|
|
|
e93883 |
Review URL: https://chromiumcodereview.appspot.com/11665007
|
|
|
e93883 |
|
|
|
e93883 |
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@13273 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
|
|
|
e93883 |
|
|
|
e93883 |
Signed-off-by: Fedor Indutny <fedor@indutny.com>
|
|
|
e93883 |
---
|
|
|
e93883 |
src/x64/lithium-codegen-x64.cc | 6 ++--
|
|
|
e93883 |
test/mjsunit/regress/regress-164442.js | 45 ++++++++++++++++++++++++++
|
|
|
e93883 |
2 files changed, 48 insertions(+), 3 deletions(-)
|
|
|
e93883 |
create mode 100644 test/mjsunit/regress/regress-164442.js
|
|
|
e93883 |
|
|
|
e93883 |
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
|
|
|
e93883 |
index b461e62..ff01f44 100644
|
|
|
e93883 |
--- a/src/x64/lithium-codegen-x64.cc
|
|
|
e93883 |
+++ b/src/x64/lithium-codegen-x64.cc
|
|
|
e93883 |
@@ -1457,17 +1457,17 @@ void LCodeGen::DoMathMinMax(LMathMinMax* instr) {
|
|
|
e93883 |
if (right->IsConstantOperand()) {
|
|
|
e93883 |
Immediate right_imm =
|
|
|
e93883 |
Immediate(ToInteger32(LConstantOperand::cast(right)));
|
|
|
e93883 |
- __ cmpq(left_reg, right_imm);
|
|
|
e93883 |
+ __ cmpl(left_reg, right_imm);
|
|
|
e93883 |
__ j(condition, &return_left, Label::kNear);
|
|
|
e93883 |
__ movq(left_reg, right_imm);
|
|
|
e93883 |
} else if (right->IsRegister()) {
|
|
|
e93883 |
Register right_reg = ToRegister(right);
|
|
|
e93883 |
- __ cmpq(left_reg, right_reg);
|
|
|
e93883 |
+ __ cmpl(left_reg, right_reg);
|
|
|
e93883 |
__ j(condition, &return_left, Label::kNear);
|
|
|
e93883 |
__ movq(left_reg, right_reg);
|
|
|
e93883 |
} else {
|
|
|
e93883 |
Operand right_op = ToOperand(right);
|
|
|
e93883 |
- __ cmpq(left_reg, right_op);
|
|
|
e93883 |
+ __ cmpl(left_reg, right_op);
|
|
|
e93883 |
__ j(condition, &return_left, Label::kNear);
|
|
|
e93883 |
__ movq(left_reg, right_op);
|
|
|
e93883 |
}
|
|
|
e93883 |
diff --git a/test/mjsunit/regress/regress-164442.js b/test/mjsunit/regress/regress-164442.js
|
|
|
e93883 |
new file mode 100644
|
|
|
e93883 |
index 0000000..1160d87
|
|
|
e93883 |
--- /dev/null
|
|
|
e93883 |
+++ b/test/mjsunit/regress/regress-164442.js
|
|
|
e93883 |
@@ -0,0 +1,45 @@
|
|
|
e93883 |
+// Copyright 2012 the V8 project authors. All rights reserved.
|
|
|
e93883 |
+// Redistribution and use in source and binary forms, with or without
|
|
|
e93883 |
+// modification, are permitted provided that the following conditions are
|
|
|
e93883 |
+// met:
|
|
|
e93883 |
+//
|
|
|
e93883 |
+// * Redistributions of source code must retain the above copyright
|
|
|
e93883 |
+// notice, this list of conditions and the following disclaimer.
|
|
|
e93883 |
+// * Redistributions in binary form must reproduce the above
|
|
|
e93883 |
+// copyright notice, this list of conditions and the following
|
|
|
e93883 |
+// disclaimer in the documentation and/or other materials provided
|
|
|
e93883 |
+// with the distribution.
|
|
|
e93883 |
+// * Neither the name of Google Inc. nor the names of its
|
|
|
e93883 |
+// contributors may be used to endorse or promote products derived
|
|
|
e93883 |
+// from this software without specific prior written permission.
|
|
|
e93883 |
+//
|
|
|
e93883 |
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
e93883 |
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
e93883 |
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
e93883 |
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
e93883 |
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
e93883 |
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
e93883 |
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
e93883 |
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
e93883 |
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
e93883 |
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
e93883 |
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
e93883 |
+
|
|
|
e93883 |
+// Flags: --allow-natives-syntax
|
|
|
e93883 |
+
|
|
|
e93883 |
+// Should not take a very long time (n^2 algorithms are bad)
|
|
|
e93883 |
+
|
|
|
e93883 |
+
|
|
|
e93883 |
+function ensureNotNegative(x) {
|
|
|
e93883 |
+ return Math.max(0, x | 0);
|
|
|
e93883 |
+}
|
|
|
e93883 |
+
|
|
|
e93883 |
+
|
|
|
e93883 |
+ensureNotNegative(1);
|
|
|
e93883 |
+ensureNotNegative(2);
|
|
|
e93883 |
+
|
|
|
e93883 |
+%OptimizeFunctionOnNextCall(ensureNotNegative);
|
|
|
e93883 |
+
|
|
|
e93883 |
+var r = ensureNotNegative(-1);
|
|
|
e93883 |
+
|
|
|
e93883 |
+assertEquals(0, r);
|
|
|
e93883 |
--
|
|
|
e93883 |
2.0.3
|
|
|
e93883 |
|