Reviewers: Jakob,
Message:
PTAL
Description:
Fix Smi-based MathMinMax on x64, and reenable smi mode.
BUG=
Please review this at https://chromiumcodereview.appspot.com/20706002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/hydrogen-instructions.h
M src/x64/lithium-codegen-x64.cc
M src/x64/lithium-x64.cc
M test/mjsunit/math-min-max.js
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index
40bbc902458cd70ae79d79cb73f9f3cb85447e98..bf59159164c53b4e41ae52ee2d48d76625017a1b
100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -4792,8 +4792,7 @@ class HMathMinMax: public HArithmeticBinaryOperation {
virtual Representation RepresentationFromInputs() {
Representation left_rep = left()->representation();
Representation right_rep = right()->representation();
- // TODO(verwaest): Initialize to Smi once lithium-codegen has been
fixed.
- Representation result = Representation::Integer32();
+ Representation result = Representation::Smi();
result = result.generalize(left_rep);
result = result.generalize(right_rep);
if (result.IsTagged()) return Representation::Double();
Index: src/x64/lithium-codegen-x64.cc
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index
364c3a1824ef671ee44dcd8f984d4be0363da993..49c58f2500f874a8226a2129c799df45b0e8d25a
100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -1699,7 +1699,7 @@ void LCodeGen::DoMathMinMax(LMathMinMax* instr) {
LOperand* right = instr->right();
ASSERT(left->Equals(instr->result()));
HMathMinMax::Operation operation = instr->hydrogen()->operation();
- if (instr->hydrogen()->representation().IsInteger32()) {
+ if (instr->hydrogen()->representation().IsSmiOrInteger32()) {
Label return_left;
Condition condition = (operation == HMathMinMax::kMathMin)
? less_equal
@@ -1713,12 +1713,20 @@ void LCodeGen::DoMathMinMax(LMathMinMax* instr) {
__ movq(left_reg, right_imm);
} else if (right->IsRegister()) {
Register right_reg = ToRegister(right);
- __ cmpl(left_reg, right_reg);
+ if (instr->hydrogen_value()->representation().IsSmi()) {
+ __ cmpq(left_reg, right_reg);
+ } else {
+ __ cmpl(left_reg, right_reg);
+ }
__ j(condition, &return_left, Label::kNear);
__ movq(left_reg, right_reg);
} else {
Operand right_op = ToOperand(right);
- __ cmpl(left_reg, right_op);
+ if (instr->hydrogen_value()->representation().IsSmi()) {
+ __ cmpq(left_reg, right_op);
+ } else {
+ __ cmpl(left_reg, right_op);
+ }
__ j(condition, &return_left, Label::kNear);
__ movq(left_reg, right_op);
}
Index: src/x64/lithium-x64.cc
diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc
index
d6f05c0a2df80bf90531fda2ed89aae021f9c442..a6f9801c831638a070d0b47ab56fde41666e26b0
100644
--- a/src/x64/lithium-x64.cc
+++ b/src/x64/lithium-x64.cc
@@ -1562,9 +1562,9 @@ LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) {
LOperand* left = NULL;
LOperand* right = NULL;
- if (instr->representation().IsInteger32()) {
- ASSERT(instr->left()->representation().IsInteger32());
- ASSERT(instr->right()->representation().IsInteger32());
+ if (instr->representation().IsSmiOrInteger32()) {
+
ASSERT(instr->left()->representation().Equals(instr->representation()));
+
ASSERT(instr->right()->representation().Equals(instr->representation()));
left = UseRegisterAtStart(instr->BetterLeftOperand());
right = UseOrConstantAtStart(instr->BetterRightOperand());
} else {
Index: test/mjsunit/math-min-max.js
diff --git a/test/mjsunit/math-min-max.js b/test/mjsunit/math-min-max.js
index
e4fd313538f53270747661268a1a1d47dfbc7c39..2686e02091bb7bb5d463e9d380c9c7609723581d
100644
--- a/test/mjsunit/math-min-max.js
+++ b/test/mjsunit/math-min-max.js
@@ -187,3 +187,17 @@ function crankshaft_test_3() {
}
run(crankshaft_test_3);
+
+var o = { a: 1, b: 2 };
+
+function f(o) {
+ return Math.min(o.a, o.b);
+}
+
+assertEquals(1, f(o));
+assertEquals(1, f(o));
+%OptimizeFunctionOnNextCall(f);
+assertEquals(1, f(o));
+o.a = 5;
+o.b = 4;
+assertEquals(4, f(o));
--
--
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.