/** * Assigns registers to locals. From the spec: * "the N arguments to a method land in the last N registers of the * method's invocation frame, in order. Wide arguments consume two * registers. Instance methods are passed a this reference as their * first argument." * * In addition to assigning registers to each of the locals, this creates * instructions to move parameters into their initial registers. These * instructions are inserted before the code's first real instruction. */ void initializeLocals() { if (localsInitialized) { throw new AssertionError(); } localsInitialized = true; int reg = 0; for (Local<?> local : locals) { reg += local.initialize(reg); } int firstParamReg = reg; List<Insn> moveParameterInstructions = new ArrayList<Insn>(); for (Local<?> local : parameters) { CstInteger paramConstant = CstInteger.make(reg - firstParamReg); reg += local.initialize(reg); moveParameterInstructions.add(new PlainCstInsn(Rops.opMoveParam(local.type.ropType), sourcePosition, local.spec(), RegisterSpecList.EMPTY, paramConstant)); } labels.get(0).instructions.addAll(0, moveParameterInstructions); }
/** * Copies the constant value {@code value} to {@code target}. The constant * must be a primitive, String, Class, TypeId, or null. */ public <T> void loadConstant(Local<T> target, T value) { Rop rop = value == null ? Rops.CONST_OBJECT_NOTHROW : Rops.opConst(target.type.ropType); if (rop.getBranchingness() == BRANCH_NONE) { addInstruction(new PlainCstInsn(rop, sourcePosition, target.spec(), RegisterSpecList.EMPTY, Constants.getConstant(value))); } else { addInstruction(new ThrowingCstInsn(rop, sourcePosition, RegisterSpecList.EMPTY, catches, Constants.getConstant(value))); moveResult(target, true); } }
/** {@inheritDoc} */ @Override public Insn withNewRegisters(RegisterSpec result, RegisterSpecList sources) { return new PlainCstInsn(getOpcode(), getPosition(), result, sources, getConstant()); } }
/** {@inheritDoc} */ @Override public Insn withNewRegisters(RegisterSpec result, RegisterSpecList sources) { return new PlainCstInsn(getOpcode(), getPosition(), result, sources, getConstant()); } }
/** {@inheritDoc} */ @Override public Insn withNewRegisters(RegisterSpec result, RegisterSpecList sources) { return new PlainCstInsn(getOpcode(), getPosition(), result, sources, getConstant()); } }
/** {@inheritDoc} */ @Override public Insn withNewRegisters(RegisterSpec result, RegisterSpecList sources) { return new PlainCstInsn(getOpcode(), getPosition(), result, sources, getConstant()); } }
/** {@inheritDoc} */ @Override public Insn withNewRegisters(RegisterSpec result, RegisterSpecList sources) { return new PlainCstInsn(getOpcode(), getPosition(), result, sources, getConstant()); } }
/** {@inheritDoc} */ @Override public Insn withNewRegisters(RegisterSpec result, RegisterSpecList sources) { return new PlainCstInsn(getOpcode(), getPosition(), result, sources, getConstant()); } }
/** {@inheritDoc} */ @Override public Insn withNewRegisters(RegisterSpec result, RegisterSpecList sources) { return new PlainCstInsn(getOpcode(), getPosition(), result, sources, getConstant()); } }
/** {@inheritDoc} */ @Override public Insn withNewRegisters(RegisterSpec result, RegisterSpecList sources) { return new PlainCstInsn(getOpcode(), getPosition(), result, sources, getConstant()); } }
/** {@inheritDoc} */ @Override public Insn withRegisterOffset(int delta) { return new PlainCstInsn(getOpcode(), getPosition(), getResult().withOffset(delta), getSources().withOffset(delta), getConstant()); }
/** {@inheritDoc} */ @Override public Insn withRegisterOffset(int delta) { return new PlainCstInsn(getOpcode(), getPosition(), getResult().withOffset(delta), getSources().withOffset(delta), getConstant()); }
/** {@inheritDoc} */ @Override public Insn withRegisterOffset(int delta) { return new PlainCstInsn(getOpcode(), getPosition(), getResult().withOffset(delta), getSources().withOffset(delta), getConstant()); }
/** {@inheritDoc} */ @Override public Insn withRegisterOffset(int delta) { return new PlainCstInsn(getOpcode(), getPosition(), getResult().withOffset(delta), getSources().withOffset(delta), getConstant()); }
/** {@inheritDoc} */ @Override public Insn withRegisterOffset(int delta) { return new PlainCstInsn(getOpcode(), getPosition(), getResult().withOffset(delta), getSources().withOffset(delta), getConstant()); }
/** {@inheritDoc} */ @Override public Insn withRegisterOffset(int delta) { return new PlainCstInsn(getOpcode(), getPosition(), getResult().withOffset(delta), getSources().withOffset(delta), getConstant()); }
/** {@inheritDoc} */ @Override public Insn withRegisterOffset(int delta) { return new PlainCstInsn(getOpcode(), getPosition(), getResult().withOffset(delta), getSources().withOffset(delta), getConstant()); }
/** {@inheritDoc} */ @Override public Insn withRegisterOffset(int delta) { return new PlainCstInsn(getOpcode(), getPosition(), getResult().withOffset(delta), getSources().withOffset(delta), getConstant()); }
public <T> void loadConstant(Local<T> target, T value) { Rop rop = Rops.opConst(target.type.ropType); if (rop.getBranchingness() == BRANCH_NONE) { addInstruction(new PlainCstInsn(rop, sourcePosition, target.spec(), RegisterSpecList.EMPTY, Constants.getConstant(value))); } else { addInstruction(new ThrowingCstInsn(rop, sourcePosition, RegisterSpecList.EMPTY, catches, Constants.getConstant(value))); moveResult(target, true); } }
/** * Copies the constant value {@code value} to {@code target}. The constant must be a primitive, String, Class, TypeId, or null. */ public <T> void loadConstant(Local<T> target, T value) { Rop rop = value == null ? Rops.CONST_OBJECT_NOTHROW : Rops.opConst(target.type.ropType); if (rop.getBranchingness() == BRANCH_NONE) { addInstruction(new PlainCstInsn(rop, sourcePosition, target.spec(), RegisterSpecList.EMPTY, Constants.getConstant(value))); } else { addInstruction(new ThrowingCstInsn(rop, sourcePosition, RegisterSpecList.EMPTY, catches, Constants.getConstant(value))); moveResult(target, true); } }