diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -1017,6 +1017,25 @@
};
#endif
+#ifdef SPARC
+// Simulate x86 overflow behavior
+template<>
+struct ConvertImpl<JSUint64, jsdouble> {
+ static JS_ALWAYS_INLINE JSUint64 Convert(jsdouble d) {
+ return d >= 0xffffffffffffffff ?
+ 0x8000000000000000 : JSUint64(d);
+ }
+};
+
+template<>
+struct ConvertImpl<JSInt64, jsdouble> {
+ static JS_ALWAYS_INLINE JSInt64 Convert(jsdouble d) {
+ return d >= 0x7fffffffffffffff ?
+ 0x8000000000000000 : JSInt64(d);
+ }
+};
+#endif
+
template<class TargetType, class FromType>
static JS_ALWAYS_INLINE TargetType Convert(FromType d)
{