@Override public void transferInstruction(InstructionHandle handle, BasicBlock basicBlock, BitSet fact) throws DataflowAnalysisException { if (!isFactValid(fact)) { return; } Instruction ins = handle.getInstruction(); if (ins instanceof StoreInstruction) { // Local is stored: any live stores on paths leading // to this instruction are now dead LocalVariableInstruction store = (LocalVariableInstruction) ins; int local = store.getIndex(); fact.clear(local); fact.set(local + killedByStoreOffset); } if (ins instanceof LoadInstruction || ins instanceof IINC || ins instanceof RET) { // Local is loaded: it will be live on any path leading // to this instruction IndexedInstruction load = (IndexedInstruction) ins; int local = load.getIndex(); fact.set(local); fact.clear(local + killedByStoreOffset); } if (!isFactValid(fact)) { throw new IllegalStateException("Fact become invalid"); } }
public void visitLocalVariableInstruction(LocalVariableInstruction i) { short opcode = i.getOpcode(); Type type = i.getType(_cp); if(opcode == Constants.IINC) { _out.println("il.append(new IINC(" + i.getIndex() + ", " + ((IINC)i).getIncrement() + "));"); } else { String kind = (opcode < Constants.ISTORE)? "Load" : "Store"; _out.println("il.append(_factory.create" + kind + "(" + BCELifier.printType(type) + ", " + i.getIndex() + "));"); } }
/** * Assures the generic preconditions of a LocalVariableInstruction instance. * That is, the index of the local variable must be valid. */ public void visitLocalVariableInstruction(LocalVariableInstruction o){ if (locals().maxLocals() <= (o.getType(cpg).getSize()==1? o.getIndex() : o.getIndex()+1) ){ constraintViolated(o, "The 'index' is not a valid index into the local variable array."); } }
/** * Dump instruction as byte code to stream out. * @param out Output stream */ @Override public void dump( final DataOutputStream out ) throws IOException { if (wide) { out.writeByte(org.apache.bcel.Const.WIDE); } out.writeByte(super.getOpcode()); if (wide) { out.writeShort(super.getIndex()); out.writeShort(c); } else { out.writeByte(super.getIndex()); out.writeByte(c); } }
/** * Dump instruction as byte code to stream out. * @param out Output stream */ public void dump(DataOutputStream out) throws IOException { if(wide()) // Need WIDE prefix ? out.writeByte(Constants.WIDE); out.writeByte(opcode); if(length > 1) { // Otherwise ILOAD_n, instruction, e.g. if(wide()) out.writeShort(n); else out.writeByte(n); } }
/** * @param opcode Instruction opcode * @param c_tag Instruction number for compact version, ALOAD_0, e.g. * @param n local variable index (unsigned short) */ protected LocalVariableInstruction(short opcode, short c_tag, int n) { super(opcode, (short)2); this.c_tag = c_tag; canon_tag = opcode; setIndex(n); }
/** * @return mnemonic for instruction */ @Override public String toString( final boolean verbose ) { return super.toString(verbose) + " " + c; }
int s = ((LocalVariableInstruction) ih.getInstruction()).getType(null).getSize(); if (s==2) acc.add(new Integer(idx+1));
@Override public void visitLocalVariableInstruction( final LocalVariableInstruction i ) { final short opcode = i.getOpcode(); final Type type = i.getType(_cp); if (opcode == Const.IINC) { _out.println("il.append(new IINC(" + i.getIndex() + ", " + ((IINC) i).getIncrement() + "));"); } else { final String kind = (opcode < Const.ISTORE) ? "Load" : "Store"; _out.println("il.append(_factory.create" + kind + "(" + BCELifier.printType(type) + ", " + i.getIndex() + "));"); } }
/** * Assures the generic preconditions of a LocalVariableInstruction instance. * That is, the index of the local variable must be valid. */ @Override public void visitLocalVariableInstruction(final LocalVariableInstruction o) { if (locals().maxLocals() <= (o.getType(cpg).getSize()==1? o.getIndex() : o.getIndex()+1) ) { constraintViolated(o, "The 'index' is not a valid index into the local variable array."); } }
/** * Set the local variable index */ public void setIndex(int n) { if((n < 0) || (n > Constants.MAX_SHORT)) throw new ClassGenException("Illegal value: " + n); this.n = n; if(n >= 0 && n <= 3) { // Use more compact instruction xLOAD_n opcode = (short)(c_tag + n); length = 1; } else { opcode = canon_tag; if(wide()) // Need WIDE prefix ? length = 4; else length = 2; } }
/** * @param opcode Instruction opcode * @param c_tag Instruction number for compact version, ALOAD_0, e.g. * @param n local variable index (unsigned short) */ protected LocalVariableInstruction(final short opcode, final short c_tag, final int n) { super(opcode, (short) 2); this.c_tag = c_tag; canon_tag = opcode; setIndex(n); }
/** * @return mnemonic for instruction */ public String toString(boolean verbose) { return super.toString(verbose) + " " + c; }
final int s = ((LocalVariableInstruction) ih.getInstruction()).getType(null).getSize(); if (s==2) { acc.add(Integer.valueOf(idx+1));
/** * Dump instruction as byte code to stream out. * @param out Output stream */ @Override public void dump( final DataOutputStream out ) throws IOException { if (wide()) { out.writeByte(Const.WIDE); } out.writeByte(super.getOpcode()); if (super.getLength() > 1) { // Otherwise ILOAD_n, instruction, e.g. if (wide()) { out.writeShort(n); } else { out.writeByte(n); } } }
@Override public void transferInstruction(InstructionHandle handle, BasicBlock basicBlock, BitSet fact) throws DataflowAnalysisException { if (!isFactValid(fact)) { return; } Instruction ins = handle.getInstruction(); if (ins instanceof StoreInstruction) { // Local is stored: any live stores on paths leading // to this instruction are now dead LocalVariableInstruction store = (LocalVariableInstruction) ins; int local = store.getIndex(); fact.clear(local); fact.set(local + killedByStoreOffset); } if (ins instanceof LoadInstruction || ins instanceof IINC || ins instanceof RET) { // Local is loaded: it will be live on any path leading // to this instruction IndexedInstruction load = (IndexedInstruction) ins; int local = load.getIndex(); fact.set(local); fact.clear(local + killedByStoreOffset); } if (!isFactValid(fact)) { throw new IllegalStateException("Fact become invalid"); } }
/** * Set the local variable index. * also updates opcode and length * TODO Why? * @see #setIndexOnly(int) */ @Override public void setIndex( final int n ) { // TODO could be package-protected? if ((n < 0) || (n > Const.MAX_SHORT)) { throw new ClassGenException("Illegal value: " + n); } this.n = n; // Cannot be < 0 as this is checked above if (n <= 3) { // Use more compact instruction xLOAD_n super.setOpcode((short) (c_tag + n)); super.setLength(1); } else { super.setOpcode(canon_tag); if (wide()) { super.setLength(4); } else { super.setLength(2); } } }