| Index: src/arm64/code-stubs-arm64.cc
|
| diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc
|
| index 6b0306845c9497f32e4df29c63c1862ff82d35ef..43bb45956d4fc0d1e91f398aaca5e001e4392ade 100644
|
| --- a/src/arm64/code-stubs-arm64.cc
|
| +++ b/src/arm64/code-stubs-arm64.cc
|
| @@ -683,7 +683,6 @@ void RestoreRegistersStateStub::Generate(MacroAssembler* masm) {
|
| __ Ret(return_address);
|
| }
|
|
|
| -
|
| void MathPowStub::Generate(MacroAssembler* masm) {
|
| // Stack on entry:
|
| // jssp[0]: Exponent (as a tagged value).
|
| @@ -692,13 +691,10 @@ void MathPowStub::Generate(MacroAssembler* masm) {
|
| // The (tagged) result will be returned in x0, as a heap number.
|
|
|
| Register result_tagged = x0;
|
| - Register base_tagged = x10;
|
| Register exponent_tagged = MathPowTaggedDescriptor::exponent();
|
| DCHECK(exponent_tagged.is(x11));
|
| Register exponent_integer = MathPowIntegerDescriptor::exponent();
|
| DCHECK(exponent_integer.is(x12));
|
| - Register scratch1 = x14;
|
| - Register scratch0 = x15;
|
| Register saved_lr = x19;
|
| FPRegister result_double = d0;
|
| FPRegister base_double = d0;
|
| @@ -709,37 +705,11 @@ void MathPowStub::Generate(MacroAssembler* masm) {
|
|
|
| // A fast-path for integer exponents.
|
| Label exponent_is_smi, exponent_is_integer;
|
| - // Bail out to runtime.
|
| - Label call_runtime;
|
| // Allocate a heap number for the result, and return it.
|
| Label done;
|
|
|
| // Unpack the inputs.
|
| - if (exponent_type() == ON_STACK) {
|
| - Label base_is_smi;
|
| - Label unpack_exponent;
|
| -
|
| - __ Pop(exponent_tagged, base_tagged);
|
| -
|
| - __ JumpIfSmi(base_tagged, &base_is_smi);
|
| - __ JumpIfNotHeapNumber(base_tagged, &call_runtime);
|
| - // base_tagged is a heap number, so load its double value.
|
| - __ Ldr(base_double, FieldMemOperand(base_tagged, HeapNumber::kValueOffset));
|
| - __ B(&unpack_exponent);
|
| - __ Bind(&base_is_smi);
|
| - // base_tagged is a SMI, so untag it and convert it to a double.
|
| - __ SmiUntagToDouble(base_double, base_tagged);
|
| -
|
| - __ Bind(&unpack_exponent);
|
| - // x10 base_tagged The tagged base (input).
|
| - // x11 exponent_tagged The tagged exponent (input).
|
| - // d1 base_double The base as a double.
|
| - __ JumpIfSmi(exponent_tagged, &exponent_is_smi);
|
| - __ JumpIfNotHeapNumber(exponent_tagged, &call_runtime);
|
| - // exponent_tagged is a heap number, so load its double value.
|
| - __ Ldr(exponent_double,
|
| - FieldMemOperand(exponent_tagged, HeapNumber::kValueOffset));
|
| - } else if (exponent_type() == TAGGED) {
|
| + if (exponent_type() == TAGGED) {
|
| __ JumpIfSmi(exponent_tagged, &exponent_is_smi);
|
| __ Ldr(exponent_double,
|
| FieldMemOperand(exponent_tagged, HeapNumber::kValueOffset));
|
| @@ -752,89 +722,11 @@ void MathPowStub::Generate(MacroAssembler* masm) {
|
| __ TryRepresentDoubleAsInt64(exponent_integer, exponent_double,
|
| scratch0_double, &exponent_is_integer);
|
|
|
| - if (exponent_type() == ON_STACK) {
|
| - FPRegister half_double = d3;
|
| - FPRegister minus_half_double = d4;
|
| - // Detect square root case. Crankshaft detects constant +/-0.5 at compile
|
| - // time and uses DoMathPowHalf instead. We then skip this check for
|
| - // non-constant cases of +/-0.5 as these hardly occur.
|
| -
|
| - __ Fmov(minus_half_double, -0.5);
|
| - __ Fmov(half_double, 0.5);
|
| - __ Fcmp(minus_half_double, exponent_double);
|
| - __ Fccmp(half_double, exponent_double, NZFlag, ne);
|
| - // Condition flags at this point:
|
| - // 0.5; nZCv // Identified by eq && pl
|
| - // -0.5: NZcv // Identified by eq && mi
|
| - // other: ?z?? // Identified by ne
|
| - __ B(ne, &call_runtime);
|
| -
|
| - // The exponent is 0.5 or -0.5.
|
| -
|
| - // Given that exponent is known to be either 0.5 or -0.5, the following
|
| - // special cases could apply (according to ECMA-262 15.8.2.13):
|
| - //
|
| - // base.isNaN(): The result is NaN.
|
| - // (base == +INFINITY) || (base == -INFINITY)
|
| - // exponent == 0.5: The result is +INFINITY.
|
| - // exponent == -0.5: The result is +0.
|
| - // (base == +0) || (base == -0)
|
| - // exponent == 0.5: The result is +0.
|
| - // exponent == -0.5: The result is +INFINITY.
|
| - // (base < 0) && base.isFinite(): The result is NaN.
|
| - //
|
| - // Fsqrt (and Fdiv for the -0.5 case) can handle all of those except
|
| - // where base is -INFINITY or -0.
|
| -
|
| - // Add +0 to base. This has no effect other than turning -0 into +0.
|
| - __ Fadd(base_double, base_double, fp_zero);
|
| - // The operation -0+0 results in +0 in all cases except where the
|
| - // FPCR rounding mode is 'round towards minus infinity' (RM). The
|
| - // ARM64 simulator does not currently simulate FPCR (where the rounding
|
| - // mode is set), so test the operation with some debug code.
|
| - if (masm->emit_debug_code()) {
|
| - UseScratchRegisterScope temps(masm);
|
| - Register temp = temps.AcquireX();
|
| - __ Fneg(scratch0_double, fp_zero);
|
| - // Verify that we correctly generated +0.0 and -0.0.
|
| - // bits(+0.0) = 0x0000000000000000
|
| - // bits(-0.0) = 0x8000000000000000
|
| - __ Fmov(temp, fp_zero);
|
| - __ CheckRegisterIsClear(temp, kCouldNotGenerateZero);
|
| - __ Fmov(temp, scratch0_double);
|
| - __ Eor(temp, temp, kDSignMask);
|
| - __ CheckRegisterIsClear(temp, kCouldNotGenerateNegativeZero);
|
| - // Check that -0.0 + 0.0 == +0.0.
|
| - __ Fadd(scratch0_double, scratch0_double, fp_zero);
|
| - __ Fmov(temp, scratch0_double);
|
| - __ CheckRegisterIsClear(temp, kExpectedPositiveZero);
|
| - }
|
| -
|
| - // If base is -INFINITY, make it +INFINITY.
|
| - // * Calculate base - base: All infinities will become NaNs since both
|
| - // -INFINITY+INFINITY and +INFINITY-INFINITY are NaN in ARM64.
|
| - // * If the result is NaN, calculate abs(base).
|
| - __ Fsub(scratch0_double, base_double, base_double);
|
| - __ Fcmp(scratch0_double, 0.0);
|
| - __ Fabs(scratch1_double, base_double);
|
| - __ Fcsel(base_double, scratch1_double, base_double, vs);
|
| -
|
| - // Calculate the square root of base.
|
| - __ Fsqrt(result_double, base_double);
|
| - __ Fcmp(exponent_double, 0.0);
|
| - __ B(ge, &done); // Finish now for exponents of 0.5.
|
| - // Find the inverse for exponents of -0.5.
|
| - __ Fmov(scratch0_double, 1.0);
|
| - __ Fdiv(result_double, scratch0_double, result_double);
|
| - __ B(&done);
|
| - }
|
| -
|
| {
|
| AllowExternalCallThatCantCauseGC scope(masm);
|
| __ Mov(saved_lr, lr);
|
| __ CallCFunction(
|
| - ExternalReference::power_double_double_function(isolate()),
|
| - 0, 2);
|
| + ExternalReference::power_double_double_function(isolate()), 0, 2);
|
| __ Mov(lr, saved_lr);
|
| __ B(&done);
|
| }
|
| @@ -903,34 +795,17 @@ void MathPowStub::Generate(MacroAssembler* masm) {
|
| __ Fcmp(result_double, 0.0);
|
| __ B(&done, ne);
|
|
|
| - if (exponent_type() == ON_STACK) {
|
| - // Bail out to runtime code.
|
| - __ Bind(&call_runtime);
|
| - // Put the arguments back on the stack.
|
| - __ Push(base_tagged, exponent_tagged);
|
| - __ TailCallRuntime(Runtime::kMathPowRT);
|
| -
|
| - // Return.
|
| - __ Bind(&done);
|
| - __ AllocateHeapNumber(result_tagged, &call_runtime, scratch0, scratch1,
|
| - result_double);
|
| - DCHECK(result_tagged.is(x0));
|
| - __ Ret();
|
| - } else {
|
| - AllowExternalCallThatCantCauseGC scope(masm);
|
| - __ Mov(saved_lr, lr);
|
| - __ Fmov(base_double, base_double_copy);
|
| - __ Scvtf(exponent_double, exponent_integer);
|
| - __ CallCFunction(
|
| - ExternalReference::power_double_double_function(isolate()),
|
| - 0, 2);
|
| - __ Mov(lr, saved_lr);
|
| - __ Bind(&done);
|
| - __ Ret();
|
| - }
|
| + AllowExternalCallThatCantCauseGC scope(masm);
|
| + __ Mov(saved_lr, lr);
|
| + __ Fmov(base_double, base_double_copy);
|
| + __ Scvtf(exponent_double, exponent_integer);
|
| + __ CallCFunction(ExternalReference::power_double_double_function(isolate()),
|
| + 0, 2);
|
| + __ Mov(lr, saved_lr);
|
| + __ Bind(&done);
|
| + __ Ret();
|
| }
|
|
|
| -
|
| void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
|
| // It is important that the following stubs are generated in this order
|
| // because pregenerated stubs can only call other pregenerated stubs.
|
|
|