Revert "Clean up runtime functions for Maths."
authoryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 27 Mar 2014 16:30:03 +0000 (16:30 +0000)
committeryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 27 Mar 2014 16:30:03 +0000 (16:30 +0000)
This reverts r20307.

TBR=jarin@chromium.org

Review URL: https://codereview.chromium.org/214593005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20311 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

15 files changed:
src/arm/code-stubs-arm.cc
src/arm/full-codegen-arm.cc
src/arm64/code-stubs-arm64.cc
src/arm64/full-codegen-arm64.cc
src/harmony-math.js
src/hydrogen.cc
src/ia32/code-stubs-ia32.cc
src/ia32/full-codegen-ia32.cc
src/math.js
src/mips/code-stubs-mips.cc
src/mips/full-codegen-mips.cc
src/runtime.cc
src/runtime.h
src/x64/code-stubs-x64.cc
src/x64/full-codegen-x64.cc

index aadfb29..832296b 100644 (file)
@@ -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::kHiddenMathPow, 2, 1);
+    __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1);
 
     // The stub is called from non-optimized code, which expects the result
     // as heap number in exponent.
index 2ca8016..b5ec2d5 100644 (file)
@@ -3759,6 +3759,26 @@ void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) {
 }
 
 
+void FullCodeGenerator::EmitMathLog(CallRuntime* expr) {
+  // Load the argument on the stack and call the runtime function.
+  ZoneList<Expression*>* 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<Expression*>* 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<Expression*>* args = expr->arguments();
   ASSERT(args->length() >= 2);
index 7e8267b..b097fc5 100644 (file)
@@ -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::kHiddenMathPow, 2, 1);
+    __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1);
 
     // Return.
     __ Bind(&done);
index d8f1402..d40e74a 100644 (file)
@@ -3492,6 +3492,26 @@ void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) {
 }
 
 
+void FullCodeGenerator::EmitMathLog(CallRuntime* expr) {
+  // Load the argument on the stack and call the runtime function.
+  ZoneList<Expression*>* 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<Expression*>* 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<Expression*>* args = expr->arguments();
index c8fac07..298fa58 100644 (file)
@@ -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 %MathFround(TO_NUMBER_INLINE(x));
+  return %Math_fround(TO_NUMBER_INLINE(x));
 }
 
 
index d4aa64e..a7ef0cb 100644 (file)
@@ -10785,15 +10785,6 @@ 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<HUnaryMathOperation>(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)));
index dca7ae7..ab29167 100644 (file)
@@ -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::kHiddenMathPow, 2, 1);
+    __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1);
 
     // The stub is called from non-optimized code, which expects the result
     // as heap number in exponent.
index 1a7d828..70a968e 100644 (file)
@@ -3539,7 +3539,7 @@ void FullCodeGenerator::EmitMathPow(CallRuntime* expr) {
     MathPowStub stub(MathPowStub::ON_STACK);
     __ CallStub(&stub);
   } else {
-    __ CallRuntime(Runtime::kHiddenMathPowSlow, 2);
+    __ CallRuntime(Runtime::kMath_pow, 2);
   }
   context()->Plug(eax);
 }
@@ -3726,6 +3726,26 @@ void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) {
 }
 
 
+void FullCodeGenerator::EmitMathLog(CallRuntime* expr) {
+  // Load the argument on the stack and call the runtime function.
+  ZoneList<Expression*>* 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<Expression*>* 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<Expression*>* args = expr->arguments();
   ASSERT(args->length() >= 2);
index 951b5b1..da96d96 100644 (file)
@@ -52,24 +52,24 @@ function MathAbs(x) {
 
 // ECMA 262 - 15.8.2.2
 function MathAcos(x) {
-  return %MathAcos(TO_NUMBER_INLINE(x));
+  return %Math_acos(TO_NUMBER_INLINE(x));
 }
 
 // ECMA 262 - 15.8.2.3
 function MathAsin(x) {
-  return %MathAsin(TO_NUMBER_INLINE(x));
+  return %Math_asin(TO_NUMBER_INLINE(x));
 }
 
 // ECMA 262 - 15.8.2.4
 function MathAtan(x) {
-  return %MathAtan(TO_NUMBER_INLINE(x));
+  return %Math_atan(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 %MathAtan2(TO_NUMBER_INLINE(y), TO_NUMBER_INLINE(x));
+  return %Math_atan2(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 %_MathExp(TO_NUMBER_INLINE(x));
+  return %Math_exp(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 %MathFloor(x);
+    return %Math_floor(x);
   }
 }
 
index 7851b58..332ed4b 100644 (file)
@@ -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::kHiddenMathPow, 2, 1);
+    __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1);
 
     // The stub is called from non-optimized code, which expects the result
     // as heap number in exponent.
index a676fea..87c0764 100644 (file)
@@ -3798,6 +3798,26 @@ void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) {
 }
 
 
+void FullCodeGenerator::EmitMathLog(CallRuntime* expr) {
+  // Load the argument on the stack and call the runtime function.
+  ZoneList<Expression*>* 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<Expression*>* 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<Expression*>* args = expr->arguments();
   ASSERT(args->length() >= 2);
index 4fdc5ad..8f4c4ca 100644 (file)
@@ -7759,19 +7759,19 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringCompare) {
 }
 
 
-#define RUNTIME_UNARY_MATH(Name, name)                                         \
-RUNTIME_FUNCTION(MaybeObject*, Runtime_Math##Name) {                           \
+#define RUNTIME_UNARY_MATH(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, acos)
-RUNTIME_UNARY_MATH(Asin, asin)
-RUNTIME_UNARY_MATH(Atan, atan)
-RUNTIME_UNARY_MATH(Log, log)
+RUNTIME_UNARY_MATH(acos)
+RUNTIME_UNARY_MATH(asin)
+RUNTIME_UNARY_MATH(atan)
+RUNTIME_UNARY_MATH(log)
 #undef RUNTIME_UNARY_MATH
 
 
@@ -7807,7 +7807,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ConstructDouble) {
 static const double kPiDividedBy4 = 0.78539816339744830962;
 
 
-RUNTIME_FUNCTION(MaybeObject*, Runtime_MathAtan2) {
+RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) {
   SealHandleScope shs(isolate);
   ASSERT(args.length() == 2);
   isolate->counters()->math_atan2()->Increment();
@@ -7830,7 +7830,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_MathAtan2) {
 }
 
 
-RUNTIME_FUNCTION(MaybeObject*, Runtime_MathExp) {
+RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) {
   SealHandleScope shs(isolate);
   ASSERT(args.length() == 1);
   isolate->counters()->math_exp()->Increment();
@@ -7841,7 +7841,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_MathExp) {
 }
 
 
-RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFloor) {
+RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) {
   SealHandleScope shs(isolate);
   ASSERT(args.length() == 1);
   isolate->counters()->math_floor()->Increment();
@@ -7853,7 +7853,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFloor) {
 
 // Slow version of Math.pow.  We check for fast paths for special cases.
 // Used if SSE2/VFP3 is not available.
-RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPowSlow) {
+RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) {
   SealHandleScope shs(isolate);
   ASSERT(args.length() == 2);
   isolate->counters()->math_pow()->Increment();
@@ -7876,7 +7876,7 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPowSlow) {
 
 // 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*, RuntimeHidden_MathPow) {
+RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow_cfunction) {
   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_MathSqrt) {
+RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) {
   SealHandleScope shs(isolate);
   ASSERT(args.length() == 1);
   isolate->counters()->math_sqrt()->Increment();
@@ -7946,7 +7946,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_MathSqrt) {
 }
 
 
-RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFround) {
+RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_fround) {
   SealHandleScope shs(isolate);
   ASSERT(args.length() == 1);
 
index 09a6cc9..58cd525 100644 (file)
@@ -157,13 +157,18 @@ namespace internal {
   F(SmiLexicographicCompare, 2, 1) \
   \
   /* Math */ \
-  F(MathAcos, 1, 1) \
-  F(MathAsin, 1, 1) \
-  F(MathAtan, 1, 1) \
-  F(MathFloor, 1, 1) \
-  F(MathAtan2, 2, 1) \
+  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(RoundNumber, 1, 1) \
-  F(MathFround, 1, 1) \
+  F(Math_fround, 1, 1) \
   \
   /* Regular expressions */ \
   F(RegExpCompile, 3, 1) \
@@ -551,7 +556,6 @@ 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) \
@@ -630,11 +634,7 @@ namespace internal {
   F(InitializeConstContextSlot, 3, 1) \
   \
   /* Eval */ \
-  F(ResolvePossiblyDirectEval, 5, 2) \
-  \
-  /* Maths */ \
-  F(MathPowSlow, 2, 1) \
-  F(MathPow, 2, 1)
+  F(ResolvePossiblyDirectEval, 5, 2)
 
 // ----------------------------------------------------------------------------
 // INLINE_FUNCTION_LIST defines all inlined functions accessed
@@ -663,6 +663,8 @@ 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)                                               \
@@ -688,19 +690,13 @@ 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) \
-  /* Typed Arrays */                                                         \
+  F(DoubleHi, 1, 1)                                                          \
+  F(DoubleLo, 1, 1)                                                          \
   F(ConstructDouble, 2, 1)                                                   \
   F(TypedArrayInitialize, 5, 1)                                              \
   F(DataViewInitialize, 4, 1)                                                \
   F(MaxSmi, 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)
+  F(TypedArrayMaxSizeInHeap, 0, 1)
 
 
 //---------------------------------------------------------------------------
index 137142a..c949a42 100644 (file)
@@ -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::kHiddenMathPow, 2, 1);
+    __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1);
 
     // The stub is called from non-optimized code, which expects the result
     // as heap number in rax.
index a25215a..f0b9438 100644 (file)
@@ -3698,6 +3698,26 @@ void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) {
 }
 
 
+void FullCodeGenerator::EmitMathLog(CallRuntime* expr) {
+  // Load the argument on the stack and call the runtime function.
+  ZoneList<Expression*>* 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<Expression*>* 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<Expression*>* args = expr->arguments();
   ASSERT(args->length() >= 2);