mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
Merge pull request #478 from dicej/putDouble
add sun.misc.Unsafe.putDouble(Object,long,double)
This commit is contained in:
commit
c299319b16
@ -96,6 +96,14 @@ public final class Unsafe {
|
||||
putLongVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
public double getDouble(Object o, long offset) {
|
||||
return getDoubleVolatile(o, offset);
|
||||
}
|
||||
|
||||
public void putDouble(Object o, long offset, double x) {
|
||||
putDoubleVolatile(o, offset, x);
|
||||
}
|
||||
|
||||
public native void putOrderedLong(Object o, long offset, long x);
|
||||
|
||||
public native void putOrderedInt(Object o, long offset, int x);
|
||||
|
@ -3093,6 +3093,20 @@ extern "C" AVIAN_EXPORT void JNICALL
|
||||
fieldAtOffset<int64_t>(o, offset) = value;
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT void JNICALL
|
||||
Avian_sun_misc_Unsafe_putDouble__Ljava_lang_Object_2JD(Thread*,
|
||||
object,
|
||||
uintptr_t* arguments)
|
||||
{
|
||||
object o = reinterpret_cast<object>(arguments[1]);
|
||||
int64_t offset;
|
||||
memcpy(&offset, arguments + 2, 8);
|
||||
jdouble value;
|
||||
memcpy(&value, arguments + 4, 8);
|
||||
|
||||
fieldAtOffset<jdouble>(o, offset) = value;
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
Avian_sun_misc_Unsafe_pageSize(Thread*, object, uintptr_t*)
|
||||
{
|
||||
|
@ -134,7 +134,30 @@ public class UnsafeTest {
|
||||
== 1.23456789012345D);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
private static class Data {
|
||||
public long longField;
|
||||
public double doubleField;
|
||||
}
|
||||
|
||||
private static void unsafeObject(Unsafe u) throws Exception {
|
||||
final long longOffset = u.objectFieldOffset
|
||||
(Data.class.getField("longField"));
|
||||
|
||||
final long doubleOffset = u.objectFieldOffset
|
||||
(Data.class.getField("doubleField"));
|
||||
|
||||
Data data = new Data();
|
||||
|
||||
u.putLong(data, longOffset, 0x1234567890ABCDEFL);
|
||||
|
||||
u.putDouble(data, doubleOffset, 1.23456789012345D);
|
||||
|
||||
expect(u.getLong(data, longOffset) == 0x1234567890ABCDEFL);
|
||||
|
||||
expect(u.getDouble(data, doubleOffset) == 1.23456789012345D);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("method count is "
|
||||
+ Unsafe.class.getDeclaredMethods().length);
|
||||
|
||||
@ -143,5 +166,6 @@ public class UnsafeTest {
|
||||
unsafeCatch(u);
|
||||
unsafeMemory(u);
|
||||
unsafeArray(u);
|
||||
unsafeObject(u);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user