mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
tolerate ConstantValue attributes on non-static fields, since the compiler ensures that they are initialized in any constructors for that class (i.e., the VM does not need to do anything special to initialize them)
This commit is contained in:
parent
e86acf4543
commit
54ad7c4e98
@ -2488,6 +2488,8 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
Compiler::Operand* table;
|
Compiler::Operand* table;
|
||||||
|
|
||||||
if (instruction == getstatic) {
|
if (instruction == getstatic) {
|
||||||
|
assert(t, fieldFlags(t, field) & ACC_STATIC);
|
||||||
|
|
||||||
if (fieldClass(t, field) != methodClass(t, context->method)
|
if (fieldClass(t, field) != methodClass(t, context->method)
|
||||||
and classNeedsInit(t, fieldClass(t, field)))
|
and classNeedsInit(t, fieldClass(t, field)))
|
||||||
{
|
{
|
||||||
@ -2501,6 +2503,8 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
|
|
||||||
table = frame->append(classStaticTable(t, fieldClass(t, field)));
|
table = frame->append(classStaticTable(t, fieldClass(t, field)));
|
||||||
} else {
|
} else {
|
||||||
|
assert(t, (fieldFlags(t, field) & ACC_STATIC) == 0);
|
||||||
|
|
||||||
table = frame->popObject();
|
table = frame->popObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3369,6 +3373,8 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
object staticTable = 0;
|
object staticTable = 0;
|
||||||
|
|
||||||
if (instruction == putstatic) {
|
if (instruction == putstatic) {
|
||||||
|
assert(t, fieldFlags(t, field) & ACC_STATIC);
|
||||||
|
|
||||||
if (fieldClass(t, field) != methodClass(t, context->method)
|
if (fieldClass(t, field) != methodClass(t, context->method)
|
||||||
and classNeedsInit(t, fieldClass(t, field)))
|
and classNeedsInit(t, fieldClass(t, field)))
|
||||||
{
|
{
|
||||||
@ -3381,6 +3387,8 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
}
|
}
|
||||||
|
|
||||||
staticTable = classStaticTable(t, fieldClass(t, field));
|
staticTable = classStaticTable(t, fieldClass(t, field));
|
||||||
|
} else {
|
||||||
|
assert(t, (fieldFlags(t, field) & ACC_STATIC) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Compiler::Operand* value;
|
Compiler::Operand* value;
|
||||||
|
@ -1454,6 +1454,8 @@ interpret(Thread* t)
|
|||||||
if (UNLIKELY(exception)) goto throw_;
|
if (UNLIKELY(exception)) goto throw_;
|
||||||
if (throwIfVolatileField(t, field)) goto throw_;
|
if (throwIfVolatileField(t, field)) goto throw_;
|
||||||
|
|
||||||
|
assert(t, (fieldFlags(t, field) & ACC_STATIC) == 0);
|
||||||
|
|
||||||
pushField(t, popObject(t), field);
|
pushField(t, popObject(t), field);
|
||||||
} else {
|
} else {
|
||||||
exception = makeNullPointerException(t);
|
exception = makeNullPointerException(t);
|
||||||
@ -1468,6 +1470,8 @@ interpret(Thread* t)
|
|||||||
if (UNLIKELY(exception)) goto throw_;
|
if (UNLIKELY(exception)) goto throw_;
|
||||||
if (throwIfVolatileField(t, field)) goto throw_;
|
if (throwIfVolatileField(t, field)) goto throw_;
|
||||||
|
|
||||||
|
assert(t, fieldFlags(t, field) & ACC_STATIC);
|
||||||
|
|
||||||
PROTECT(t, field);
|
PROTECT(t, field);
|
||||||
|
|
||||||
if (UNLIKELY(classInit(t, fieldClass(t, field), 3))) goto invoke;
|
if (UNLIKELY(classInit(t, fieldClass(t, field), 3))) goto invoke;
|
||||||
@ -2401,6 +2405,8 @@ interpret(Thread* t)
|
|||||||
if (UNLIKELY(exception)) goto throw_;
|
if (UNLIKELY(exception)) goto throw_;
|
||||||
if (throwIfVolatileField(t, field)) goto throw_;
|
if (throwIfVolatileField(t, field)) goto throw_;
|
||||||
|
|
||||||
|
assert(t, (fieldFlags(t, field) & ACC_STATIC) == 0);
|
||||||
|
|
||||||
switch (fieldCode(t, field)) {
|
switch (fieldCode(t, field)) {
|
||||||
case ByteField:
|
case ByteField:
|
||||||
case BooleanField:
|
case BooleanField:
|
||||||
@ -2467,6 +2473,8 @@ interpret(Thread* t)
|
|||||||
if (UNLIKELY(exception)) goto throw_;
|
if (UNLIKELY(exception)) goto throw_;
|
||||||
if (throwIfVolatileField(t, field)) goto throw_;
|
if (throwIfVolatileField(t, field)) goto throw_;
|
||||||
|
|
||||||
|
assert(t, fieldFlags(t, field) & ACC_STATIC);
|
||||||
|
|
||||||
PROTECT(t, field);
|
PROTECT(t, field);
|
||||||
|
|
||||||
if (UNLIKELY(classInit(t, fieldClass(t, field), 3))) goto invoke;
|
if (UNLIKELY(classInit(t, fieldClass(t, field), 3))) goto invoke;
|
||||||
|
@ -835,10 +835,6 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool)
|
|||||||
|
|
||||||
staticTypes[staticCount++] = code;
|
staticTypes[staticCount++] = code;
|
||||||
} else {
|
} else {
|
||||||
if (value) {
|
|
||||||
abort(t); // todo: handle non-static field initializers
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned excess = (memberOffset % fieldSize(t, code)) % BytesPerWord;
|
unsigned excess = (memberOffset % fieldSize(t, code)) % BytesPerWord;
|
||||||
if (excess) {
|
if (excess) {
|
||||||
memberOffset += BytesPerWord - excess;
|
memberOffset += BytesPerWord - excess;
|
||||||
|
@ -3,6 +3,8 @@ public class Misc {
|
|||||||
private static int beta;
|
private static int beta;
|
||||||
private static byte byte1, byte2, byte3;
|
private static byte byte1, byte2, byte3;
|
||||||
|
|
||||||
|
private final int NonStaticConstant = 42;
|
||||||
|
|
||||||
private int gamma;
|
private int gamma;
|
||||||
private int pajama;
|
private int pajama;
|
||||||
private boolean boolean1;
|
private boolean boolean1;
|
||||||
@ -338,6 +340,8 @@ public class Misc {
|
|||||||
{ Misc m = new Misc();
|
{ Misc m = new Misc();
|
||||||
m.toString();
|
m.toString();
|
||||||
|
|
||||||
|
expect(m.NonStaticConstant == 42);
|
||||||
|
|
||||||
expect(m.time == 0xffffffffffffffffL);
|
expect(m.time == 0xffffffffffffffffL);
|
||||||
long t = m.time;
|
long t = m.time;
|
||||||
expect(t == 0xffffffffffffffffL);
|
expect(t == 0xffffffffffffffffL);
|
||||||
|
Loading…
Reference in New Issue
Block a user