diff --git a/classpath/sun/misc/Unsafe.java b/classpath/sun/misc/Unsafe.java index a03bf3db71..21c7c43d62 100644 --- a/classpath/sun/misc/Unsafe.java +++ b/classpath/sun/misc/Unsafe.java @@ -60,6 +60,10 @@ public final class Unsafe { public native void putObject(Object o, long offset, Object x); + public native void putObjectVolatile(Object o, long offset, Object x); + + public native void putOrderedObject(Object o, long offset, Object x); + public native long getAddress(long address); public native void putAddress(long address, long x); diff --git a/src/builtin.cpp b/src/builtin.cpp index 9940b53c7b..f5733f6ec3 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -703,6 +703,26 @@ Avian_sun_misc_Unsafe_putObject set(t, o, offset, reinterpret_cast(value)); } +extern "C" AVIAN_EXPORT void JNICALL +Avian_sun_misc_Unsafe_putObjectVolatile +(Thread* t, object, uintptr_t* arguments) +{ + object o = reinterpret_cast(arguments[1]); + int64_t offset; memcpy(&offset, arguments + 2, 8); + object value = reinterpret_cast(arguments[4]); + + storeStoreMemoryBarrier(); + set(t, o, offset, reinterpret_cast(value)); + storeLoadMemoryBarrier(); +} + +extern "C" AVIAN_EXPORT void JNICALL +Avian_sun_misc_Unsafe_putOrderedObject +(Thread* t, object method, uintptr_t* arguments) +{ + Avian_sun_misc_Unsafe_putObjectVolatile(t, method, arguments); +} + extern "C" AVIAN_EXPORT int64_t JNICALL Avian_sun_misc_Unsafe_compareAndSwapObject (Thread* t, object, uintptr_t* arguments) diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index ac406b3adb..f802abd347 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -2794,26 +2794,6 @@ Avian_sun_misc_Unsafe_getObjectVolatile return value; } -extern "C" AVIAN_EXPORT void JNICALL -Avian_sun_misc_Unsafe_putObjectVolatile -(Thread* t, object, uintptr_t* arguments) -{ - object o = reinterpret_cast(arguments[1]); - int64_t offset; memcpy(&offset, arguments + 2, 8); - object value = reinterpret_cast(arguments[4]); - - storeStoreMemoryBarrier(); - set(t, o, offset, reinterpret_cast(value)); - storeLoadMemoryBarrier(); -} - -extern "C" AVIAN_EXPORT void JNICALL -Avian_sun_misc_Unsafe_putOrderedObject -(Thread* t, object method, uintptr_t* arguments) -{ - Avian_sun_misc_Unsafe_putObjectVolatile(t, method, arguments); -} - extern "C" AVIAN_EXPORT int64_t JNICALL Avian_sun_misc_Unsafe_pageSize (Thread*, object, uintptr_t*)