public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { replacementInstruction = new BranchInstruction(branchInstruction.opcode, matchedBranchOffset(offset, branchInstruction.branchOffset)); }
protected void writeInfo(byte[] code, int offset) { if (requiredBranchOffsetSize() > branchOffsetSize()) { throw new IllegalArgumentException("Instruction has invalid branch offset size ("+this.toString(offset)+")"); } writeSignedValue(code, offset, branchOffset, branchOffsetSize()); }
public String toString() { return getName()+" "+(branchOffset >= 0 ? "+" : "")+branchOffset; }
protected void readInfo(byte[] code, int offset) { branchOffset = readSignedValue(code, offset, branchOffsetSize()); }
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { // Is it a necessary subroutine invocation? if (branchInstruction.canonicalOpcode() == InstructionConstants.OP_JSR) { int nextOffset = offset + branchInstruction.length(offset); if (!instructionUsageMarker.isInstructionNecessary(nextOffset)) { replaceByInfiniteLoop(clazz, nextOffset); if (DEBUG) System.out.println(" Adding infinite loop at ["+nextOffset+"] after "+branchInstruction.toString(offset)); } } } }
branchOffset != branchInstruction.length(offset) && !codeAttributeEditor.isModified(offset) && !codeAttributeEditor.isModified(targetOffset)) new BranchInstruction(opcode, (branchOffset + targetBranchOffset)); codeAttributeEditor.replaceInstruction(offset,
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { // Adjust the branch offset. branchInstruction.branchOffset = remapBranchOffset(offset, branchInstruction.branchOffset); // Write out the instruction. instructionWriter.visitBranchInstruction(clazz, method, codeAttribute, newOffset, branchInstruction); newOffset += branchInstruction.length(newOffset); }
public Instruction shrink() if (requiredBranchOffsetSize() == 2) throw new IllegalArgumentException("Branch instruction can't be widened ("+this.toString()+")");
branchInstruction.write(codeAttribute, offset); new BranchInstruction(InstructionConstants.OP_GOTO_W, branchInstruction.branchOffset); new BranchInstruction(branchInstruction.opcode, branchInstruction.branchOffset); new BranchInstruction((byte)(((branchInstruction.opcode+1) ^ 1) - 1), (1+2) + (1+4)); new BranchInstruction((byte)(branchInstruction.opcode ^ 1), (1+2) + (1+4)); branchInstruction.write(codeAttribute, offset);
branchInstruction.write(codeAttribute, offset); new BranchInstruction(InstructionConstants.OP_GOTO_W, branchInstruction.branchOffset); new BranchInstruction(branchInstruction.opcode, branchInstruction.branchOffset).shrink(); new BranchInstruction((byte)(((branchInstruction.opcode+1) ^ 1) - 1), (1+2) + (1+4)); new BranchInstruction((byte)(branchInstruction.opcode ^ 1), (1+2) + (1+4)); branchInstruction.write(codeAttribute, offset);
public int length(int offset) { return 1 + branchOffsetSize(); }
public String toString(int offset) { return "["+offset+"] "+toString()+" (target="+(offset+branchOffset)+")"; }
branchOffset != branchInstruction.length(offset) && !codeAttributeEditor.isModified(offset) && !codeAttributeEditor.isModified(targetOffset)) new BranchInstruction(opcode, (branchOffset + targetBranchOffset)); codeAttributeEditor.replaceInstruction(offset,
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { // Update the branch offset, relative to the precise new offset. branchInstruction.branchOffset = newBranchOffset(offset, branchInstruction.branchOffset, newOffset); // Write out the instruction. instructionWriter.visitBranchInstruction(clazz, method, codeAttribute, newOffset, branchInstruction); newOffset += branchInstruction.length(newOffset); }
protected void readInfo(byte[] code, int offset) { branchOffset = readSignedValue(code, offset, branchOffsetSize()); }
public Instruction shrink() if (requiredBranchOffsetSize() == 2) throw new IllegalArgumentException("Branch instruction can't be widened ("+this.toString()+")");
branchInstruction.write(codeAttribute, offset); new BranchInstruction(InstructionConstants.OP_GOTO_W, branchInstruction.branchOffset); new BranchInstruction(branchInstruction.opcode, branchInstruction.branchOffset); new BranchInstruction((byte)(((branchInstruction.opcode+1) ^ 1) - 1), (1+2) + (1+4)); new BranchInstruction((byte)(branchInstruction.opcode ^ 1), (1+2) + (1+4)); branchInstruction.write(codeAttribute, offset);
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { // Is it a necessary subroutine invocation? if (branchInstruction.canonicalOpcode() == InstructionConstants.OP_JSR) { int nextOffset = offset + branchInstruction.length(offset); if (!instructionUsageMarker.isInstructionNecessary(nextOffset)) { replaceByInfiniteLoop(clazz, nextOffset); if (DEBUG) System.out.println(" Adding infinite loop at ["+nextOffset+"] after "+branchInstruction.toString(offset)); } } } }
public int length(int offset) { return 1 + branchOffsetSize(); }
public String toString(int offset) { return "["+offset+"] "+toString()+" (target="+(offset+branchOffset)+")"; }