move Unsafe.get{Object|Int}Volatile from classpath-openjdk.cpp to builtin.cpp

This makes them available in all class libraries, not just the OpenJDK
library.  Note that I've also removed the unecessary idle statements,
per ab4adef.
This commit is contained in:
Joel Dice 2014-03-03 14:51:43 -07:00
parent 1cd822b23e
commit 0a89683eff
3 changed files with 28 additions and 32 deletions

View File

@ -46,6 +46,8 @@ public final class Unsafe {
public native void putDouble(long address, double x);
public native int getIntVolatile(Object o, long offset);
public native void putIntVolatile(Object o, long offset, int x);
public native long getLongVolatile(Object o, long offset);
@ -64,6 +66,8 @@ public final class Unsafe {
public native void putOrderedObject(Object o, long offset, Object x);
public native Object getObjectVolatile(Object o, long offset);
public native long getAddress(long address);
public native void putAddress(long address, long x);

View File

@ -723,6 +723,18 @@ Avian_sun_misc_Unsafe_putOrderedObject
Avian_sun_misc_Unsafe_putObjectVolatile(t, method, arguments);
}
extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_sun_misc_Unsafe_getObjectVolatile
(Thread*, object, uintptr_t* arguments)
{
object o = reinterpret_cast<object>(arguments[1]);
int64_t offset; memcpy(&offset, arguments + 2, 8);
uintptr_t value = fieldAtOffset<uintptr_t>(o, offset);
loadMemoryBarrier();
return value;
}
extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_sun_misc_Unsafe_compareAndSwapObject
(Thread* t, object, uintptr_t* arguments)
@ -916,6 +928,18 @@ Avian_sun_misc_Unsafe_putOrderedInt
Avian_sun_misc_Unsafe_putIntVolatile(t, method, arguments);
}
extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_sun_misc_Unsafe_getIntVolatile
(Thread*, object, uintptr_t* arguments)
{
object o = reinterpret_cast<object>(arguments[1]);
int64_t offset; memcpy(&offset, arguments + 2, 8);
int32_t result = fieldAtOffset<int32_t>(o, offset);
loadMemoryBarrier();
return result;
}
extern "C" AVIAN_EXPORT void JNICALL
Avian_sun_misc_Unsafe_throwException
(Thread* t, object, uintptr_t* arguments)

View File

@ -2640,22 +2640,6 @@ Avian_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J
return fieldAtOffset<int32_t>(o, offset);
}
extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_sun_misc_Unsafe_getIntVolatile
(Thread* t, object, uintptr_t* arguments)
{
object o = reinterpret_cast<object>(arguments[1]);
int64_t offset; memcpy(&offset, arguments + 2, 8);
// avoid blocking the VM if this is being called in a busy loop
PROTECT(t, o);
{ ENTER(t, Thread::IdleState); }
int32_t result = fieldAtOffset<int32_t>(o, offset);
loadMemoryBarrier();
return result;
}
extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J
(Thread*, object, uintptr_t* arguments)
@ -2769,22 +2753,6 @@ Avian_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ
fieldAtOffset<int64_t>(o, offset) = value;
}
extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_sun_misc_Unsafe_getObjectVolatile
(Thread* t, object, uintptr_t* arguments)
{
object o = reinterpret_cast<object>(arguments[1]);
int64_t offset; memcpy(&offset, arguments + 2, 8);
// avoid blocking the VM if this is being called in a busy loop
PROTECT(t, o);
{ ENTER(t, Thread::IdleState); }
uintptr_t value = fieldAtOffset<uintptr_t>(o, offset);
loadMemoryBarrier();
return value;
}
extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_sun_misc_Unsafe_pageSize
(Thread*, object, uintptr_t*)