Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1772)

Unified Diff: src/runtime.cc

Issue 183743018: Harmony: implement Math.cbrt in Javascript. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 24dc60f0bc5b76cbe3963a20e5bff4f958739afc..46021ad9bb6f5c46529846c501ff718b33771589 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -7708,36 +7708,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ConstructDouble) {
}
-// Cube root approximation, refer to: http://metamerist.com/cbrt/cbrt.htm
-// Using initial approximation adapted from Kahan's cbrt and 4 iterations
-// of Newton's method.
-inline double CubeRootNewtonIteration(double approx, double x) {
- return (1.0 / 3.0) * (x / (approx * approx) + 2 * approx);
-}
-
-
-inline double CubeRoot(double x) {
- static const uint64_t magic = V8_2PART_UINT64_C(0x2A9F7893, 00000000);
- uint64_t xhigh = double_to_uint64(x);
- double approx = uint64_to_double(xhigh / 3 + magic);
-
- approx = CubeRootNewtonIteration(approx, x);
- approx = CubeRootNewtonIteration(approx, x);
- approx = CubeRootNewtonIteration(approx, x);
- return CubeRootNewtonIteration(approx, x);
-}
-
-
-RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cbrt) {
- SealHandleScope shs(isolate);
- ASSERT(args.length() == 1);
- CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- if (x == 0 || std::isinf(x)) return args[0];
- double result = (x > 0) ? CubeRoot(x) : -CubeRoot(-x);
- return isolate->heap()->AllocateHeapNumber(result);
-}
-
-
RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log1p) {
SealHandleScope shs(isolate);
ASSERT(args.length() == 1);
« no previous file with comments | « src/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698