From: svenpanne@chromium.org Date: Tue, 26 Nov 2013 12:29:47 +0000 (+0000) Subject: Implement Math.ceil via Math.floor. X-Git-Tag: upstream/4.7.83~11548 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=afdf6156833b8400d15a633a47dee956139d524c;p=platform%2Fupstream%2Fv8.git Implement Math.ceil via Math.floor. 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 --- diff --git a/src/math.js b/src/math.js index 789886e..5cbe94a 100644 --- a/src/math.js +++ b/src/math.js @@ -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); diff --git a/src/runtime.cc b/src/runtime.cc index 67e5e9e..fbe4426 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -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); diff --git a/src/runtime.h b/src/runtime.h index 69783f4..62c52a7 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -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) \ diff --git a/src/v8-counters.h b/src/v8-counters.h index 54e8100..9178046 100644 --- a/src/v8-counters.h +++ b/src/v8-counters.h @@ -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) \