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