Reviewers: Søren Gjesse,

Description:
ARM: Implement DoMathRound in the lithium code generator.

Please review this at http://codereview.chromium.org/6519051/

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

Affected files:
  M src/arm/lithium-arm.cc
  M src/arm/lithium-codegen-arm.h
  M src/arm/lithium-codegen-arm.cc


Index: src/arm/lithium-arm.cc
diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc
index 786ceeb3cac0b52afa0500645679d174ee08ca5d..d02b337371418437aab33727727c3efbd5e35fa6 100644
--- a/src/arm/lithium-arm.cc
+++ b/src/arm/lithium-arm.cc
@@ -1204,8 +1204,7 @@ LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
     case kMathSqrt:
       return DefineSameAsFirst(result);
     case kMathRound:
-      Abort("MathRound LUnaryMathOperation not implemented");
-      return NULL;
+      return AssignEnvironment(DefineAsRegister(result));
     case kMathPowHalf:
       Abort("MathPowHalf LUnaryMathOperation not implemented");
       return NULL;
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;
Index: src/arm/lithium-codegen-arm.h
diff --git a/src/arm/lithium-codegen-arm.h b/src/arm/lithium-codegen-arm.h
index ef1f8f7700dca1b9058b954da480b518a6634e90..efb2fd3ae422f000b7b4168cfcb1679da3e3faf9 100644
--- a/src/arm/lithium-codegen-arm.h
+++ b/src/arm/lithium-codegen-arm.h
@@ -229,6 +229,7 @@ class LCodeGen BASE_EMBEDDED {
                        Register scratch1,
                        Register scratch2);
   void DoMathFloor(LUnaryMathOperation* instr);
+  void DoMathRound(LUnaryMathOperation* instr);
   void DoMathSqrt(LUnaryMathOperation* instr);

   // Support for recording safepoint and position information.


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to