From 5df90d2c7430ded9dcd828123728934756050677 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Wed, 4 Dec 2013 11:39:24 +0000 Subject: [PATCH] Remove unused trigonometric code. R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/104203003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18256 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/code-stubs-arm.cc | 15 ------ src/arm/codegen-arm.cc | 3 -- src/arm/lithium-arm.cc | 25 ---------- src/arm/lithium-arm.h | 42 ---------------- src/arm/lithium-codegen-arm.cc | 33 ------------- src/assembler.cc | 39 --------------- src/assembler.h | 3 -- src/heap-inl.h | 15 +----- src/heap.h | 2 +- src/hydrogen-instructions.cc | 13 ----- src/hydrogen-instructions.h | 6 --- src/ia32/code-stubs-ia32.cc | 96 ++----------------------------------- src/ia32/codegen-ia32.cc | 3 -- src/ia32/lithium-codegen-ia32.cc | 33 ------------- src/ia32/lithium-ia32.cc | 24 ---------- src/ia32/lithium-ia32.h | 42 ---------------- src/mips/code-stubs-mips.cc | 17 ------- src/mips/codegen-mips.cc | 3 -- src/mips/lithium-codegen-mips.cc | 33 ------------- src/mips/lithium-mips.cc | 24 ---------- src/mips/lithium-mips.h | 42 ---------------- src/objects.h | 6 --- src/platform-posix.cc | 6 --- src/platform-win32.cc | 6 --- src/platform.h | 3 -- src/runtime.cc | 38 ++------------- src/runtime.h | 3 -- src/v8-counters.h | 3 -- src/x64/code-stubs-x64.cc | 100 ++------------------------------------- src/x64/codegen-x64.cc | 3 -- src/x64/lithium-codegen-x64.cc | 33 ------------- src/x64/lithium-x64.cc | 24 ---------- src/x64/lithium-x64.h | 42 ---------------- 33 files changed, 14 insertions(+), 766 deletions(-) diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index cc2dbdc..4eb08a1 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -1418,18 +1418,6 @@ void TranscendentalCacheStub::GenerateCallCFunction(MacroAssembler* masm, } AllowExternalCallThatCantCauseGC scope(masm); switch (type_) { - case TranscendentalCache::SIN: - __ CallCFunction(ExternalReference::math_sin_double_function(isolate), - 0, 1); - break; - case TranscendentalCache::COS: - __ CallCFunction(ExternalReference::math_cos_double_function(isolate), - 0, 1); - break; - case TranscendentalCache::TAN: - __ CallCFunction(ExternalReference::math_tan_double_function(isolate), - 0, 1); - break; case TranscendentalCache::LOG: __ CallCFunction(ExternalReference::math_log_double_function(isolate), 0, 1); @@ -1445,9 +1433,6 @@ void TranscendentalCacheStub::GenerateCallCFunction(MacroAssembler* masm, Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() { switch (type_) { // Add more cases when necessary. - case TranscendentalCache::SIN: return Runtime::kMath_sin; - case TranscendentalCache::COS: return Runtime::kMath_cos; - case TranscendentalCache::TAN: return Runtime::kMath_tan; case TranscendentalCache::LOG: return Runtime::kMath_log; default: UNIMPLEMENTED(); diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc index 238d34e..97bf622 100644 --- a/src/arm/codegen-arm.cc +++ b/src/arm/codegen-arm.cc @@ -39,9 +39,6 @@ namespace internal { UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) { switch (type) { - case TranscendentalCache::SIN: return &sin; - case TranscendentalCache::COS: return &cos; - case TranscendentalCache::TAN: return &tan; case TranscendentalCache::LOG: return &log; default: UNIMPLEMENTED(); } diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index 6119b24..416512a 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -1187,9 +1187,6 @@ LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { case kMathRound: return DoMathRound(instr); case kMathAbs: return DoMathAbs(instr); case kMathLog: return DoMathLog(instr); - case kMathSin: return DoMathSin(instr); - case kMathCos: return DoMathCos(instr); - case kMathTan: return DoMathTan(instr); case kMathExp: return DoMathExp(instr); case kMathSqrt: return DoMathSqrt(instr); case kMathPowHalf: return DoMathPowHalf(instr); @@ -1233,27 +1230,6 @@ LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) { } -LInstruction* LChunkBuilder::DoMathSin(HUnaryMathOperation* instr) { - LOperand* input = UseFixedDouble(instr->value(), d2); - LMathSin* result = new(zone()) LMathSin(input); - return MarkAsCall(DefineFixedDouble(result, d2), instr); -} - - -LInstruction* LChunkBuilder::DoMathCos(HUnaryMathOperation* instr) { - LOperand* input = UseFixedDouble(instr->value(), d2); - LMathCos* result = new(zone()) LMathCos(input); - return MarkAsCall(DefineFixedDouble(result, d2), instr); -} - - -LInstruction* LChunkBuilder::DoMathTan(HUnaryMathOperation* instr) { - LOperand* input = UseFixedDouble(instr->value(), d2); - LMathTan* result = new(zone()) LMathTan(input); - return MarkAsCall(DefineFixedDouble(result, d2), instr); -} - - LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) { ASSERT(instr->representation().IsDouble()); ASSERT(instr->value()->representation().IsDouble()); @@ -2677,5 +2653,4 @@ LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); } - } } // namespace v8::internal diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h index cfafc06..4bac4b1 100644 --- a/src/arm/lithium-arm.h +++ b/src/arm/lithium-arm.h @@ -131,7 +131,6 @@ class LCodeGen; V(LoadNamedGeneric) \ V(MapEnumLength) \ V(MathAbs) \ - V(MathCos) \ V(MathExp) \ V(MathFloor) \ V(MathFloorOfDiv) \ @@ -139,9 +138,7 @@ class LCodeGen; V(MathMinMax) \ V(MathPowHalf) \ V(MathRound) \ - V(MathSin) \ V(MathSqrt) \ - V(MathTan) \ V(ModI) \ V(MulI) \ V(MultiplyAddD) \ @@ -816,42 +813,6 @@ class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> { }; -class LMathSin V8_FINAL : public LTemplateInstruction<1, 1, 0> { - public: - explicit LMathSin(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(MathSin, "math-sin") -}; - - -class LMathCos V8_FINAL : public LTemplateInstruction<1, 1, 0> { - public: - explicit LMathCos(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(MathCos, "math-cos") -}; - - -class LMathTan V8_FINAL : public LTemplateInstruction<1, 1, 0> { - public: - explicit LMathTan(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(MathTan, "math-tan") -}; - - class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 3> { public: LMathExp(LOperand* value, @@ -2778,9 +2739,6 @@ class LChunkBuilder V8_FINAL BASE_EMBEDDED { LInstruction* DoMathRound(HUnaryMathOperation* instr); LInstruction* DoMathAbs(HUnaryMathOperation* instr); LInstruction* DoMathLog(HUnaryMathOperation* instr); - LInstruction* DoMathSin(HUnaryMathOperation* instr); - LInstruction* DoMathCos(HUnaryMathOperation* instr); - LInstruction* DoMathTan(HUnaryMathOperation* instr); LInstruction* DoMathExp(HUnaryMathOperation* instr); LInstruction* DoMathSqrt(HUnaryMathOperation* instr); LInstruction* DoMathPowHalf(HUnaryMathOperation* instr); diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index b9f1a5f..8f1c9c0 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -3951,39 +3951,6 @@ void LCodeGen::DoMathLog(LMathLog* instr) { } -void LCodeGen::DoMathTan(LMathTan* instr) { - ASSERT(ToDoubleRegister(instr->result()).is(d2)); - // Set the context register to a GC-safe fake value. Clobbering it is - // OK because this instruction is marked as a call. - __ mov(cp, Operand::Zero()); - TranscendentalCacheStub stub(TranscendentalCache::TAN, - TranscendentalCacheStub::UNTAGGED); - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); -} - - -void LCodeGen::DoMathCos(LMathCos* instr) { - ASSERT(ToDoubleRegister(instr->result()).is(d2)); - // Set the context register to a GC-safe fake value. Clobbering it is - // OK because this instruction is marked as a call. - __ mov(cp, Operand::Zero()); - TranscendentalCacheStub stub(TranscendentalCache::COS, - TranscendentalCacheStub::UNTAGGED); - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); -} - - -void LCodeGen::DoMathSin(LMathSin* instr) { - ASSERT(ToDoubleRegister(instr->result()).is(d2)); - // Set the context register to a GC-safe fake value. Clobbering it is - // OK because this instruction is marked as a call. - __ mov(cp, Operand::Zero()); - TranscendentalCacheStub stub(TranscendentalCache::SIN, - TranscendentalCacheStub::UNTAGGED); - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { ASSERT(ToRegister(instr->context()).is(cp)); ASSERT(ToRegister(instr->function()).is(r1)); diff --git a/src/assembler.cc b/src/assembler.cc index febae63..c8d16ae 100644 --- a/src/assembler.cc +++ b/src/assembler.cc @@ -1418,50 +1418,11 @@ static double mod_two_doubles(double x, double y) { } -static double math_sin_double(double x) { - return sin(x); -} - - -static double math_cos_double(double x) { - return cos(x); -} - - -static double math_tan_double(double x) { - return tan(x); -} - - static double math_log_double(double x) { return log(x); } -ExternalReference ExternalReference::math_sin_double_function( - Isolate* isolate) { - return ExternalReference(Redirect(isolate, - FUNCTION_ADDR(math_sin_double), - BUILTIN_FP_CALL)); -} - - -ExternalReference ExternalReference::math_cos_double_function( - Isolate* isolate) { - return ExternalReference(Redirect(isolate, - FUNCTION_ADDR(math_cos_double), - BUILTIN_FP_CALL)); -} - - -ExternalReference ExternalReference::math_tan_double_function( - Isolate* isolate) { - return ExternalReference(Redirect(isolate, - FUNCTION_ADDR(math_tan_double), - BUILTIN_FP_CALL)); -} - - ExternalReference ExternalReference::math_log_double_function( Isolate* isolate) { return ExternalReference(Redirect(isolate, diff --git a/src/assembler.h b/src/assembler.h index 0c706c4..6c06262 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -811,9 +811,6 @@ class ExternalReference BASE_EMBEDDED { static ExternalReference address_of_the_hole_nan(); static ExternalReference address_of_uint32_bias(); - static ExternalReference math_sin_double_function(Isolate* isolate); - static ExternalReference math_cos_double_function(Isolate* isolate); - static ExternalReference math_tan_double_function(Isolate* isolate); static ExternalReference math_log_double_function(Isolate* isolate); static ExternalReference math_exp_constants(int constant_index); diff --git a/src/heap-inl.h b/src/heap-inl.h index 525c634..3229aee 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -763,23 +763,10 @@ Address TranscendentalCache::cache_array_address() { double TranscendentalCache::SubCache::Calculate(double input) { switch (type_) { - case ACOS: - return acos(input); - case ASIN: - return asin(input); - case ATAN: - return atan(input); - case COS: - return fast_cos(input); - case EXP: - return exp(input); case LOG: return fast_log(input); - case SIN: - return fast_sin(input); - case TAN: - return fast_tan(input); default: + UNREACHABLE(); return 0.0; // Never happens. } } diff --git a/src/heap.h b/src/heap.h index 1c8e0e1..c8ccb7f 100644 --- a/src/heap.h +++ b/src/heap.h @@ -2904,7 +2904,7 @@ class RegExpResultsCache { class TranscendentalCache { public: - enum Type {ACOS, ASIN, ATAN, COS, EXP, LOG, SIN, TAN, kNumberOfCaches}; + enum Type { LOG, kNumberOfCaches}; static const int kTranscendentalTypeBits = 3; STATIC_ASSERT((1 << kTranscendentalTypeBits) >= kNumberOfCaches); diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 91bd01e..3ab9576 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -1119,9 +1119,6 @@ const char* HUnaryMathOperation::OpName() const { case kMathRound: return "round"; case kMathAbs: return "abs"; case kMathLog: return "log"; - case kMathSin: return "sin"; - case kMathCos: return "cos"; - case kMathTan: return "tan"; case kMathExp: return "exp"; case kMathSqrt: return "sqrt"; case kMathPowHalf: return "pow-half"; @@ -3859,10 +3856,6 @@ HInstruction* HUnaryMathOperation::New( } if (std::isinf(d)) { // +Infinity and -Infinity. switch (op) { - case kMathSin: - case kMathCos: - case kMathTan: - return H_CONSTANT_DOUBLE(OS::nan_value()); case kMathExp: return H_CONSTANT_DOUBLE((d > 0.0) ? d : 0.0); case kMathLog: @@ -3880,12 +3873,6 @@ HInstruction* HUnaryMathOperation::New( } } switch (op) { - case kMathSin: - return H_CONSTANT_DOUBLE(fast_sin(d)); - case kMathCos: - return H_CONSTANT_DOUBLE(fast_cos(d)); - case kMathTan: - return H_CONSTANT_DOUBLE(fast_tan(d)); case kMathExp: return H_CONSTANT_DOUBLE(fast_exp(d)); case kMathLog: diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 30a6b20..23dbbd2 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -2638,9 +2638,6 @@ class HUnaryMathOperation V8_FINAL : public HTemplateInstruction<2> { case kMathPowHalf: case kMathLog: case kMathExp: - case kMathSin: - case kMathCos: - case kMathTan: return Representation::Double(); case kMathAbs: return representation(); @@ -2685,9 +2682,6 @@ class HUnaryMathOperation V8_FINAL : public HTemplateInstruction<2> { SetGVNFlag(kChangesNewSpacePromotion); break; case kMathLog: - case kMathSin: - case kMathCos: - case kMathTan: set_representation(Representation::Double()); // These operations use the TranscendentalCache, so they may allocate. SetGVNFlag(kChangesNewSpacePromotion); diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc index 0481814..4633400 100644 --- a/src/ia32/code-stubs-ia32.cc +++ b/src/ia32/code-stubs-ia32.cc @@ -896,9 +896,6 @@ void TranscendentalCacheStub::Generate(MacroAssembler* masm) { Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() { switch (type_) { - case TranscendentalCache::SIN: return Runtime::kMath_sin; - case TranscendentalCache::COS: return Runtime::kMath_cos; - case TranscendentalCache::TAN: return Runtime::kMath_tan; case TranscendentalCache::LOG: return Runtime::kMath_log; default: UNIMPLEMENTED(); @@ -913,95 +910,10 @@ void TranscendentalCacheStub::GenerateOperation( // Input value is on FP stack, and also in ebx/edx. // Input value is possibly in xmm1. // Address of result (a newly allocated HeapNumber) may be in eax. - if (type == TranscendentalCache::SIN || - type == TranscendentalCache::COS || - type == TranscendentalCache::TAN) { - // Both fsin and fcos require arguments in the range +/-2^63 and - // return NaN for infinities and NaN. They can share all code except - // the actual fsin/fcos operation. - Label in_range, done; - // If argument is outside the range -2^63..2^63, fsin/cos doesn't - // work. We must reduce it to the appropriate range. - __ mov(edi, edx); - __ and_(edi, Immediate(0x7ff00000)); // Exponent only. - int supported_exponent_limit = - (63 + HeapNumber::kExponentBias) << HeapNumber::kExponentShift; - __ cmp(edi, Immediate(supported_exponent_limit)); - __ j(below, &in_range, Label::kNear); - // Check for infinity and NaN. Both return NaN for sin. - __ cmp(edi, Immediate(0x7ff00000)); - Label non_nan_result; - __ j(not_equal, &non_nan_result, Label::kNear); - // Input is +/-Infinity or NaN. Result is NaN. - __ fstp(0); - // NaN is represented by 0x7ff8000000000000. - __ push(Immediate(0x7ff80000)); - __ push(Immediate(0)); - __ fld_d(Operand(esp, 0)); - __ add(esp, Immediate(2 * kPointerSize)); - __ jmp(&done, Label::kNear); - - __ bind(&non_nan_result); - - // Use fpmod to restrict argument to the range +/-2*PI. - __ mov(edi, eax); // Save eax before using fnstsw_ax. - __ fldpi(); - __ fadd(0); - __ fld(1); - // FPU Stack: input, 2*pi, input. - { - Label no_exceptions; - __ fwait(); - __ fnstsw_ax(); - // Clear if Illegal Operand or Zero Division exceptions are set. - __ test(eax, Immediate(5)); - __ j(zero, &no_exceptions, Label::kNear); - __ fnclex(); - __ bind(&no_exceptions); - } - - // Compute st(0) % st(1) - { - Label partial_remainder_loop; - __ bind(&partial_remainder_loop); - __ fprem1(); - __ fwait(); - __ fnstsw_ax(); - __ test(eax, Immediate(0x400 /* C2 */)); - // If C2 is set, computation only has partial result. Loop to - // continue computation. - __ j(not_zero, &partial_remainder_loop); - } - // FPU Stack: input, 2*pi, input % 2*pi - __ fstp(2); - __ fstp(0); - __ mov(eax, edi); // Restore eax (allocated HeapNumber pointer). - - // FPU Stack: input % 2*pi - __ bind(&in_range); - switch (type) { - case TranscendentalCache::SIN: - __ fsin(); - break; - case TranscendentalCache::COS: - __ fcos(); - break; - case TranscendentalCache::TAN: - // FPTAN calculates tangent onto st(0) and pushes 1.0 onto the - // FP register stack. - __ fptan(); - __ fstp(0); // Pop FP register stack. - break; - default: - UNREACHABLE(); - } - __ bind(&done); - } else { - ASSERT(type == TranscendentalCache::LOG); - __ fldln2(); - __ fxch(); - __ fyl2x(); - } + ASSERT(type == TranscendentalCache::LOG); + __ fldln2(); + __ fxch(); + __ fyl2x(); } diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc index ab4029d..84187b0 100644 --- a/src/ia32/codegen-ia32.cc +++ b/src/ia32/codegen-ia32.cc @@ -66,9 +66,6 @@ UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) { if (buffer == NULL) { // Fallback to library function if function cannot be created. switch (type) { - case TranscendentalCache::SIN: return &sin; - case TranscendentalCache::COS: return &cos; - case TranscendentalCache::TAN: return &tan; case TranscendentalCache::LOG: return &log; default: UNIMPLEMENTED(); } diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 28ae469..bba3aca 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -4197,39 +4197,6 @@ void LCodeGen::DoMathExp(LMathExp* instr) { } -void LCodeGen::DoMathTan(LMathTan* instr) { - ASSERT(ToDoubleRegister(instr->result()).is(xmm1)); - // Set the context register to a GC-safe fake value. Clobbering it is - // OK because this instruction is marked as a call. - __ Set(esi, Immediate(0)); - TranscendentalCacheStub stub(TranscendentalCache::TAN, - TranscendentalCacheStub::UNTAGGED); - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); -} - - -void LCodeGen::DoMathCos(LMathCos* instr) { - ASSERT(ToDoubleRegister(instr->result()).is(xmm1)); - // Set the context register to a GC-safe fake value. Clobbering it is - // OK because this instruction is marked as a call. - __ Set(esi, Immediate(0)); - TranscendentalCacheStub stub(TranscendentalCache::COS, - TranscendentalCacheStub::UNTAGGED); - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); -} - - -void LCodeGen::DoMathSin(LMathSin* instr) { - ASSERT(ToDoubleRegister(instr->result()).is(xmm1)); - // Set the context register to a GC-safe fake value. Clobbering it is - // OK because this instruction is marked as a call. - __ Set(esi, Immediate(0)); - TranscendentalCacheStub stub(TranscendentalCache::SIN, - TranscendentalCacheStub::UNTAGGED); - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { ASSERT(ToRegister(instr->context()).is(esi)); ASSERT(ToRegister(instr->function()).is(edi)); diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index aa35e9d..1f85b48 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -1272,9 +1272,6 @@ LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { case kMathRound: return DoMathRound(instr); case kMathAbs: return DoMathAbs(instr); case kMathLog: return DoMathLog(instr); - case kMathSin: return DoMathSin(instr); - case kMathCos: return DoMathCos(instr); - case kMathTan: return DoMathTan(instr); case kMathExp: return DoMathExp(instr); case kMathSqrt: return DoMathSqrt(instr); case kMathPowHalf: return DoMathPowHalf(instr); @@ -1317,27 +1314,6 @@ LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) { } -LInstruction* LChunkBuilder::DoMathSin(HUnaryMathOperation* instr) { - LOperand* input = UseFixedDouble(instr->value(), xmm1); - LMathSin* result = new(zone()) LMathSin(input); - return MarkAsCall(DefineFixedDouble(result, xmm1), instr); -} - - -LInstruction* LChunkBuilder::DoMathCos(HUnaryMathOperation* instr) { - LOperand* input = UseFixedDouble(instr->value(), xmm1); - LMathCos* result = new(zone()) LMathCos(input); - return MarkAsCall(DefineFixedDouble(result, xmm1), instr); -} - - -LInstruction* LChunkBuilder::DoMathTan(HUnaryMathOperation* instr) { - LOperand* input = UseFixedDouble(instr->value(), xmm1); - LMathTan* result = new(zone()) LMathTan(input); - return MarkAsCall(DefineFixedDouble(result, xmm1), instr); -} - - LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) { ASSERT(instr->representation().IsDouble()); ASSERT(instr->value()->representation().IsDouble()); diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h index ea4fef8..912ec1e 100644 --- a/src/ia32/lithium-ia32.h +++ b/src/ia32/lithium-ia32.h @@ -133,7 +133,6 @@ class LCodeGen; V(LoadRoot) \ V(MapEnumLength) \ V(MathAbs) \ - V(MathCos) \ V(MathExp) \ V(MathFloor) \ V(MathFloorOfDiv) \ @@ -141,9 +140,7 @@ class LCodeGen; V(MathMinMax) \ V(MathPowHalf) \ V(MathRound) \ - V(MathSin) \ V(MathSqrt) \ - V(MathTan) \ V(ModI) \ V(MulI) \ V(NumberTagD) \ @@ -792,42 +789,6 @@ class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> { }; -class LMathSin V8_FINAL : public LTemplateInstruction<1, 1, 0> { - public: - explicit LMathSin(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(MathSin, "math-sin") -}; - - -class LMathCos V8_FINAL : public LTemplateInstruction<1, 1, 0> { - public: - explicit LMathCos(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(MathCos, "math-cos") -}; - - -class LMathTan V8_FINAL : public LTemplateInstruction<1, 1, 0> { - public: - explicit LMathTan(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(MathTan, "math-tan") -}; - - class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> { public: LMathExp(LOperand* value, @@ -2787,9 +2748,6 @@ class LChunkBuilder V8_FINAL BASE_EMBEDDED { LInstruction* DoMathRound(HUnaryMathOperation* instr); LInstruction* DoMathAbs(HUnaryMathOperation* instr); LInstruction* DoMathLog(HUnaryMathOperation* instr); - LInstruction* DoMathSin(HUnaryMathOperation* instr); - LInstruction* DoMathCos(HUnaryMathOperation* instr); - LInstruction* DoMathTan(HUnaryMathOperation* instr); LInstruction* DoMathExp(HUnaryMathOperation* instr); LInstruction* DoMathSqrt(HUnaryMathOperation* instr); LInstruction* DoMathPowHalf(HUnaryMathOperation* instr); diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc index 4c3708c..cd1af91 100644 --- a/src/mips/code-stubs-mips.cc +++ b/src/mips/code-stubs-mips.cc @@ -1467,20 +1467,6 @@ void TranscendentalCacheStub::GenerateCallCFunction(MacroAssembler* masm, AllowExternalCallThatCantCauseGC scope(masm); Isolate* isolate = masm->isolate(); switch (type_) { - case TranscendentalCache::SIN: - __ CallCFunction( - ExternalReference::math_sin_double_function(isolate), - 0, 1); - break; - case TranscendentalCache::COS: - __ CallCFunction( - ExternalReference::math_cos_double_function(isolate), - 0, 1); - break; - case TranscendentalCache::TAN: - __ CallCFunction(ExternalReference::math_tan_double_function(isolate), - 0, 1); - break; case TranscendentalCache::LOG: __ CallCFunction( ExternalReference::math_log_double_function(isolate), @@ -1497,9 +1483,6 @@ void TranscendentalCacheStub::GenerateCallCFunction(MacroAssembler* masm, Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() { switch (type_) { // Add more cases when necessary. - case TranscendentalCache::SIN: return Runtime::kMath_sin; - case TranscendentalCache::COS: return Runtime::kMath_cos; - case TranscendentalCache::TAN: return Runtime::kMath_tan; case TranscendentalCache::LOG: return Runtime::kMath_log; default: UNIMPLEMENTED(); diff --git a/src/mips/codegen-mips.cc b/src/mips/codegen-mips.cc index 3a87c5a..229cc0b 100644 --- a/src/mips/codegen-mips.cc +++ b/src/mips/codegen-mips.cc @@ -39,9 +39,6 @@ namespace internal { UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) { switch (type) { - case TranscendentalCache::SIN: return &sin; - case TranscendentalCache::COS: return &cos; - case TranscendentalCache::TAN: return &tan; case TranscendentalCache::LOG: return &log; default: UNIMPLEMENTED(); } diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 26f446c..b4d9441 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -3874,39 +3874,6 @@ void LCodeGen::DoMathLog(LMathLog* instr) { } -void LCodeGen::DoMathTan(LMathTan* instr) { - ASSERT(ToDoubleRegister(instr->result()).is(f4)); - // Set the context register to a GC-safe fake value. Clobbering it is - // OK because this instruction is marked as a call. - __ mov(cp, zero_reg); - TranscendentalCacheStub stub(TranscendentalCache::TAN, - TranscendentalCacheStub::UNTAGGED); - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); -} - - -void LCodeGen::DoMathCos(LMathCos* instr) { - ASSERT(ToDoubleRegister(instr->result()).is(f4)); - // Set the context register to a GC-safe fake value. Clobbering it is - // OK because this instruction is marked as a call. - __ mov(cp, zero_reg); - TranscendentalCacheStub stub(TranscendentalCache::COS, - TranscendentalCacheStub::UNTAGGED); - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); -} - - -void LCodeGen::DoMathSin(LMathSin* instr) { - ASSERT(ToDoubleRegister(instr->result()).is(f4)); - // Set the context register to a GC-safe fake value. Clobbering it is - // OK because this instruction is marked as a call. - __ mov(cp, zero_reg); - TranscendentalCacheStub stub(TranscendentalCache::SIN, - TranscendentalCacheStub::UNTAGGED); - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { ASSERT(ToRegister(instr->context()).is(cp)); ASSERT(ToRegister(instr->function()).is(a1)); diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index a441ba5..3448792 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -1190,9 +1190,6 @@ LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { case kMathRound: return DoMathRound(instr); case kMathAbs: return DoMathAbs(instr); case kMathLog: return DoMathLog(instr); - case kMathSin: return DoMathSin(instr); - case kMathCos: return DoMathCos(instr); - case kMathTan: return DoMathTan(instr); case kMathExp: return DoMathExp(instr); case kMathSqrt: return DoMathSqrt(instr); case kMathPowHalf: return DoMathPowHalf(instr); @@ -1210,27 +1207,6 @@ LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) { } -LInstruction* LChunkBuilder::DoMathSin(HUnaryMathOperation* instr) { - LOperand* input = UseFixedDouble(instr->value(), f4); - LMathSin* result = new(zone()) LMathSin(input); - return MarkAsCall(DefineFixedDouble(result, f4), instr); -} - - -LInstruction* LChunkBuilder::DoMathCos(HUnaryMathOperation* instr) { - LOperand* input = UseFixedDouble(instr->value(), f4); - LMathCos* result = new(zone()) LMathCos(input); - return MarkAsCall(DefineFixedDouble(result, f4), instr); -} - - -LInstruction* LChunkBuilder::DoMathTan(HUnaryMathOperation* instr) { - LOperand* input = UseFixedDouble(instr->value(), f4); - LMathTan* result = new(zone()) LMathTan(input); - return MarkAsCall(DefineFixedDouble(result, f4), instr); -} - - LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) { ASSERT(instr->representation().IsDouble()); ASSERT(instr->value()->representation().IsDouble()); diff --git a/src/mips/lithium-mips.h b/src/mips/lithium-mips.h index dbb78ea..99885dc 100644 --- a/src/mips/lithium-mips.h +++ b/src/mips/lithium-mips.h @@ -131,7 +131,6 @@ class LCodeGen; V(LoadNamedGeneric) \ V(MapEnumLength) \ V(MathAbs) \ - V(MathCos) \ V(MathExp) \ V(MathFloor) \ V(MathFloorOfDiv) \ @@ -139,9 +138,7 @@ class LCodeGen; V(MathMinMax) \ V(MathPowHalf) \ V(MathRound) \ - V(MathSin) \ V(MathSqrt) \ - V(MathTan) \ V(ModI) \ V(MulI) \ V(MultiplyAddD) \ @@ -811,42 +808,6 @@ class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> { }; -class LMathSin V8_FINAL : public LTemplateInstruction<1, 1, 0> { - public: - explicit LMathSin(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(MathSin, "math-sin") -}; - - -class LMathCos V8_FINAL : public LTemplateInstruction<1, 1, 0> { - public: - explicit LMathCos(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(MathCos, "math-cos") -}; - - -class LMathTan V8_FINAL : public LTemplateInstruction<1, 1, 0> { - public: - explicit LMathTan(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(MathTan, "math-tan") -}; - - class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 3> { public: LMathExp(LOperand* value, @@ -2752,9 +2713,6 @@ class LChunkBuilder V8_FINAL BASE_EMBEDDED { LInstruction* DoMathRound(HUnaryMathOperation* instr); LInstruction* DoMathAbs(HUnaryMathOperation* instr); LInstruction* DoMathLog(HUnaryMathOperation* instr); - LInstruction* DoMathSin(HUnaryMathOperation* instr); - LInstruction* DoMathCos(HUnaryMathOperation* instr); - LInstruction* DoMathTan(HUnaryMathOperation* instr); LInstruction* DoMathExp(HUnaryMathOperation* instr); LInstruction* DoMathSqrt(HUnaryMathOperation* instr); LInstruction* DoMathPowHalf(HUnaryMathOperation* instr); diff --git a/src/objects.h b/src/objects.h index bbdefc1..f09d58f 100644 --- a/src/objects.h +++ b/src/objects.h @@ -6494,12 +6494,6 @@ class Script: public Struct { V(Math, ceil, MathCeil) \ V(Math, abs, MathAbs) \ V(Math, log, MathLog) \ - V(Math, sin, MathSin) \ - V(Math, cos, MathCos) \ - V(Math, tan, MathTan) \ - V(Math, asin, MathASin) \ - V(Math, acos, MathACos) \ - V(Math, atan, MathATan) \ V(Math, exp, MathExp) \ V(Math, sqrt, MathSqrt) \ V(Math, pow, MathPow) \ diff --git a/src/platform-posix.cc b/src/platform-posix.cc index 879dcc8..40d37c8 100644 --- a/src/platform-posix.cc +++ b/src/platform-posix.cc @@ -302,9 +302,6 @@ double fast_##name(double x) { \ return (*fast_##name##_function)(x); \ } -UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) -UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) -UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) UNARY_MATH_FUNCTION(exp, CreateExpFunction()) UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) @@ -521,9 +518,6 @@ void OS::PostSetUp() { OS::memcopy_uint16_uint8_function = CreateMemCopyUint16Uint8Function(&OS::MemCopyUint16Uint8Wrapper); #endif - init_fast_sin_function(); - init_fast_cos_function(); - init_fast_tan_function(); init_fast_log_function(); // fast_exp is initialized lazily. init_fast_sqrt_function(); diff --git a/src/platform-win32.cc b/src/platform-win32.cc index ea11806..7ca5e55 100644 --- a/src/platform-win32.cc +++ b/src/platform-win32.cc @@ -196,9 +196,6 @@ double fast_##name(double x) { \ return (*fast_##name##_function)(x); \ } -UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) -UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) -UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) UNARY_MATH_FUNCTION(exp, CreateExpFunction()) UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) @@ -217,9 +214,6 @@ void MathSetup() { #ifdef _WIN64 init_modulo_function(); #endif - init_fast_sin_function(); - init_fast_cos_function(); - init_fast_tan_function(); init_fast_log_function(); // fast_exp is initialized lazily. init_fast_sqrt_function(); diff --git a/src/platform.h b/src/platform.h index 3bd87a9..6bc94e1 100644 --- a/src/platform.h +++ b/src/platform.h @@ -96,9 +96,6 @@ namespace internal { double modulo(double x, double y); // Custom implementation of math functions. -double fast_sin(double input); -double fast_cos(double input); -double fast_tan(double input); double fast_log(double input); double fast_exp(double input); double fast_sqrt(double input); diff --git a/src/runtime.cc b/src/runtime.cc index 7dc96f2..588cce4 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -7655,7 +7655,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { isolate->counters()->math_acos()->Increment(); CONVERT_DOUBLE_ARG_CHECKED(x, 0); - return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x); + return isolate->heap()->AllocateHeapNumber(acos(x)); } @@ -7665,7 +7665,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { isolate->counters()->math_asin()->Increment(); CONVERT_DOUBLE_ARG_CHECKED(x, 0); - return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x); + return isolate->heap()->AllocateHeapNumber(asin(x)); } @@ -7675,7 +7675,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { isolate->counters()->math_atan()->Increment(); CONVERT_DOUBLE_ARG_CHECKED(x, 0); - return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x); + return isolate->heap()->AllocateHeapNumber(atan(x)); } @@ -7705,16 +7705,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { } -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cos) { - SealHandleScope shs(isolate); - ASSERT(args.length() == 1); - isolate->counters()->math_cos()->Increment(); - - CONVERT_DOUBLE_ARG_CHECKED(x, 0); - return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x); -} - - RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { SealHandleScope shs(isolate); ASSERT(args.length() == 1); @@ -7742,7 +7732,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { isolate->counters()->math_log()->Increment(); CONVERT_DOUBLE_ARG_CHECKED(x, 0); - return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x); + return isolate->heap()->AllocateHeapNumber(fast_log(x)); } @@ -7831,16 +7821,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) { } -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sin) { - SealHandleScope shs(isolate); - ASSERT(args.length() == 1); - isolate->counters()->math_sin()->Increment(); - - CONVERT_DOUBLE_ARG_CHECKED(x, 0); - return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x); -} - - RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { SealHandleScope shs(isolate); ASSERT(args.length() == 1); @@ -7851,16 +7831,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { } -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) { - SealHandleScope shs(isolate); - ASSERT(args.length() == 1); - isolate->counters()->math_tan()->Increment(); - - CONVERT_DOUBLE_ARG_CHECKED(x, 0); - return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); -} - - RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { SealHandleScope shs(isolate); ASSERT(args.length() == 2); diff --git a/src/runtime.h b/src/runtime.h index 0f920c7..e015a91 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -180,16 +180,13 @@ namespace internal { F(Math_asin, 1, 1) \ F(Math_atan, 1, 1) \ F(Math_atan2, 2, 1) \ - F(Math_cos, 1, 1) \ F(Math_exp, 1, 1) \ F(Math_floor, 1, 1) \ F(Math_log, 1, 1) \ F(Math_pow, 2, 1) \ F(Math_pow_cfunction, 2, 1) \ F(RoundNumber, 1, 1) \ - F(Math_sin, 1, 1) \ F(Math_sqrt, 1, 1) \ - F(Math_tan, 1, 1) \ \ /* Regular expressions */ \ F(RegExpCompile, 3, 1) \ diff --git a/src/v8-counters.h b/src/v8-counters.h index 9178046..72f5650 100644 --- a/src/v8-counters.h +++ b/src/v8-counters.h @@ -242,15 +242,12 @@ namespace internal { SC(math_asin, V8.MathAsin) \ SC(math_atan, V8.MathAtan) \ SC(math_atan2, V8.MathAtan2) \ - SC(math_cos, V8.MathCos) \ SC(math_exp, V8.MathExp) \ SC(math_floor, V8.MathFloor) \ SC(math_log, V8.MathLog) \ SC(math_pow, V8.MathPow) \ SC(math_round, V8.MathRound) \ - SC(math_sin, V8.MathSin) \ SC(math_sqrt, V8.MathSqrt) \ - SC(math_tan, V8.MathTan) \ SC(transcendental_cache_hit, V8.TranscendentalCacheHit) \ SC(transcendental_cache_miss, V8.TranscendentalCacheMiss) \ SC(stack_interrupts, V8.StackInterrupts) \ diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc index 0c9a0f2..2f65856 100644 --- a/src/x64/code-stubs-x64.cc +++ b/src/x64/code-stubs-x64.cc @@ -789,9 +789,6 @@ void TranscendentalCacheStub::Generate(MacroAssembler* masm) { Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() { switch (type_) { // Add more cases when necessary. - case TranscendentalCache::SIN: return Runtime::kMath_sin; - case TranscendentalCache::COS: return Runtime::kMath_cos; - case TranscendentalCache::TAN: return Runtime::kMath_tan; case TranscendentalCache::LOG: return Runtime::kMath_log; default: UNIMPLEMENTED(); @@ -807,99 +804,10 @@ void TranscendentalCacheStub::GenerateOperation( // rbx: Bits of input double. Must be preserved. // rcx: Pointer to cache entry. Must be preserved. // st(0): Input double - Label done; - if (type == TranscendentalCache::SIN || - type == TranscendentalCache::COS || - type == TranscendentalCache::TAN) { - // Both fsin and fcos require arguments in the range +/-2^63 and - // return NaN for infinities and NaN. They can share all code except - // the actual fsin/fcos operation. - Label in_range; - // If argument is outside the range -2^63..2^63, fsin/cos doesn't - // work. We must reduce it to the appropriate range. - __ movq(rdi, rbx); - // Move exponent and sign bits to low bits. - __ shr(rdi, Immediate(HeapNumber::kMantissaBits)); - // Remove sign bit. - __ andl(rdi, Immediate((1 << HeapNumber::kExponentBits) - 1)); - int supported_exponent_limit = (63 + HeapNumber::kExponentBias); - __ cmpl(rdi, Immediate(supported_exponent_limit)); - __ j(below, &in_range); - // Check for infinity and NaN. Both return NaN for sin. - __ cmpl(rdi, Immediate(0x7ff)); - Label non_nan_result; - __ j(not_equal, &non_nan_result, Label::kNear); - // Input is +/-Infinity or NaN. Result is NaN. - __ fstp(0); - // NaN is represented by 0x7ff8000000000000. - __ subq(rsp, Immediate(kPointerSize)); - __ movl(Operand(rsp, 4), Immediate(0x7ff80000)); - __ movl(Operand(rsp, 0), Immediate(0x00000000)); - __ fld_d(Operand(rsp, 0)); - __ addq(rsp, Immediate(kPointerSize)); - __ jmp(&done); - - __ bind(&non_nan_result); - - // Use fpmod to restrict argument to the range +/-2*PI. - __ movq(rdi, rax); // Save rax before using fnstsw_ax. - __ fldpi(); - __ fadd(0); - __ fld(1); - // FPU Stack: input, 2*pi, input. - { - Label no_exceptions; - __ fwait(); - __ fnstsw_ax(); - // Clear if Illegal Operand or Zero Division exceptions are set. - __ testl(rax, Immediate(5)); // #IO and #ZD flags of FPU status word. - __ j(zero, &no_exceptions); - __ fnclex(); - __ bind(&no_exceptions); - } - - // Compute st(0) % st(1) - { - Label partial_remainder_loop; - __ bind(&partial_remainder_loop); - __ fprem1(); - __ fwait(); - __ fnstsw_ax(); - __ testl(rax, Immediate(0x400)); // Check C2 bit of FPU status word. - // If C2 is set, computation only has partial result. Loop to - // continue computation. - __ j(not_zero, &partial_remainder_loop); - } - // FPU Stack: input, 2*pi, input % 2*pi - __ fstp(2); - // FPU Stack: input % 2*pi, 2*pi, - __ fstp(0); - // FPU Stack: input % 2*pi - __ movq(rax, rdi); // Restore rax, pointer to the new HeapNumber. - __ bind(&in_range); - switch (type) { - case TranscendentalCache::SIN: - __ fsin(); - break; - case TranscendentalCache::COS: - __ fcos(); - break; - case TranscendentalCache::TAN: - // FPTAN calculates tangent onto st(0) and pushes 1.0 onto the - // FP register stack. - __ fptan(); - __ fstp(0); // Pop FP register stack. - break; - default: - UNREACHABLE(); - } - __ bind(&done); - } else { - ASSERT(type == TranscendentalCache::LOG); - __ fldln2(); - __ fxch(); - __ fyl2x(); - } + ASSERT(type == TranscendentalCache::LOG); + __ fldln2(); + __ fxch(); + __ fyl2x(); } diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc index afe0e3b..96d930e 100644 --- a/src/x64/codegen-x64.cc +++ b/src/x64/codegen-x64.cc @@ -64,9 +64,6 @@ UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) { if (buffer == NULL) { // Fallback to library function if function cannot be created. switch (type) { - case TranscendentalCache::SIN: return &sin; - case TranscendentalCache::COS: return &cos; - case TranscendentalCache::TAN: return &tan; case TranscendentalCache::LOG: return &log; default: UNIMPLEMENTED(); } diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index 3ab5236..7c9949a 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -3747,39 +3747,6 @@ void LCodeGen::DoMathLog(LMathLog* instr) { } -void LCodeGen::DoMathTan(LMathTan* instr) { - ASSERT(ToDoubleRegister(instr->result()).is(xmm1)); - // Set the context register to a GC-safe fake value. Clobbering it is - // OK because this instruction is marked as a call. - __ Set(rsi, 0); - TranscendentalCacheStub stub(TranscendentalCache::TAN, - TranscendentalCacheStub::UNTAGGED); - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); -} - - -void LCodeGen::DoMathCos(LMathCos* instr) { - ASSERT(ToDoubleRegister(instr->result()).is(xmm1)); - // Set the context register to a GC-safe fake value. Clobbering it is - // OK because this instruction is marked as a call. - __ Set(rsi, 0); - TranscendentalCacheStub stub(TranscendentalCache::COS, - TranscendentalCacheStub::UNTAGGED); - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); -} - - -void LCodeGen::DoMathSin(LMathSin* instr) { - ASSERT(ToDoubleRegister(instr->result()).is(xmm1)); - // Set the context register to a GC-safe fake value. Clobbering it is - // OK because this instruction is marked as a call. - __ Set(rsi, 0); - TranscendentalCacheStub stub(TranscendentalCache::SIN, - TranscendentalCacheStub::UNTAGGED); - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); -} - - void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { ASSERT(ToRegister(instr->context()).is(rsi)); ASSERT(ToRegister(instr->function()).is(rdi)); diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index 0f7ebc4..9ceaa26 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -1187,9 +1187,6 @@ LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { case kMathRound: return DoMathRound(instr); case kMathAbs: return DoMathAbs(instr); case kMathLog: return DoMathLog(instr); - case kMathSin: return DoMathSin(instr); - case kMathCos: return DoMathCos(instr); - case kMathTan: return DoMathTan(instr); case kMathExp: return DoMathExp(instr); case kMathSqrt: return DoMathSqrt(instr); case kMathPowHalf: return DoMathPowHalf(instr); @@ -1231,27 +1228,6 @@ LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) { } -LInstruction* LChunkBuilder::DoMathSin(HUnaryMathOperation* instr) { - LOperand* input = UseFixedDouble(instr->value(), xmm1); - LMathSin* result = new(zone()) LMathSin(input); - return MarkAsCall(DefineFixedDouble(result, xmm1), instr); -} - - -LInstruction* LChunkBuilder::DoMathCos(HUnaryMathOperation* instr) { - LOperand* input = UseFixedDouble(instr->value(), xmm1); - LMathCos* result = new(zone()) LMathCos(input); - return MarkAsCall(DefineFixedDouble(result, xmm1), instr); -} - - -LInstruction* LChunkBuilder::DoMathTan(HUnaryMathOperation* instr) { - LOperand* input = UseFixedDouble(instr->value(), xmm1); - LMathTan* result = new(zone()) LMathTan(input); - return MarkAsCall(DefineFixedDouble(result, xmm1), instr); -} - - LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) { ASSERT(instr->representation().IsDouble()); ASSERT(instr->value()->representation().IsDouble()); diff --git a/src/x64/lithium-x64.h b/src/x64/lithium-x64.h index 44bd992..e644c2d 100644 --- a/src/x64/lithium-x64.h +++ b/src/x64/lithium-x64.h @@ -131,7 +131,6 @@ class LCodeGen; V(LoadNamedGeneric) \ V(MapEnumLength) \ V(MathAbs) \ - V(MathCos) \ V(MathExp) \ V(MathFloor) \ V(MathFloorOfDiv) \ @@ -139,9 +138,7 @@ class LCodeGen; V(MathMinMax) \ V(MathPowHalf) \ V(MathRound) \ - V(MathSin) \ V(MathSqrt) \ - V(MathTan) \ V(ModI) \ V(MulI) \ V(NumberTagD) \ @@ -770,42 +767,6 @@ class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> { }; -class LMathSin V8_FINAL : public LTemplateInstruction<1, 1, 0> { - public: - explicit LMathSin(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(MathSin, "math-sin") -}; - - -class LMathCos V8_FINAL : public LTemplateInstruction<1, 1, 0> { - public: - explicit LMathCos(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(MathCos, "math-cos") -}; - - -class LMathTan V8_FINAL : public LTemplateInstruction<1, 1, 0> { - public: - explicit LMathTan(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(MathTan, "math-tan") -}; - - class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> { public: LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) { @@ -2705,9 +2666,6 @@ class LChunkBuilder V8_FINAL BASE_EMBEDDED { LInstruction* DoMathRound(HUnaryMathOperation* instr); LInstruction* DoMathAbs(HUnaryMathOperation* instr); LInstruction* DoMathLog(HUnaryMathOperation* instr); - LInstruction* DoMathSin(HUnaryMathOperation* instr); - LInstruction* DoMathCos(HUnaryMathOperation* instr); - LInstruction* DoMathTan(HUnaryMathOperation* instr); LInstruction* DoMathExp(HUnaryMathOperation* instr); LInstruction* DoMathSqrt(HUnaryMathOperation* instr); LInstruction* DoMathPowHalf(HUnaryMathOperation* instr); -- 2.7.4