val.load(eContext);  idx.loadIf(eContext, (useBarrier) ? ~Item.Kind.REGISTER : ~(Item.Kind.CONSTANT | Item.Kind.REGISTER)); ref.load(eContext); final Register r = ref.getRegister(); final Register v = val.getRegister(); checkBounds(ref, idx); if (idx.getKind() == Item.Kind.CONSTANT) { final int i = idx.getValue(); os.writeMOV(INTSIZE, r, i + VmArray.DATA_OFFSET * 4, v); } else { final Register i = idx.getRegister(); os.writeMOV(INTSIZE, r, i, 4, VmArray.DATA_OFFSET * 4, v); } if (useBarrier) {   final X86RegisterPool pool = eContext.getPool(); final Register scratch = pool.request(JvmType.INT); helper .writeArrayStoreWriteBarrier(r, idx.getRegister(), v, scratch); pool.release(scratch); }
val.load(eContext);  idx.loadIf(eContext, (useBarrier) ? ~Item.Kind.REGISTER : ~(Item.Kind.CONSTANT | Item.Kind.REGISTER)); ref.load(eContext); final Register r = ref.getRegister(); final Register v = val.getRegister(); checkBounds(ref, idx); if (idx.isConstant()) { final int i = idx.getValue(); os.writeMOV(INTSIZE, r, i + VmArray.DATA_OFFSET * 4, v); } else { final Register i = idx.getRegister(); os.writeMOV(INTSIZE, r, i, 4, VmArray.DATA_OFFSET * 4, v); } if (useBarrier) {   final X86RegisterPool pool = eContext.getPool(); final Register scratch = pool.request(JvmType.INT); helper .writeArrayStoreWriteBarrier(r, idx.getRegister(), v, scratch); pool.release(scratch); }
    public final void visit_aastore() {        final boolean useBarrier = (context.getWriteBarrier() != null);        RefItem val = vstack.popRef();        IntItem idx = vstack.popInt();        RefItem ref = vstack.popRef();        //IMPROVE: optimize case with const value        val.load(eContext);        // if barrier in use, the index must also be in a register        idx.loadIf(eContext, (useBarrier) ? ~Item.Kind.REGISTER                : ~(Item.Kind.CONSTANT | Item.Kind.REGISTER));        ref.load(eContext);        final Register r = ref.getRegister();        final Register v = val.getRegister();        checkBounds(ref, idx);        if (idx.getKind() == Item.Kind.CONSTANT) {            final int i = idx.getValue();            os.writeMOV(INTSIZE, r, i + VmArray.DATA_OFFSET * 4, v);        } else {            final Register i = idx.getRegister();            os.writeMOV(INTSIZE, r, i, 4, VmArray.DATA_OFFSET * 4, v);        }        if (useBarrier) {            // the write barrier could easily be modified to avoid using a            // scratch register            final X86RegisterPool pool = eContext.getPool();            final Register scratch = pool.request(JvmType.INT);            helper                    .writeArrayStoreWriteBarrier(r, idx.getRegister(), v,                            scratch);            pool.release(scratch);        }        val.release(eContext);        idx.release(eContext);        ref.release(eContext);    }