Implement Math.ceil via Math.floor.
authorsvenpanne@chromium.org <svenpanne@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 26 Nov 2013 12:29:47 +0000 (12:29 +0000)
committersvenpanne@chromium.org <svenpanne@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 26 Nov 2013 12:29:47 +0000 (12:29 +0000)
This way we get all the Crankshaft goodness and avoid always going
through the runtime: Less code + even some small speedup in Kraken.

R=jkummerow@chromium.org

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

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

src/math.js
src/runtime.cc
src/runtime.h
src/v8-counters.h

index 789886e..5cbe94a 100644 (file)
@@ -74,7 +74,7 @@ function MathAtan2(y, x) {
 
 // ECMA 262 - 15.8.2.6
 function MathCeil(x) {
-  return %Math_ceil(TO_NUMBER_INLINE(x));
+  return -MathFloor(-x);
 }
 
 // ECMA 262 - 15.8.2.7
@@ -348,6 +348,7 @@ function SetUpMath() {
     "imul", MathImul
   ));
 
+  %SetInlineBuiltinFlag(MathCeil);
   %SetInlineBuiltinFlag(MathRandom);
   %SetInlineBuiltinFlag(MathSin);
   %SetInlineBuiltinFlag(MathCos);
index 67e5e9e..fbe4426 100644 (file)
@@ -7701,16 +7701,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) {
 }
 
 
-RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_ceil) {
-  SealHandleScope shs(isolate);
-  ASSERT(args.length() == 1);
-  isolate->counters()->math_ceil()->Increment();
-
-  CONVERT_DOUBLE_ARG_CHECKED(x, 0);
-  return isolate->heap()->NumberFromDouble(ceiling(x));
-}
-
-
 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cos) {
   SealHandleScope shs(isolate);
   ASSERT(args.length() == 1);
index 69783f4..62c52a7 100644 (file)
@@ -179,7 +179,6 @@ namespace internal {
   F(Math_asin, 1, 1) \
   F(Math_atan, 1, 1) \
   F(Math_atan2, 2, 1) \
-  F(Math_ceil, 1, 1) \
   F(Math_cos, 1, 1) \
   F(Math_exp, 1, 1) \
   F(Math_floor, 1, 1) \
index 54e8100..9178046 100644 (file)
@@ -242,7 +242,6 @@ namespace internal {
   SC(math_asin, V8.MathAsin)                                          \
   SC(math_atan, V8.MathAtan)                                          \
   SC(math_atan2, V8.MathAtan2)                                        \
-  SC(math_ceil, V8.MathCeil)                                          \
   SC(math_cos, V8.MathCos)                                            \
   SC(math_exp, V8.MathExp)                                            \
   SC(math_floor, V8.MathFloor)                                        \