From 789c36a4599727e5ac4f99f9f9cc51297ac6f286 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 2 Jan 2014 18:00:53 -0700 Subject: [PATCH] move Unsafe.putObjectVolatile and putOrderedObject implementations This makes them available to all class libraries, not just OpenJDK. --- classpath/sun/misc/Unsafe.java | 4 ++++ src/builtin.cpp | 20 ++++++++++++++++++++ src/classpath-openjdk.cpp | 20 -------------------- 3 files changed, 24 insertions(+), 20 deletions(-) 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*)