switch (insn.getOpcode().getBranchingness()) { case BRANCH_NONE: if (branch != null) {
/** * 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); } }
/** * Executes {@code op} and sets {@code target} to the result. For most * binary operations, the types of {@code a} and {@code b} must be the same. * Shift operations (like {@link BinaryOp#SHIFT_LEFT}) require {@code b} to * be an {@code int}, even when {@code a} is a {@code long}. */ public <T1, T2> void op(BinaryOp op, Local<T1> target, Local<T1> a, Local<T2> b) { Rop rop = op.rop(StdTypeList.make(a.type.ropType, b.type.ropType)); RegisterSpecList sources = RegisterSpecList.make(a.spec(), b.spec()); if (rop.getBranchingness() == BRANCH_NONE) { addInstruction(new PlainInsn(rop, sourcePosition, target.spec(), sources)); } else { addInstruction(new ThrowingInsn(rop, sourcePosition, sources, catches)); moveResult(target, true); } }
/** * Constructs an instance. * * @param opcode {@code non-null;} the opcode * @param position {@code non-null;} source position * @param result {@code null-ok;} spec for the result, if any * @param sources {@code non-null;} specs for all the sources * @param cst {@code non-null;} the constant */ public PlainCstInsn(Rop opcode, SourcePosition position, RegisterSpec result, RegisterSpecList sources, Constant cst) { super(opcode, position, result, sources, cst); if (opcode.getBranchingness() != Rop.BRANCH_NONE) { throw new IllegalArgumentException("opcode with invalid branchingness: " + opcode.getBranchingness()); } }
/** * Validates that a basic block is a valid end predecessor. It must * end in a RETURN or a THROW. Throws a runtime exception on error. * * @param b {@code non-null;} block to validate * @throws RuntimeException on error */ private void verifyValidExitPredecessor(SsaBasicBlock b) { ArrayList<SsaInsn> insns = b.getInsns(); SsaInsn lastInsn = insns.get(insns.size() - 1); Rop opcode = lastInsn.getOpcode(); if (opcode.getBranchingness() != Rop.BRANCH_RETURN && opcode != Rops.THROW) { throw new RuntimeException("Exit predecessor must end" + " in valid exit statement."); } }
/** * Validates that a basic block is a valid end predecessor. It must * end in a RETURN or a THROW. Throws a runtime exception on error. * * @param b {@code non-null;} block to validate * @throws RuntimeException on error */ private void verifyValidExitPredecessor(SsaBasicBlock b) { ArrayList<SsaInsn> insns = b.getInsns(); SsaInsn lastInsn = insns.get(insns.size() - 1); Rop opcode = lastInsn.getOpcode(); if (opcode.getBranchingness() != Rop.BRANCH_RETURN && opcode != Rops.THROW) { throw new RuntimeException("Exit predecessor must end" + " in valid exit statement."); } }
/** * Replaces the last insn in this block. The provided insn must have * some branchingness. * * @param insn {@code non-null;} rop-form insn to add, which must branch. */ public void replaceLastInsn(Insn insn) { if (insn.getOpcode().getBranchingness() == Rop.BRANCH_NONE) { throw new IllegalArgumentException("last insn must branch"); } SsaInsn oldInsn = insns.get(insns.size() - 1); SsaInsn newInsn = SsaInsn.makeFromRop(insn, this); insns.set(insns.size() - 1, newInsn); parent.onInsnRemoved(oldInsn); parent.onInsnAdded(newInsn); }
/** * Replaces the last insn in this block. The provided insn must have * some branchingness. * * @param insn {@code non-null;} rop-form insn to add, which must branch. */ public void replaceLastInsn(Insn insn) { if (insn.getOpcode().getBranchingness() == Rop.BRANCH_NONE) { throw new IllegalArgumentException("last insn must branch"); } SsaInsn oldInsn = insns.get(insns.size() - 1); SsaInsn newInsn = SsaInsn.makeFromRop(insn, this); insns.set(insns.size() - 1, newInsn); parent.onInsnRemoved(oldInsn); parent.onInsnAdded(newInsn); }
/** * Replaces the last insn in this block. The provided insn must have * some branchingness. * * @param insn {@code non-null;} rop-form insn to add, which must branch. */ public void replaceLastInsn(Insn insn) { if (insn.getOpcode().getBranchingness() == Rop.BRANCH_NONE) { throw new IllegalArgumentException("last insn must branch"); } SsaInsn oldInsn = insns.get(insns.size() - 1); SsaInsn newInsn = SsaInsn.makeFromRop(insn, this); insns.set(insns.size() - 1, newInsn); parent.onInsnRemoved(oldInsn); parent.onInsnAdded(newInsn); }
/** * Replaces the last insn in this block. The provided insn must have * some branchingness. * * @param insn {@code non-null;} rop-form insn to add, which must branch. */ public void replaceLastInsn(Insn insn) { if (insn.getOpcode().getBranchingness() == Rop.BRANCH_NONE) { throw new IllegalArgumentException("last insn must branch"); } SsaInsn oldInsn = insns.get(insns.size() - 1); SsaInsn newInsn = SsaInsn.makeFromRop(insn, this); insns.set(insns.size() - 1, newInsn); parent.onInsnRemoved(oldInsn); parent.onInsnAdded(newInsn); }
/** * Replaces the last insn in this block. The provided insn must have * some branchingness. * * @param insn {@code non-null;} rop-form insn to add, which must branch. */ public void replaceLastInsn(Insn insn) { if (insn.getOpcode().getBranchingness() == Rop.BRANCH_NONE) { throw new IllegalArgumentException("last insn must branch"); } SsaInsn oldInsn = insns.get(insns.size() - 1); SsaInsn newInsn = SsaInsn.makeFromRop(insn, this); insns.set(insns.size() - 1, newInsn); parent.onInsnRemoved(oldInsn); parent.onInsnAdded(newInsn); }
/** * Replaces the last insn in this block. The provided insn must have * some branchingness. * * @param insn {@code non-null;} rop-form insn to add, which must branch. */ public void replaceLastInsn(Insn insn) { if (insn.getOpcode().getBranchingness() == Rop.BRANCH_NONE) { throw new IllegalArgumentException("last insn must branch"); } SsaInsn oldInsn = insns.get(insns.size() - 1); SsaInsn newInsn = SsaInsn.makeFromRop(insn, this); insns.set(insns.size() - 1, newInsn); parent.onInsnRemoved(oldInsn); parent.onInsnAdded(newInsn); }
/** * Replaces the last insn in this block. The provided insn must have * some branchingness. * * @param insn {@code non-null;} rop-form insn to add, which must branch. */ public void replaceLastInsn(Insn insn) { if (insn.getOpcode().getBranchingness() == Rop.BRANCH_NONE) { throw new IllegalArgumentException("last insn must branch"); } SsaInsn oldInsn = insns.get(insns.size() - 1); SsaInsn newInsn = SsaInsn.makeFromRop(insn, this); insns.set(insns.size() - 1, newInsn); parent.onInsnRemoved(oldInsn); parent.onInsnAdded(newInsn); }
/** * Replaces the last insn in this block. The provided insn must have * some branchingness. * * @param insn {@code non-null;} rop-form insn to add, which must branch. */ public void replaceLastInsn(Insn insn) { if (insn.getOpcode().getBranchingness() == Rop.BRANCH_NONE) { throw new IllegalArgumentException("last insn must branch"); } SsaInsn oldInsn = insns.get(insns.size() - 1); SsaInsn newInsn = SsaInsn.makeFromRop(insn, this); insns.set(insns.size() - 1, newInsn); parent.onInsnRemoved(oldInsn); parent.onInsnAdded(newInsn); }
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); } }
/** * 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); } }
public <T> void op(BinaryOp op, Local<T> target, Local<T> a, Local<T> b) { Rop rop = op.rop(StdTypeList.make(a.type.ropType, b.type.ropType)); RegisterSpecList sources = RegisterSpecList.make(a.spec(), b.spec()); if (rop.getBranchingness() == BRANCH_NONE) { addInstruction(new PlainInsn(rop, sourcePosition, target.spec(), sources)); } else { addInstruction(new ThrowingInsn(rop, sourcePosition, sources, catches)); moveResult(target, true); } }
/** * Executes {@code op} and sets {@code target} to the result. For most binary operations, the types of {@code a} and {@code b} must be the same. Shift operations (like {@link BinaryOp#SHIFT_LEFT}) require {@code b} to be an {@code int}, even when {@code a} is a {@code long}. */ public <T1, T2> void op(BinaryOp op, Local<T1> target, Local<T1> a, Local<T2> b) { Rop rop = op.rop(StdTypeList.make(a.type.ropType, b.type.ropType)); RegisterSpecList sources = RegisterSpecList.make(a.spec(), b.spec()); if (rop.getBranchingness() == BRANCH_NONE) { addInstruction(new PlainInsn(rop, sourcePosition, target.spec(), sources)); } else { addInstruction(new ThrowingInsn(rop, sourcePosition, sources, catches)); moveResult(target, true); } }
/** * Executes {@code op} and sets {@code target} to the result. For most * binary operations, the types of {@code a} and {@code b} must be the same. * Shift operations (like {@link BinaryOp#SHIFT_LEFT}) require {@code b} to * be an {@code int}, even when {@code a} is a {@code long}. */ public <T1, T2> void op(BinaryOp op, Local<T1> target, Local<T1> a, Local<T2> b) { Rop rop = op.rop(StdTypeList.make(a.type.ropType, b.type.ropType)); RegisterSpecList sources = RegisterSpecList.make(a.spec(), b.spec()); if (rop.getBranchingness() == BRANCH_NONE) { addInstruction(new PlainInsn(rop, sourcePosition, target.spec(), sources)); } else { addInstruction(new ThrowingInsn(rop, sourcePosition, sources, catches)); moveResult(target, true); } }