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

Unified Diff: src/runtime.cc

Issue 189823003: Reland "Introduce intrinsics for double values in Javascript." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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') | src/x64/assembler-x64.h » ('j') | 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 5fe69c26b3e0a44af6761a6ff3f5c60ae86b00eb..c0c87a457d3ad870d701f6747d23a13e644fd741 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -7665,6 +7665,35 @@ RUNTIME_UNARY_MATH(log)
#undef RUNTIME_UNARY_MATH
+RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleHi) {
+ SealHandleScope shs(isolate);
+ ASSERT(args.length() == 1);
+ CONVERT_DOUBLE_ARG_CHECKED(x, 0);
+ uint64_t integer = double_to_uint64(x);
+ integer = (integer >> 32) & 0xFFFFFFFFu;
+ return isolate->heap()->NumberFromDouble(static_cast<int32_t>(integer));
+}
+
+
+RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleLo) {
+ SealHandleScope shs(isolate);
+ ASSERT(args.length() == 1);
+ CONVERT_DOUBLE_ARG_CHECKED(x, 0);
+ return isolate->heap()->NumberFromDouble(
+ static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu));
+}
+
+
+RUNTIME_FUNCTION(MaybeObject*, Runtime_ConstructDouble) {
+ SealHandleScope shs(isolate);
+ ASSERT(args.length() == 2);
+ CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]);
+ CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]);
+ uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo;
+ return isolate->heap()->AllocateHeapNumber(uint64_to_double(result));
+}
+
+
// 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.
« no previous file with comments | « src/runtime.h ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698