/** * Visits all insns in this block. * * @param visitor {@code non-null;} callback interface */ public void forEachInsn(SsaInsn.Visitor visitor) { // This gets called a LOT, and not using an iterator // saves a lot of allocations and reduces memory usage int len = insns.size(); for (int i = 0; i < len; i++) { insns.get(i).accept(visitor); } }
/** * Renames the result register of this insn and updates the * current register mapping. Does nothing if this insn has no result. * Applied to all non-move insns. * * @param insn insn to process. */ void processResultReg(SsaInsn insn) { RegisterSpec ropResult = insn.getResult(); if (ropResult == null) { return; } int ropReg = ropResult.getReg(); insn.changeResultReg(nextSsaReg); addMapping(ropReg, insn.getResult()); if (DEBUG) { ssaRegToRopReg.add(ropReg); } nextSsaReg++; }
/** {@inheritDoc} */ @Override public NormalSsaInsn clone() { return (NormalSsaInsn) super.clone(); }
final RegisterSpec origReg = insn.getResult(); TypeBearer typeBearer = insn.getResult().getTypeBearer(); if (use.canThrow() && use.getBlock().getSuccessors().cardinality() > 1) { continue; use.mapSourceRegisters(mapper);
RegisterSpec newReg) { for (SsaInsn use : ssaMeth.getUseListForRegister(origReg.getReg())) { RegisterSpec localAssignment = use.getLocalAssignment(); if (localAssignment == null) { continue; if (use.getResult() == null) { use.setResultLocal(null); = SsaInsn.makeFromRop( new PlainInsn(Rops.opMarkLocal(newReg), SourcePosition.NO_INFO, null, RegisterSpecList.make(newReg)), use.getBlock()); ArrayList<SsaInsn> insns = use.getBlock().getInsns();
SsaInsn insn = ssaMeth.getDefinitionForRegister(i); if (insn == null || insn.getOpcode() == null) continue; RegisterSpec result = insn.getResult(); TypeBearer typeBearer = result.getTypeBearer(); if (insn.getOpcode().getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { int pred = insn.getBlock().getPredecessors().nextSetBit(0); ArrayList<SsaInsn> predInsns; predInsns = ssaMeth.getBlocks().get(pred).getInsns(); if (insn.canThrow()) { if (insn.getBlock().getSuccessors().cardinality() > 1) { continue;
/** * Gets the parameter index for SSA registers that are method parameters. * {@code -1} is returned for non-parameter registers. * * @param ssaReg {@code >=0;} SSA register to look up * @return parameter index or {@code -1} if not a parameter */ private int getParameterIndexForReg(int ssaReg) { SsaInsn defInsn = ssaMeth.getDefinitionForRegister(ssaReg); if (defInsn == null) { return -1; } Rop opcode = defInsn.getOpcode(); // opcode == null for phi insns. if (opcode != null && opcode.getOpcode() == RegOps.MOVE_PARAM) { CstInsn origInsn = (CstInsn) defInsn.getOriginalRopInsn(); return ((CstInteger) origInsn.getConstant()).getValue(); } return -1; }
/** * Checks to see if the given SSA reg is ever associated with a local * local variable. Each SSA reg may be associated with at most one * local var. * * @param spec {@code non-null;} ssa reg * @return true if reg is ever associated with a local */ public boolean isRegALocal(RegisterSpec spec) { SsaInsn defn = getDefinitionForRegister(spec.getReg()); if (defn == null) { // version 0 registers are never used as locals return false; } // Does the definition have a local associated with it? if (defn.getLocalAssignment() != null) return true; // If not, is there a mark-local insn? for (SsaInsn use : getUseListForRegister(spec.getReg())) { Insn insn = use.getOriginalRopInsn(); if (insn != null && insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { return true; } } return false; }
assignment = insn.getLocalAssignment(); if (insn.getOpcode().getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { moveResultPseudoInsns.add((NormalSsaInsn) insn); } else if (Optimizer.getAdvice().requiresSourcesInOrder( insn.getOriginalRopInsn().getOpcode(), insn.getSources())) { invokeRangeInsns.add((NormalSsaInsn) insn);
/** * "v is live-out at s." */ private void liveOutAtStatement() { SsaInsn statement = blockN.getInsns().get(statementIndex); RegisterSpec rs = statement.getResult(); if (!statement.isResultReg(regV)) { if (rs != null) { interference.add(regV, rs.getReg()); } nextFunction = NextFunction.LIVE_IN_AT_STATEMENT; } }
&& block.getInsns().get(0).isMoveException()) { zNode.getInsns().add(0, block.getInsns().get(0).clone());
/** * Finds the corresponding instruction for a given move result * * @param moveInsn {@code non-null;} a move result instruction * @return {@code non-null;} the instruction that produces the result for * the move */ private SsaInsn getInsnForMove(SsaInsn moveInsn) { int pred = moveInsn.getBlock().getPredecessors().nextSetBit(0); ArrayList<SsaInsn> predInsns = ssaMeth.getBlocks().get(pred).getInsns(); return predInsns.get(predInsns.size()-1); }
/** * 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."); } }
/** * Indicates whether the specified register is amongst the registers * used as sources for this instruction. * * @param reg the register in question * @return true if the reg is a source */ public boolean isRegASource(int reg) { return null != getSources().specForRegister(reg); }
/** * Returns the RegisterSpec of the definition of the register. * * @param reg {@code >= 0;} SSA register * @return definition spec of the register or null if it is never defined * (for the case of "version 0" SSA registers) */ protected final RegisterSpec getDefinitionSpecForSsaReg(int reg) { SsaInsn definition = ssaMeth.getDefinitionForRegister(reg); return definition == null ? null : definition.getResult(); }
final RegisterSpec origReg = insn.getResult(); TypeBearer typeBearer = insn.getResult().getTypeBearer(); if (use.canThrow() && use.getBlock().getSuccessors().cardinality() > 1) { continue; use.mapSourceRegisters(mapper);
SsaInsn insn = ssaMeth.getDefinitionForRegister(i); if (insn == null || insn.getOpcode() == null) continue; RegisterSpec result = insn.getResult(); TypeBearer typeBearer = result.getTypeBearer(); if (insn.getOpcode().getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { int pred = insn.getBlock().getPredecessors().nextSetBit(0); ArrayList<SsaInsn> predInsns; predInsns = ssaMeth.getBlocks().get(pred).getInsns(); if (insn.canThrow()) { if (insn.getBlock().getSuccessors().cardinality() > 1) { continue;
/** * Gets the parameter index for SSA registers that are method parameters. * {@code -1} is returned for non-parameter registers. * * @param ssaReg {@code >=0;} SSA register to look up * @return parameter index or {@code -1} if not a parameter */ private int getParameterIndexForReg(int ssaReg) { SsaInsn defInsn = ssaMeth.getDefinitionForRegister(ssaReg); if (defInsn == null) { return -1; } Rop opcode = defInsn.getOpcode(); // opcode == null for phi insns. if (opcode != null && opcode.getOpcode() == RegOps.MOVE_PARAM) { CstInsn origInsn = (CstInsn) defInsn.getOriginalRopInsn(); return ((CstInteger) origInsn.getConstant()).getValue(); } return -1; }
/** * Checks to see if the given SSA reg is ever associated with a local * local variable. Each SSA reg may be associated with at most one * local var. * * @param spec {@code non-null;} ssa reg * @return true if reg is ever associated with a local */ public boolean isRegALocal(RegisterSpec spec) { SsaInsn defn = getDefinitionForRegister(spec.getReg()); if (defn == null) { // version 0 registers are never used as locals return false; } // Does the definition have a local associated with it? if (defn.getLocalAssignment() != null) return true; // If not, is there a mark-local insn? for (SsaInsn use : getUseListForRegister(spec.getReg())) { Insn insn = use.getOriginalRopInsn(); if (insn != null && insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { return true; } } return false; }
assignment = insn.getLocalAssignment(); if (insn.getOpcode().getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { moveResultPseudoInsns.add((NormalSsaInsn) insn); } else if (Optimizer.getAdvice().requiresSourcesInOrder( insn.getOriginalRopInsn().getOpcode(), insn.getSources())) { invokeRangeInsns.add((NormalSsaInsn) insn);