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 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); }
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); }
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); }
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 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 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 void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { byte opcode = branchInstruction.opcode; // Evaluate the target instruction blocks. evaluateInstructionBlock(clazz, method, codeAttribute, offset + branchInstruction.branchOffset); // Evaluate the instructions after a subroutine branch. if (opcode == InstructionConstants.OP_JSR || opcode == InstructionConstants.OP_JSR_W) { // We assume subroutine calls (jsr and jsr_w instructions) don't // change the stack, other than popping the return value. stackSize -= 1; evaluateInstructionBlock(clazz, method, codeAttribute, offset + branchInstruction.length(offset)); } // Some branch instructions always end the current instruction block. exitInstructionBlock = opcode == InstructionConstants.OP_GOTO || opcode == InstructionConstants.OP_GOTO_W || opcode == InstructionConstants.OP_JSR || opcode == InstructionConstants.OP_JSR_W; }
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { byte opcode = branchInstruction.opcode; // Evaluate the target instruction blocks. evaluateInstructionBlock(clazz, method, codeAttribute, offset + branchInstruction.branchOffset); // Evaluate the instructions after a subroutine branch. if (opcode == InstructionConstants.OP_JSR || opcode == InstructionConstants.OP_JSR_W) { // We assume subroutine calls (jsr and jsr_w instructions) don't // change the stack, other than popping the return value. stackSize -= 1; evaluateInstructionBlock(clazz, method, codeAttribute, offset + branchInstruction.length(offset)); } // Some branch instructions always end the current instruction block. exitInstructionBlock = opcode == InstructionConstants.OP_GOTO || opcode == InstructionConstants.OP_GOTO_W || opcode == InstructionConstants.OP_JSR || opcode == InstructionConstants.OP_JSR_W; }
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { byte opcode = branchInstruction.opcode; // Evaluate the target instruction blocks. evaluateInstructionBlock(clazz, method, codeAttribute, offset + branchInstruction.branchOffset); // Evaluate the instructions after a subroutine branch. if (opcode == InstructionConstants.OP_JSR || opcode == InstructionConstants.OP_JSR_W) { // We assume subroutine calls (jsr and jsr_w instructions) don't // change the stack, other than popping the return value. stackSize -= 1; evaluateInstructionBlock(clazz, method, codeAttribute, offset + branchInstruction.length(offset)); } // Some branch instructions always end the current instruction block. exitInstructionBlock = opcode == InstructionConstants.OP_GOTO || opcode == InstructionConstants.OP_GOTO_W || opcode == InstructionConstants.OP_JSR || opcode == InstructionConstants.OP_JSR_W; }
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { byte opcode = branchInstruction.opcode; // Evaluate the target instruction blocks. evaluateInstructionBlock(clazz, method, codeAttribute, offset + branchInstruction.branchOffset); // Evaluate the instructions after a subroutine branch. if (opcode == InstructionConstants.OP_JSR || opcode == InstructionConstants.OP_JSR_W) { // We assume subroutine calls (jsr and jsr_w instructions) don't // change the stack, other than popping the return value. stackSize -= 1; evaluateInstructionBlock(clazz, method, codeAttribute, offset + branchInstruction.length(offset)); } // Some branch instructions always end the current instruction block. exitInstructionBlock = opcode == InstructionConstants.OP_GOTO || opcode == InstructionConstants.OP_GOTO_W || opcode == InstructionConstants.OP_JSR || opcode == InstructionConstants.OP_JSR_W; }
/** * Replaces the given 'jsr' instruction by a simpler branch instruction, * if it jumps to a subroutine that doesn't return or a subroutine that * is only called from one place. */ private void replaceJsrInstruction(Clazz clazz, int offset, BranchInstruction branchInstruction) { // Is the subroutine ever returning? int subroutineStart = offset + branchInstruction.branchOffset; if (!partialEvaluator.isSubroutineReturning(subroutineStart) || partialEvaluator.branchOrigins(subroutineStart).instructionOffsetCount() == 1) { // All 'jsr' instructions to this subroutine can be replaced // by unconditional branch instructions. replaceBranchInstruction(clazz, offset, branchInstruction); } else if (!partialEvaluator.isTraced(offset + branchInstruction.length(offset))) { // We have to make sure the instruction after this 'jsr' // instruction is valid, even if it is never reached. replaceByInfiniteLoop(clazz, offset + branchInstruction.length(offset), branchInstruction); } }
/** * Replaces the given 'jsr' instruction by a simpler branch instruction, * if it jumps to a subroutine that doesn't return or a subroutine that * is only called from one place. */ private void replaceJsrInstruction(Clazz clazz, int offset, BranchInstruction branchInstruction) { // Is the subroutine ever returning? int subroutineStart = offset + branchInstruction.branchOffset; if (!partialEvaluator.isSubroutineReturning(subroutineStart) || partialEvaluator.branchOrigins(subroutineStart).instructionOffsetCount() == 1) { // All 'jsr' instructions to this subroutine can be replaced // by unconditional branch instructions. replaceBranchInstruction(clazz, offset, branchInstruction); } else if (!partialEvaluator.isTraced(offset + branchInstruction.length(offset))) { // We have to make sure the instruction after this 'jsr' // instruction is valid, even if it is never reached. replaceByInfiniteLoop(clazz, offset + branchInstruction.length(offset), branchInstruction); } }
/** * Replaces the given 'jsr' instruction by a simpler branch instruction, * if it jumps to a subroutine that doesn't return or a subroutine that * is only called from one place. */ private void replaceJsrInstruction(Clazz clazz, int offset, BranchInstruction branchInstruction) { // Is the subroutine ever returning? int subroutineStart = offset + branchInstruction.branchOffset; if (!partialEvaluator.isSubroutineReturning(subroutineStart) || partialEvaluator.branchOrigins(subroutineStart).instructionOffsetCount() == 1) { // All 'jsr' instructions to this subroutine can be replaced // by unconditional branch instructions. replaceBranchInstruction(clazz, offset, branchInstruction); } else if (!partialEvaluator.isTraced(offset + branchInstruction.length(offset))) { // We have to make sure the instruction after this 'jsr' // instruction is valid, even if it is never reached. replaceByInfiniteLoop(clazz, offset + branchInstruction.length(offset), branchInstruction); } }
/** * Replaces the given 'jsr' instruction by a simpler branch instruction, * if it jumps to a subroutine that doesn't return or a subroutine that * is only called from one place. */ private void replaceJsrInstruction(Clazz clazz, int offset, BranchInstruction branchInstruction) { // Is the subroutine ever returning? int subroutineStart = offset + branchInstruction.branchOffset; if (!partialEvaluator.isSubroutineReturning(subroutineStart) || partialEvaluator.branchOrigins(subroutineStart).instructionOffsetCount() == 1) { // All 'jsr' instructions to this subroutine can be replaced // by unconditional branch instructions. replaceBranchInstruction(clazz, offset, branchInstruction); } else if (!partialEvaluator.isTraced(offset + branchInstruction.length(offset))) { // We have to make sure the instruction after this 'jsr' // instruction is valid, even if it is never reached. replaceByInfiniteLoop(clazz, offset + branchInstruction.length(offset), branchInstruction); } }
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { // Mark the branch origin. markBranchOrigin(offset); // Check if this is the first instruction of a subroutine. checkSubroutine(offset); // Mark the branch target. markBranchTarget(offset, branchInstruction.branchOffset); byte opcode = branchInstruction.opcode; if (opcode == InstructionConstants.OP_JSR || opcode == InstructionConstants.OP_JSR_W) { // Mark the subroutine invocation. instructionMarks[offset] |= SUBROUTINE_INVOCATION; // Mark the subroutine start. int targetOffset = offset + branchInstruction.branchOffset; subroutineStarts[targetOffset] = targetOffset; } else if (opcode == InstructionConstants.OP_GOTO || opcode == InstructionConstants.OP_GOTO_W) { // Mark the next instruction. markAfterBranchOrigin(offset + branchInstruction.length(offset)); } }
markAfterBranchOrigin(offset + branchInstruction.length(offset));
markAfterBranchOrigin(offset + branchInstruction.length(offset));
markAfterBranchOrigin(offset + branchInstruction.length(offset));
int targetOffset = offset + branchOffset; if (branchOffset != branchInstruction.length(offset) && !codeAttributeEditor.isModified(offset) && !codeAttributeEditor.isModified(targetOffset))