Index: src/arm/lithium-codegen-arm.cc |
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc |
index 2c916f6ad67b847376a3656a5189f25d1cb0c18c..e85d71bab98759991875133f7ae1151debe3cf84 100644 |
--- a/src/arm/lithium-codegen-arm.cc |
+++ b/src/arm/lithium-codegen-arm.cc |
@@ -2854,6 +2854,30 @@ void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { |
} |
+void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { |
+ DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); |
+ Register result = ToRegister(instr->result()); |
+ Register scratch1 = scratch0(); |
+ Register scratch2 = result; |
+ EmitVFPTruncate(kRoundToNearest, |
+ double_scratch0().low(), |
+ input, |
+ scratch1, |
+ scratch2); |
+ DeoptimizeIf(ne, instr->environment()); |
+ __ vmov(result, double_scratch0().low()); |
+ |
+ // Test for -0. |
+ Label done; |
+ __ cmp(result, Operand(0)); |
+ __ b(ne, &done); |
+ __ vmov(scratch1, input.high()); |
+ __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
+ DeoptimizeIf(ne, instr->environment()); |
+ __ bind(&done); |
+} |
+ |
+ |
void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { |
DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); |
ASSERT(ToDoubleRegister(instr->result()).is(input)); |
@@ -2869,6 +2893,9 @@ void LCodeGen::DoUnaryMathOperation(LUnaryMathOperation* instr) { |
case kMathFloor: |
DoMathFloor(instr); |
break; |
+ case kMathRound: |
+ DoMathRound(instr); |
+ break; |
case kMathSqrt: |
DoMathSqrt(instr); |
break; |