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

Unified Diff: src/conversions-inl.h

Issue 1148007: Merge bleeding_edge from version 2.1.3 up to revision 4205... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 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/conversions.cc ('k') | src/counters.h » ('j') | src/heap.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/conversions-inl.h
===================================================================
--- src/conversions-inl.h (revision 4205)
+++ src/conversions-inl.h (working copy)
@@ -60,7 +60,8 @@
// The fast double-to-unsigned-int conversion routine does not guarantee
-// rounding towards zero.
+// rounding towards zero, or any reasonable value if the argument is larger
+// than what fits in an unsigned 32-bit integer.
static inline unsigned int FastD2UI(double x) {
// There is no unsigned version of lrint, so there is no fast path
// in this function as there is in FastD2I. Using lrint doesn't work
@@ -77,7 +78,13 @@
if (x < k2Pow52) {
x += k2Pow52;
uint32_t result;
- memcpy(&result, &x, sizeof(result)); // Copy low 32 bits.
+#ifdef BIG_ENDIAN_FLOATING_POINT
+ Address mantissa_ptr = reinterpret_cast<Address>(&x) + kIntSize;
+#else
+ Address mantissa_ptr = reinterpret_cast<Address>(&x);
+#endif
+ // Copy least significant 32 bits of mantissa.
+ memcpy(&result, mantissa_ptr, sizeof(result));
return negative ? ~result + 1 : result;
}
// Large number (outside uint32 range), Infinity or NaN.
« no previous file with comments | « src/conversions.cc ('k') | src/counters.h » ('j') | src/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698