mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
fix sun.misc.Unsafe.getLongVolatile for static fields on 32-bit platforms
The existing code did not handle static field lookups for synchronization on 32-bit systems, which is necessary because such systems generally don't support atomic operations on 64-bit values.
This commit is contained in:
parent
90fa4c9b69
commit
c918cbced1
@ -2292,11 +2292,28 @@ fieldForOffsetInClass(Thread* t, object c, unsigned offset)
|
|||||||
object
|
object
|
||||||
fieldForOffset(Thread* t, object o, unsigned offset)
|
fieldForOffset(Thread* t, object o, unsigned offset)
|
||||||
{
|
{
|
||||||
object field = fieldForOffsetInClass(t, objectClass(t, o), offset);
|
object c = objectClass(t, o);
|
||||||
if (field) {
|
if (classVmFlags(t, c) & SingletonFlag) {
|
||||||
return field;
|
c = singletonObject(t, o, 0);
|
||||||
} else {
|
object table = classFieldTable(t, c);
|
||||||
|
if (table) {
|
||||||
|
for (unsigned i = 0; i < objectArrayLength(t, table); ++i) {
|
||||||
|
object field = objectArrayBody(t, table, i);
|
||||||
|
if ((fieldFlags(t, field) & ACC_STATIC)
|
||||||
|
and fieldOffset(t, field) == offset)
|
||||||
|
{
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
abort(t);
|
abort(t);
|
||||||
|
} else {
|
||||||
|
object field = fieldForOffsetInClass(t, c, offset);
|
||||||
|
if (field) {
|
||||||
|
return field;
|
||||||
|
} else {
|
||||||
|
abort(t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1128,7 +1128,7 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool)
|
|||||||
|
|
||||||
unsigned count = s.read2();
|
unsigned count = s.read2();
|
||||||
if (count) {
|
if (count) {
|
||||||
unsigned staticOffset = BytesPerWord * 2;
|
unsigned staticOffset = BytesPerWord * 3;
|
||||||
unsigned staticCount = 0;
|
unsigned staticCount = 0;
|
||||||
|
|
||||||
object fieldTable = makeArray(t, count);
|
object fieldTable = makeArray(t, count);
|
||||||
@ -1242,7 +1242,10 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool)
|
|||||||
uint8_t* body = reinterpret_cast<uint8_t*>
|
uint8_t* body = reinterpret_cast<uint8_t*>
|
||||||
(&singletonBody(t, staticTable, 0));
|
(&singletonBody(t, staticTable, 0));
|
||||||
|
|
||||||
for (unsigned i = 0, offset = 0; i < staticCount; ++i) {
|
memcpy(body, &class_, BytesPerWord);
|
||||||
|
singletonMarkObject(t, staticTable, 0);
|
||||||
|
|
||||||
|
for (unsigned i = 0, offset = BytesPerWord; i < staticCount; ++i) {
|
||||||
unsigned size = fieldSize(t, RUNTIME_ARRAY_BODY(staticTypes)[i]);
|
unsigned size = fieldSize(t, RUNTIME_ARRAY_BODY(staticTypes)[i]);
|
||||||
while (offset % size) {
|
while (offset % size) {
|
||||||
++ offset;
|
++ offset;
|
||||||
|
Loading…
Reference in New Issue
Block a user