mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
implement Unsafe.putOrderedLong and putVolatileLong
The former just defers to the latter for now, since it provides strictly weaker guarantees. Thus it's correct to use full volatile-style barriers, though not as efficient as it could be on some architectures.
This commit is contained in:
parent
ab4adef373
commit
cc5b58725a
@ -50,6 +50,10 @@ public final class Unsafe {
|
|||||||
|
|
||||||
public native long getLongVolatile(Object o, long offset);
|
public native long getLongVolatile(Object o, long offset);
|
||||||
|
|
||||||
|
public native long putLongVolatile(Object o, long offset, long x);
|
||||||
|
|
||||||
|
public native long putOrderedLong(Object o, long offset, long x);
|
||||||
|
|
||||||
public native void putOrderedInt(Object o, long offset, int x);
|
public native void putOrderedInt(Object o, long offset, int x);
|
||||||
|
|
||||||
public native Object getObject(Object o, long offset);
|
public native Object getObject(Object o, long offset);
|
||||||
|
@ -784,6 +784,42 @@ Avian_sun_misc_Unsafe_getLongVolatile
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" AVIAN_EXPORT void JNICALL
|
||||||
|
Avian_sun_misc_Unsafe_putLongVolatile
|
||||||
|
(Thread* t, object, uintptr_t* arguments)
|
||||||
|
{
|
||||||
|
object o = reinterpret_cast<object>(arguments[1]);
|
||||||
|
int64_t offset; memcpy(&offset, arguments + 2, 8);
|
||||||
|
int64_t value; memcpy(&value, arguments + 4, 8);
|
||||||
|
|
||||||
|
object field;
|
||||||
|
if (BytesPerWord < 8) {
|
||||||
|
field = fieldForOffset(t, o, offset);
|
||||||
|
|
||||||
|
PROTECT(t, field);
|
||||||
|
acquire(t, field);
|
||||||
|
} else {
|
||||||
|
storeStoreMemoryBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldAtOffset<int64_t>(o, offset) = value;
|
||||||
|
|
||||||
|
if (BytesPerWord < 8) {
|
||||||
|
release(t, field);
|
||||||
|
} else {
|
||||||
|
storeLoadMemoryBarrier();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" AVIAN_EXPORT void JNICALL
|
||||||
|
Avian_sun_misc_Unsafe_putOrderedLong
|
||||||
|
(Thread* t, object method, uintptr_t* arguments)
|
||||||
|
{
|
||||||
|
// todo: we might be able to use weaker barriers here than
|
||||||
|
// putLongVolatile does
|
||||||
|
Avian_sun_misc_Unsafe_putLongVolatile(t, method, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" AVIAN_EXPORT void JNICALL
|
extern "C" AVIAN_EXPORT void JNICALL
|
||||||
Avian_sun_misc_Unsafe_unpark
|
Avian_sun_misc_Unsafe_unpark
|
||||||
(Thread* t, object, uintptr_t* arguments)
|
(Thread* t, object, uintptr_t* arguments)
|
||||||
|
Loading…
Reference in New Issue
Block a user