} else {
val.load(eContext);
}
idx.loadIf(eContext, ~Item.Kind.CONSTANT | extraLoadIdxMask);
ref.load(eContext);
final GPR refr = ref.getRegister();
final GPR valr = val.getRegister();
final X86RegisterPool pool = eContext.getGPRPool();
// Verify
checkBounds(ref, idx);
//todo spec issue: add type compatibility check (elemType <- valueType), throw ArrayStoreException
// Store
if (idx.isConstant()) {
final int offset = idx.getValue() * scale;
os.writeMOV(valSize, refr, offset + arrayDataOffset, valr);
} else {
GPR idxr = idx.getRegister();
if (os.isCode64()) {
final GPR64 idxr64 = (GPR64) pool.getRegisterInSameGroup(idxr, JvmType.LONG);
os.writeMOVSXD(idxr64, (GPR32) idxr);
idxr = idxr64;
}
os.writeMOV(valSize, refr, idxr, scale, arrayDataOffset, valr);
}
// Call write barrier (reference only)
if ((jvmType == JvmType.REFERENCE) && useBarrier) {
// the write barrier could easily be modified to avoid using a
// scratch register
final GPR idxr;
if (os.isCode32()) {
idxr = idx.getRegister();
} else {
idxr = (GPR) eContext.getGPRPool().getRegisterInSameGroup(idx.getRegister(), JvmType.LONG);
}
final GPR scratch = (GPR) pool.request(JvmType.INT);
helper.writeArrayStoreWriteBarrier(refr, idxr, valr, scratch);
pool.release(scratch);
}
// Release