Revision: 15905
Author: [email protected]
Date: Fri Jul 26 05:06:22 2013
Log: Fix Smi-based MathMinMax on x64, and reenable smi mode.
BUG=
[email protected]
Review URL: https://chromiumcodereview.appspot.com/20706002
http://code.google.com/p/v8/source/detail?r=15905
Modified:
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
/branches/bleeding_edge/src/x64/lithium-x64.cc
/branches/bleeding_edge/test/mjsunit/math-min-max.js
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Fri Jul 26 02:00:43
2013
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Fri Jul 26 05:06:22
2013
@@ -4792,8 +4792,7 @@
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();
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Thu Jul 25
05:22:23 2013
+++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Fri Jul 26
05:06:22 2013
@@ -1699,7 +1699,7 @@
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
@@ -1708,17 +1708,26 @@
if (right->IsConstantOperand()) {
Immediate right_imm =
Immediate(ToInteger32(LConstantOperand::cast(right)));
+ ASSERT(!instr->hydrogen_value()->representation().IsSmi());
__ cmpl(left_reg, right_imm);
__ j(condition, &return_left, Label::kNear);
__ 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);
}
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc Thu Jul 25 05:22:23 2013
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc Fri Jul 26 05:06:22 2013
@@ -1562,9 +1562,9 @@
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 {
=======================================
--- /branches/bleeding_edge/test/mjsunit/math-min-max.js Mon Feb 20
05:21:15 2012
+++ /branches/bleeding_edge/test/mjsunit/math-min-max.js Fri Jul 26
05:06:22 2013
@@ -177,6 +177,21 @@
run(crankshaft_test_2);
+var o = { a: 1, b: 2 };
+
+// Test smi-based Math.min.
+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));
+
// Test overriding Math.min and Math.max
Math.min = function(a, b) { return a + b; }
Math.max = function(a, b) { return a - b; }
--
--
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.