Reviewers: Jakob,

Description:
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.

Please review this at https://codereview.chromium.org/88053002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+2, -13 lines):
  M src/math.js
  M src/runtime.h
  M src/runtime.cc
  M src/v8-counters.h


Index: src/math.js
diff --git a/src/math.js b/src/math.js
index 789886e2d1c4abf87d0bb2ba5612e35f1f263e33..5cbe94a35c7be9d71024a39b266ec8e920e022b6 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);
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 67e5e9e3dfaf84a7d2c2c57ab51c41cc7a408105..fbe4426a2855ae2fb795edf3be00e13928944b3a 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);
Index: src/runtime.h
diff --git a/src/runtime.h b/src/runtime.h
index 69783f4abe8a3c8114031c352e94d5020117a20b..62c52a7de061d5d0384ac44ac368054bcac86d91 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) \
Index: src/v8-counters.h
diff --git a/src/v8-counters.h b/src/v8-counters.h
index 54e8100bcce4a760b601a89507ed276cc7115cf0..9178046d6ed48491d872759a4c6db9143f366815 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)                                        \


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to