From 6dc9c986049add78f85c46323da8367debcaa774 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 20 Jun 2011 14:24:11 -0600 Subject: [PATCH] fix Set[Static]DoubleField regression for 32-bit platforms We were truncating 64-bit doubles to 32-bit values with zany results. --- src/jnienv.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 1772f7b39e..d797b3092c 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -1631,7 +1631,7 @@ setDoubleField(Thread* t, uintptr_t* arguments) { jobject o = reinterpret_cast(arguments[0]); object field = getField(t, arguments[1]); - jdouble v = bitsToDouble(arguments[2]); + jdouble v; memcpy(&v, arguments + 2, sizeof(jdouble)); PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); @@ -1644,9 +1644,10 @@ setDoubleField(Thread* t, uintptr_t* arguments) void JNICALL SetDoubleField(Thread* t, jobject o, jfieldID field, jdouble v) { - uintptr_t arguments[] = { reinterpret_cast(o), - field, - doubleToBits(v) }; + uintptr_t arguments[2 + (sizeof(jdouble) / BytesPerWord)]; + arguments[0] = reinterpret_cast(o); + arguments[1] = field; + memcpy(arguments + 2, &v, sizeof(jdouble)); run(t, setDoubleField, arguments); } @@ -2133,7 +2134,7 @@ setStaticDoubleField(Thread* t, uintptr_t* arguments) initClass(t, jclassVmClass(t, *c)); object field = getStaticField(t, arguments[1]); - jdouble v = bitsToDouble(arguments[2]); + jdouble v; memcpy(&v, arguments + 2, sizeof(jdouble)); PROTECT(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field); @@ -2147,9 +2148,10 @@ setStaticDoubleField(Thread* t, uintptr_t* arguments) void JNICALL SetStaticDoubleField(Thread* t, jobject c, jfieldID field, jdouble v) { - uintptr_t arguments[] = { reinterpret_cast(c), - field, - doubleToBits(v) }; + uintptr_t arguments[2 + (sizeof(jdouble) / BytesPerWord)]; + arguments[0] = reinterpret_cast(c); + arguments[1] = field; + memcpy(arguments + 2, &v, sizeof(jdouble)); run(t, setStaticDoubleField, arguments); }