final VmField field = fieldRef.getResolvedVmField();
if (field.isStatic()) {
throw new IncompatibleClassChangeError(
"getfield called on static field " + fieldRef.getName());
}
final VmInstanceField inf = (VmInstanceField) field;
final int offset = inf.getOffset();
final boolean wide = fieldRef.isWide();
// Get operands
final Item val = vstack.pop();
assertCondition(val.getCategory() == ((wide) ? 2 : 1),
"category mismatch");
final RefItem ref = vstack.popRef();
// Load value & ref
val.load(eContext);
ref.load(eContext);
final GPR refr = ref.getRegister();
if (!wide) {
final WordItem wval = (WordItem) val;
final GPR valr = wval.getRegister();
final char fieldType = field.getSignature().charAt(0);
// Store field
switch (fieldType) {
case 'Z': // boolean
case 'B': // byte
wval.loadToBITS8GPR(eContext);
os.writeMOV(BITS8, refr, offset, wval.getRegister());
break;
case 'C': // char
case 'S': // short
os.writeMOV(BITS16, refr, offset, valr);
break;
case 'F': // float
case 'I': // int
case 'L': // Object
case '[': // array
os.writeMOV(valr.getSize(), refr, offset, valr);
break;
default:
throw new IllegalArgumentException("Unknown fieldType: " + fieldType);
}
// Writebarrier
if (!inf.isPrimitive() && helper.needsWriteBarrier()) {
final GPR tmp = (GPR) L1AHelper.requestRegister(eContext,
JvmType.REFERENCE, false);
helper.writePutfieldWriteBarrier(inf, refr, valr, tmp);
L1AHelper.releaseRegister(eContext, tmp);
}