From: yangguo@chromium.org Date: Thu, 27 Mar 2014 14:45:56 +0000 (+0000) Subject: Clean up runtime functions for Maths. X-Git-Tag: upstream/4.7.83~9968 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1110f4fcbbf5d3f361b76c377d7b9d0ec2cc6e98;p=platform%2Fupstream%2Fv8.git Clean up runtime functions for Maths. R=dslomov@google.com, dslomov@chromium.org Review URL: https://codereview.chromium.org/212763008 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20307 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index 832296b..aadfb29c 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -1428,7 +1428,7 @@ void MathPowStub::Generate(MacroAssembler* masm) { if (exponent_type_ == ON_STACK) { // The arguments are still on the stack. __ bind(&call_runtime); - __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1); + __ TailCallRuntime(Runtime::kHiddenMathPow, 2, 1); // The stub is called from non-optimized code, which expects the result // as heap number in exponent. diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index b5ec2d5..2ca8016 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -3759,26 +3759,6 @@ void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { } -void FullCodeGenerator::EmitMathLog(CallRuntime* expr) { - // Load the argument on the stack and call the runtime function. - ZoneList* args = expr->arguments(); - ASSERT(args->length() == 1); - VisitForStackValue(args->at(0)); - __ CallRuntime(Runtime::kMath_log, 1); - context()->Plug(r0); -} - - -void FullCodeGenerator::EmitMathSqrt(CallRuntime* expr) { - // Load the argument on the stack and call the runtime function. - ZoneList* args = expr->arguments(); - ASSERT(args->length() == 1); - VisitForStackValue(args->at(0)); - __ CallRuntime(Runtime::kMath_sqrt, 1); - context()->Plug(r0); -} - - void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { ZoneList* args = expr->arguments(); ASSERT(args->length() >= 2); diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc index b097fc5..7e8267b 100644 --- a/src/arm64/code-stubs-arm64.cc +++ b/src/arm64/code-stubs-arm64.cc @@ -1389,7 +1389,7 @@ void MathPowStub::Generate(MacroAssembler* masm) { __ Bind(&call_runtime); // Put the arguments back on the stack. __ Push(base_tagged, exponent_tagged); - __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1); + __ TailCallRuntime(Runtime::kHiddenMathPow, 2, 1); // Return. __ Bind(&done); diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc index d40e74a..d8f1402 100644 --- a/src/arm64/full-codegen-arm64.cc +++ b/src/arm64/full-codegen-arm64.cc @@ -3492,26 +3492,6 @@ void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { } -void FullCodeGenerator::EmitMathLog(CallRuntime* expr) { - // Load the argument on the stack and call the runtime function. - ZoneList* args = expr->arguments(); - ASSERT(args->length() == 1); - VisitForStackValue(args->at(0)); - __ CallRuntime(Runtime::kMath_log, 1); - context()->Plug(x0); -} - - -void FullCodeGenerator::EmitMathSqrt(CallRuntime* expr) { - // Load the argument on the stack and call the runtime function. - ZoneList* args = expr->arguments(); - ASSERT(args->length() == 1); - VisitForStackValue(args->at(0)); - __ CallRuntime(Runtime::kMath_sqrt, 1); - context()->Plug(x0); -} - - void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { ASM_LOCATION("FullCodeGenerator::EmitCallFunction"); ZoneList* args = expr->arguments(); diff --git a/src/harmony-math.js b/src/harmony-math.js index 298fa58..c8fac07 100644 --- a/src/harmony-math.js +++ b/src/harmony-math.js @@ -156,7 +156,7 @@ function MathHypot(x, y) { // Function length is 2. // ES6 draft 09-27-13, section 20.2.2.16. function MathFround(x) { - return %Math_fround(TO_NUMBER_INLINE(x)); + return %MathFround(TO_NUMBER_INLINE(x)); } diff --git a/src/hydrogen.cc b/src/hydrogen.cc index a7ef0cb..d4aa64e 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -10785,6 +10785,15 @@ void HOptimizedGraphBuilder::GenerateMathSqrt(CallRuntime* call) { } +void HOptimizedGraphBuilder::GenerateMathExp(CallRuntime* call) { + ASSERT(call->arguments()->length() == 1); + CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); + HValue* value = Pop(); + HInstruction* result = NewUncasted(value, kMathExp); + return ast_context()->ReturnInstruction(result, call->id()); +} + + void HOptimizedGraphBuilder::GenerateGetCachedArrayIndex(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc index ab29167..dca7ae7 100644 --- a/src/ia32/code-stubs-ia32.cc +++ b/src/ia32/code-stubs-ia32.cc @@ -1014,7 +1014,7 @@ void MathPowStub::Generate(MacroAssembler* masm) { if (exponent_type_ == ON_STACK) { // The arguments are still on the stack. __ bind(&call_runtime); - __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1); + __ TailCallRuntime(Runtime::kHiddenMathPow, 2, 1); // The stub is called from non-optimized code, which expects the result // as heap number in exponent. diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc index 70a968e..1a7d828 100644 --- a/src/ia32/full-codegen-ia32.cc +++ b/src/ia32/full-codegen-ia32.cc @@ -3539,7 +3539,7 @@ void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { MathPowStub stub(MathPowStub::ON_STACK); __ CallStub(&stub); } else { - __ CallRuntime(Runtime::kMath_pow, 2); + __ CallRuntime(Runtime::kHiddenMathPowSlow, 2); } context()->Plug(eax); } @@ -3726,26 +3726,6 @@ void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { } -void FullCodeGenerator::EmitMathLog(CallRuntime* expr) { - // Load the argument on the stack and call the runtime function. - ZoneList* args = expr->arguments(); - ASSERT(args->length() == 1); - VisitForStackValue(args->at(0)); - __ CallRuntime(Runtime::kMath_log, 1); - context()->Plug(eax); -} - - -void FullCodeGenerator::EmitMathSqrt(CallRuntime* expr) { - // Load the argument on the stack and call the runtime function. - ZoneList* args = expr->arguments(); - ASSERT(args->length() == 1); - VisitForStackValue(args->at(0)); - __ CallRuntime(Runtime::kMath_sqrt, 1); - context()->Plug(eax); -} - - void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { ZoneList* args = expr->arguments(); ASSERT(args->length() >= 2); diff --git a/src/math.js b/src/math.js index da96d96..951b5b1 100644 --- a/src/math.js +++ b/src/math.js @@ -52,24 +52,24 @@ function MathAbs(x) { // ECMA 262 - 15.8.2.2 function MathAcos(x) { - return %Math_acos(TO_NUMBER_INLINE(x)); + return %MathAcos(TO_NUMBER_INLINE(x)); } // ECMA 262 - 15.8.2.3 function MathAsin(x) { - return %Math_asin(TO_NUMBER_INLINE(x)); + return %MathAsin(TO_NUMBER_INLINE(x)); } // ECMA 262 - 15.8.2.4 function MathAtan(x) { - return %Math_atan(TO_NUMBER_INLINE(x)); + return %MathAtan(TO_NUMBER_INLINE(x)); } // ECMA 262 - 15.8.2.5 // The naming of y and x matches the spec, as does the order in which // ToNumber (valueOf) is called. function MathAtan2(y, x) { - return %Math_atan2(TO_NUMBER_INLINE(y), TO_NUMBER_INLINE(x)); + return %MathAtan2(TO_NUMBER_INLINE(y), TO_NUMBER_INLINE(x)); } // ECMA 262 - 15.8.2.6 @@ -85,7 +85,7 @@ function MathCos(x) { // ECMA 262 - 15.8.2.8 function MathExp(x) { - return %Math_exp(TO_NUMBER_INLINE(x)); + return %_MathExp(TO_NUMBER_INLINE(x)); } // ECMA 262 - 15.8.2.9 @@ -100,7 +100,7 @@ function MathFloor(x) { // has to be -0, which wouldn't be the case with the shift. return TO_UINT32(x); } else { - return %Math_floor(x); + return %MathFloor(x); } } diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc index 332ed4b..7851b58 100644 --- a/src/mips/code-stubs-mips.cc +++ b/src/mips/code-stubs-mips.cc @@ -1511,7 +1511,7 @@ void MathPowStub::Generate(MacroAssembler* masm) { if (exponent_type_ == ON_STACK) { // The arguments are still on the stack. __ bind(&call_runtime); - __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1); + __ TailCallRuntime(Runtime::kHiddenMathPow, 2, 1); // The stub is called from non-optimized code, which expects the result // as heap number in exponent. diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc index 87c0764..a676fea 100644 --- a/src/mips/full-codegen-mips.cc +++ b/src/mips/full-codegen-mips.cc @@ -3798,26 +3798,6 @@ void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { } -void FullCodeGenerator::EmitMathLog(CallRuntime* expr) { - // Load the argument on the stack and call the runtime function. - ZoneList* args = expr->arguments(); - ASSERT(args->length() == 1); - VisitForStackValue(args->at(0)); - __ CallRuntime(Runtime::kMath_log, 1); - context()->Plug(v0); -} - - -void FullCodeGenerator::EmitMathSqrt(CallRuntime* expr) { - // Load the argument on the stack and call the runtime function. - ZoneList* args = expr->arguments(); - ASSERT(args->length() == 1); - VisitForStackValue(args->at(0)); - __ CallRuntime(Runtime::kMath_sqrt, 1); - context()->Plug(v0); -} - - void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { ZoneList* args = expr->arguments(); ASSERT(args->length() >= 2); diff --git a/src/runtime.cc b/src/runtime.cc index 8f4c4ca..4fdc5ad 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -7759,19 +7759,19 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringCompare) { } -#define RUNTIME_UNARY_MATH(NAME) \ -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_##NAME) { \ +#define RUNTIME_UNARY_MATH(Name, name) \ +RUNTIME_FUNCTION(MaybeObject*, Runtime_Math##Name) { \ SealHandleScope shs(isolate); \ ASSERT(args.length() == 1); \ - isolate->counters()->math_##NAME()->Increment(); \ + isolate->counters()->math_##name()->Increment(); \ CONVERT_DOUBLE_ARG_CHECKED(x, 0); \ - return isolate->heap()->AllocateHeapNumber(std::NAME(x)); \ + return isolate->heap()->AllocateHeapNumber(std::name(x)); \ } -RUNTIME_UNARY_MATH(acos) -RUNTIME_UNARY_MATH(asin) -RUNTIME_UNARY_MATH(atan) -RUNTIME_UNARY_MATH(log) +RUNTIME_UNARY_MATH(Acos, acos) +RUNTIME_UNARY_MATH(Asin, asin) +RUNTIME_UNARY_MATH(Atan, atan) +RUNTIME_UNARY_MATH(Log, log) #undef RUNTIME_UNARY_MATH @@ -7807,7 +7807,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ConstructDouble) { static const double kPiDividedBy4 = 0.78539816339744830962; -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { +RUNTIME_FUNCTION(MaybeObject*, Runtime_MathAtan2) { SealHandleScope shs(isolate); ASSERT(args.length() == 2); isolate->counters()->math_atan2()->Increment(); @@ -7830,7 +7830,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { } -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { +RUNTIME_FUNCTION(MaybeObject*, Runtime_MathExp) { SealHandleScope shs(isolate); ASSERT(args.length() == 1); isolate->counters()->math_exp()->Increment(); @@ -7841,7 +7841,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { } -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { +RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFloor) { SealHandleScope shs(isolate); ASSERT(args.length() == 1); isolate->counters()->math_floor()->Increment(); @@ -7853,7 +7853,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { // Slow version of Math.pow. We check for fast paths for special cases. // Used if SSE2/VFP3 is not available. -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { +RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPowSlow) { SealHandleScope shs(isolate); ASSERT(args.length() == 2); isolate->counters()->math_pow()->Increment(); @@ -7876,7 +7876,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { // Fast version of Math.pow if we know that y is not an integer and y is not // -0.5 or 0.5. Used as slow case from full codegen. -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow_cfunction) { +RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPow) { SealHandleScope shs(isolate); ASSERT(args.length() == 2); isolate->counters()->math_pow()->Increment(); @@ -7936,7 +7936,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) { } -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { +RUNTIME_FUNCTION(MaybeObject*, Runtime_MathSqrt) { SealHandleScope shs(isolate); ASSERT(args.length() == 1); isolate->counters()->math_sqrt()->Increment(); @@ -7946,7 +7946,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { } -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_fround) { +RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFround) { SealHandleScope shs(isolate); ASSERT(args.length() == 1); diff --git a/src/runtime.h b/src/runtime.h index 58cd525..09a6cc9 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -157,18 +157,13 @@ namespace internal { F(SmiLexicographicCompare, 2, 1) \ \ /* Math */ \ - F(Math_acos, 1, 1) \ - F(Math_asin, 1, 1) \ - F(Math_atan, 1, 1) \ - F(Math_log, 1, 1) \ - F(Math_sqrt, 1, 1) \ - F(Math_exp, 1, 1) \ - F(Math_floor, 1, 1) \ - F(Math_pow, 2, 1) \ - F(Math_pow_cfunction, 2, 1) \ - F(Math_atan2, 2, 1) \ + F(MathAcos, 1, 1) \ + F(MathAsin, 1, 1) \ + F(MathAtan, 1, 1) \ + F(MathFloor, 1, 1) \ + F(MathAtan2, 2, 1) \ F(RoundNumber, 1, 1) \ - F(Math_fround, 1, 1) \ + F(MathFround, 1, 1) \ \ /* Regular expressions */ \ F(RegExpCompile, 3, 1) \ @@ -556,6 +551,7 @@ namespace internal { // by id from code generator, but not via native call by name. // Entries have the form F(name, number of arguments, number of return values). #define RUNTIME_HIDDEN_FUNCTION_LIST(F) \ + /* String and Regexp */ \ F(NumberToString, 1, 1) \ F(RegExpConstructResult, 3, 1) \ F(RegExpExec, 4, 1) \ @@ -634,7 +630,11 @@ namespace internal { F(InitializeConstContextSlot, 3, 1) \ \ /* Eval */ \ - F(ResolvePossiblyDirectEval, 5, 2) + F(ResolvePossiblyDirectEval, 5, 2) \ + \ + /* Maths */ \ + F(MathPowSlow, 2, 1) \ + F(MathPow, 2, 1) // ---------------------------------------------------------------------------- // INLINE_FUNCTION_LIST defines all inlined functions accessed @@ -663,8 +663,6 @@ namespace internal { F(IsSpecObject, 1, 1) \ F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \ F(MathPow, 2, 1) \ - F(MathSqrt, 1, 1) \ - F(MathLog, 1, 1) \ F(IsMinusZero, 1, 1) \ F(HasCachedArrayIndex, 1, 1) \ F(GetCachedArrayIndex, 1, 1) \ @@ -690,13 +688,19 @@ namespace internal { // a corresponding runtime function, that is called from non-optimized code. // Entries have the form F(name, number of arguments, number of return values). #define INLINE_OPTIMIZED_FUNCTION_LIST(F) \ - F(DoubleHi, 1, 1) \ - F(DoubleLo, 1, 1) \ + /* Typed Arrays */ \ F(ConstructDouble, 2, 1) \ F(TypedArrayInitialize, 5, 1) \ F(DataViewInitialize, 4, 1) \ F(MaxSmi, 0, 1) \ - F(TypedArrayMaxSizeInHeap, 0, 1) + F(TypedArrayMaxSizeInHeap, 0, 1) \ + \ + /* Maths */ \ + F(DoubleHi, 1, 1) \ + F(DoubleLo, 1, 1) \ + F(MathSqrt, 1, 1) \ + F(MathExp, 1, 1) \ + F(MathLog, 1, 1) //--------------------------------------------------------------------------- diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc index c949a42..137142a 100644 --- a/src/x64/code-stubs-x64.cc +++ b/src/x64/code-stubs-x64.cc @@ -875,7 +875,7 @@ void MathPowStub::Generate(MacroAssembler* masm) { if (exponent_type_ == ON_STACK) { // The arguments are still on the stack. __ bind(&call_runtime); - __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1); + __ TailCallRuntime(Runtime::kHiddenMathPow, 2, 1); // The stub is called from non-optimized code, which expects the result // as heap number in rax. diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index f0b9438..a25215a 100644 --- a/src/x64/full-codegen-x64.cc +++ b/src/x64/full-codegen-x64.cc @@ -3698,26 +3698,6 @@ void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { } -void FullCodeGenerator::EmitMathLog(CallRuntime* expr) { - // Load the argument on the stack and call the runtime function. - ZoneList* args = expr->arguments(); - ASSERT(args->length() == 1); - VisitForStackValue(args->at(0)); - __ CallRuntime(Runtime::kMath_log, 1); - context()->Plug(rax); -} - - -void FullCodeGenerator::EmitMathSqrt(CallRuntime* expr) { - // Load the argument on the stack and call the runtime function. - ZoneList* args = expr->arguments(); - ASSERT(args->length() == 1); - VisitForStackValue(args->at(0)); - __ CallRuntime(Runtime::kMath_sqrt, 1); - context()->Plug(rax); -} - - void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { ZoneList* args = expr->arguments(); ASSERT(args->length() >= 2);