diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index bfe6da0ef4..f62ac859b1 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -1476,11 +1476,11 @@ void MathPowStub::Generate(MacroAssembler* masm) { const Register exponent = r2; const Register heapnumbermap = r5; const Register heapnumber = r0; - const DwVfpRegister double_base = d1; - const DwVfpRegister double_exponent = d2; - const DwVfpRegister double_result = d3; - const DwVfpRegister double_scratch = d0; - const SwVfpRegister single_scratch = s0; + const DwVfpRegister double_base = d0; + const DwVfpRegister double_exponent = d1; + const DwVfpRegister double_result = d2; + const DwVfpRegister double_scratch = d3; + const SwVfpRegister single_scratch = s6; const Register scratch = r9; const Register scratch2 = r4; diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index 2f34d6915f..7c1f65ffc3 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -758,13 +758,10 @@ LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, ASSERT(instr->left()->representation().IsDouble()); ASSERT(instr->right()->representation().IsDouble()); if (op == Token::MOD) { - LOperand* left = UseFixedDouble(instr->left(), d1); - LOperand* right = UseFixedDouble(instr->right(), d2); + LOperand* left = UseFixedDouble(instr->left(), d0); + LOperand* right = UseFixedDouble(instr->right(), d1); LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); - // We call a C function for double modulo. It can't trigger a GC. We need - // to use fixed result register for the call. - // TODO(fschneider): Allow any register as input registers. - return MarkAsCall(DefineFixedDouble(result, d1), instr); + return MarkAsCall(DefineFixedDouble(result, d0), instr); } else { LOperand* left = UseRegisterAtStart(instr->left()); LOperand* right = UseRegisterAtStart(instr->right()); @@ -1269,17 +1266,16 @@ LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) { LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) { - LOperand* input = UseRegister(instr->value()); + LOperand* input = UseRegisterAtStart(instr->value()); LMathSqrt* result = new(zone()) LMathSqrt(input); return DefineAsRegister(result); } LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) { - LOperand* input = UseFixedDouble(instr->value(), d2); - LOperand* temp = FixedTemp(d3); - LMathPowHalf* result = new(zone()) LMathPowHalf(input, temp); - return DefineFixedDouble(result, d2); + LOperand* input = UseRegisterAtStart(instr->value()); + LMathPowHalf* result = new(zone()) LMathPowHalf(input); + return DefineAsRegister(result); } @@ -1718,12 +1714,12 @@ LInstruction* LChunkBuilder::DoPower(HPower* instr) { // We need to use fixed result register for the call. Representation exponent_type = instr->right()->representation(); ASSERT(instr->left()->representation().IsDouble()); - LOperand* left = UseFixedDouble(instr->left(), d1); + LOperand* left = UseFixedDouble(instr->left(), d0); LOperand* right = exponent_type.IsDouble() ? - UseFixedDouble(instr->right(), d2) : + UseFixedDouble(instr->right(), d1) : UseFixed(instr->right(), r2); LPower* result = new(zone()) LPower(left, right); - return MarkAsCall(DefineFixedDouble(result, d3), + return MarkAsCall(DefineFixedDouble(result, d2), instr, CAN_DEOPTIMIZE_EAGERLY); } diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h index 72932ded16..19e26ba383 100644 --- a/src/arm/lithium-arm.h +++ b/src/arm/lithium-arm.h @@ -886,15 +886,13 @@ class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> { }; -class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 1> { +class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> { public: - LMathPowHalf(LOperand* value, LOperand* temp) { + explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; - temps_[0] = temp; } LOperand* value() { return inputs_[0]; } - LOperand* temp() { return temps_[0]; } DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half") }; diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 164ee553da..5aebadaef3 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -2164,9 +2164,6 @@ void LCodeGen::DoArithmeticD(LArithmeticD* instr) { __ vdiv(result, left, right); break; case Token::MOD: { - // Save r0-r3 on the stack. - __ stm(db_w, sp, r0.bit() | r1.bit() | r2.bit() | r3.bit()); - __ PrepareCallCFunction(0, 2, scratch0()); __ SetCallCDoubleArguments(left, right); __ CallCFunction( @@ -2174,9 +2171,6 @@ void LCodeGen::DoArithmeticD(LArithmeticD* instr) { 0, 2); // Move the result in the double result register. __ GetCFunctionDoubleResult(result); - - // Restore r0-r3. - __ ldm(ia_w, sp, r0.bit() | r1.bit() | r2.bit() | r3.bit()); break; } default: @@ -3903,7 +3897,7 @@ void LCodeGen::DoMathSqrt(LMathSqrt* instr) { void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) { DwVfpRegister input = ToDoubleRegister(instr->value()); DwVfpRegister result = ToDoubleRegister(instr->result()); - DwVfpRegister temp = ToDoubleRegister(instr->temp()); + DwVfpRegister temp = double_scratch0(); // Note that according to ECMA-262 15.8.2.13: // Math.pow(-Infinity, 0.5) == Infinity @@ -3926,11 +3920,11 @@ void LCodeGen::DoPower(LPower* instr) { // Having marked this as a call, we can use any registers. // Just make sure that the input/output registers are the expected ones. ASSERT(!instr->right()->IsDoubleRegister() || - ToDoubleRegister(instr->right()).is(d2)); + ToDoubleRegister(instr->right()).is(d1)); ASSERT(!instr->right()->IsRegister() || ToRegister(instr->right()).is(r2)); - ASSERT(ToDoubleRegister(instr->left()).is(d1)); - ASSERT(ToDoubleRegister(instr->result()).is(d3)); + ASSERT(ToDoubleRegister(instr->left()).is(d0)); + ASSERT(ToDoubleRegister(instr->result()).is(d2)); if (exponent_type.IsSmi()) { MathPowStub stub(MathPowStub::TAGGED); diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc index 8bb1cb19a0..66894ddeb0 100644 --- a/src/arm/macro-assembler-arm.cc +++ b/src/arm/macro-assembler-arm.cc @@ -3484,9 +3484,8 @@ void MacroAssembler::PrepareCallCFunction(int num_reg_arguments, void MacroAssembler::SetCallCDoubleArguments(DwVfpRegister dreg) { - if (use_eabi_hardfloat()) { - Move(d0, dreg); - } else { + ASSERT(dreg.is(d0)); + if (!use_eabi_hardfloat()) { vmov(r0, r1, dreg); } } @@ -3494,16 +3493,9 @@ void MacroAssembler::SetCallCDoubleArguments(DwVfpRegister dreg) { void MacroAssembler::SetCallCDoubleArguments(DwVfpRegister dreg1, DwVfpRegister dreg2) { - if (use_eabi_hardfloat()) { - if (dreg2.is(d0)) { - ASSERT(!dreg1.is(d1)); - Move(d1, dreg2); - Move(d0, dreg1); - } else { - Move(d0, dreg1); - Move(d1, dreg2); - } - } else { + ASSERT(dreg1.is(d0)); + ASSERT(dreg2.is(d1)); + if (!use_eabi_hardfloat()) { vmov(r0, r1, dreg1); vmov(r2, r3, dreg2); } @@ -3512,8 +3504,8 @@ void MacroAssembler::SetCallCDoubleArguments(DwVfpRegister dreg1, void MacroAssembler::SetCallCDoubleArguments(DwVfpRegister dreg, Register reg) { + ASSERT(dreg.is(d0)); if (use_eabi_hardfloat()) { - Move(d0, dreg); Move(r0, reg); } else { Move(r2, reg);