diff --git a/compiler/rt/libcore/libdvm/src/main/java/sun/misc/Unsafe.java b/compiler/rt/libcore/libdvm/src/main/java/sun/misc/Unsafe.java index 3d42dc0c1..d0f79ac24 100755 --- a/compiler/rt/libcore/libdvm/src/main/java/sun/misc/Unsafe.java +++ b/compiler/rt/libcore/libdvm/src/main/java/sun/misc/Unsafe.java @@ -260,6 +260,15 @@ public native void putObjectVolatile(Object obj, long offset, */ public native byte getByte(Object obj, long offset); + /** + * Gets a double field from the given object. + * + * @param obj non-null; object containing the field + * @param offset offset to the field within obj + * @return the retrieved value + */ + public native double getDouble(Object obj, long offset); + /** * Stores an int field into the given object. * @@ -287,6 +296,15 @@ public native void putObjectVolatile(Object obj, long offset, */ public native void putByte(Object obj, long offset, byte newValue); + /** + * Stores a double field into the given object. + * + * @param obj non-null; object containing the field + * @param offset offset to the field within obj + * @param newValue the value to store + */ + public native void putDouble(Object obj, long offset, double newValue); + /** * Gets an float field from the given object. * diff --git a/compiler/vm/rt/robovm/sun_misc_Unsafe.c b/compiler/vm/rt/robovm/sun_misc_Unsafe.c index fd4db0707..32f36fc73 100755 --- a/compiler/vm/rt/robovm/sun_misc_Unsafe.c +++ b/compiler/vm/rt/robovm/sun_misc_Unsafe.c @@ -110,6 +110,12 @@ jbyte Java_sun_misc_Unsafe_getByte(Env* env, Object* unsafe, Object* obj, jlong return *address; } +jdouble Java_sun_misc_Unsafe_getDouble(Env* env, Object* unsafe, Object* obj, jlong offset) { + if (!checkNull(env, obj)) return 0; + jdouble* address = (jdouble*) getFieldAddress(obj, offset); + return *address; +} + jint Java_sun_misc_Unsafe_getIntVolatile(Env* env, Object* unsafe, Object* obj, jlong offset) { if (!checkNull(env, obj)) return 0; jint* address = (jint*) getFieldAddress(obj, offset); @@ -164,6 +170,12 @@ void Java_sun_misc_Unsafe_putByte(Env* env, Object* unsafe, Object* obj, jlong o *address = newValue; } +void Java_sun_misc_Unsafe_putDouble(Env* env, Object* unsafe, Object* obj, jlong offset, jdouble newValue) { + if (!checkNull(env, obj)) return; + jdouble* address = (jdouble*) getFieldAddress(obj, offset); + *address = newValue; +} + void Java_sun_misc_Unsafe_putIntVolatile(Env* env, Object* unsafe, Object* obj, jlong offset, jint newValue) { if (!checkNull(env, obj)) return; jint* address = (jint*) getFieldAddress(obj, offset);