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

Unified Diff: src/runtime.cc

Issue 66703005: Increase precision when finding the remainder after division by pi/2. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 213166a92d48f212d89ad23589505efd7e6a1eea..7a70e825a97e494d0f7bde5297c362ca285ff543 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -6874,6 +6874,31 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateHeapNumber) {
}
+static int HexToInt(uint16_t c) {
+ if (c >= '0' && c <= '9') return c - '0';
+ ASSERT(c >= 'a' && c <= 'f');
+ return c - 'a' + 10;
+}
+
+
+RUNTIME_FUNCTION(MaybeObject*, Runtime_HeapNumberFromHex) {
+ SealHandleScope shs(isolate);
+ ASSERT(args.length() == 1);
+ CONVERT_ARG_CHECKED(String, input, 0);
+ RUNTIME_ASSERT(input->length() == 16);
+ // Only used during bootstrapping.
+ RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
+ double result = 0;
+ uint8_t* bytes = reinterpret_cast<uint8_t*>(&result);
Jakob Kummerow 2013/11/19 17:49:54 Are you sure this compiles? AFAIK this is what we
+ // Input string is a little-endian hex representation of the double value.
+ for (int i = 0; i < 8; i++) {
+ bytes[i] = HexToInt(input->Get(2 * i)) * 16 +
+ HexToInt(input->Get(2 * i + 1));
+ }
+ return isolate->heap()->AllocateHeapNumber(result);
+}
+
+
RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) {
SealHandleScope shs(isolate);
ASSERT(args.length() == 2);

Powered by Google App Engine
This is Rietveld 408576698