void registerJump(Instruction instr) { if(instr.getOperandCount() == 1 && instr.getOperand(0) instanceof Instruction) { seenLabels.add(instr.getOperand(0)); } }
private static boolean isGetClassInvocation(final Instruction p) { return p != null && p.getOpCode() == OpCode.INVOKEVIRTUAL && p.<MethodReference>getOperand(0).getParameters().isEmpty() && StringUtilities.equals(p.<MethodReference>getOperand(0).getName(), "getClass"); }
private static void writeOperandList(final ITextOutput writer, final Instruction instruction) { for (int i = 0, n = instruction.getOperandCount(); i < n; i++) { if (i != 0) { writer.write(", "); } writeOperand(writer, instruction.getOperand(i)); } }
private static boolean isGetClassInvocation(final Instruction p) { return p != null && p.getOpCode() == OpCode.INVOKEVIRTUAL && p.<MethodReference>getOperand(0).getParameters().isEmpty() && StringUtilities.equals(p.<MethodReference>getOperand(0).getName(), "getClass"); }
private static void writeOperandList(final ITextOutput writer, final Instruction instruction) { for (int i = 0, n = instruction.getOperandCount(); i < n; i++) { if (i != 0) { writer.write(", "); } writeOperand(writer, instruction.getOperand(i)); } }
private static boolean isGetClassInvocation(final Instruction p) { return p != null && p.getOpCode() == OpCode.INVOKEVIRTUAL && p.<MethodReference>getOperand(0).getParameters().isEmpty() && StringUtilities.equals(p.<MethodReference>getOperand(0).getName(), "getClass"); }
private static void writeOperandList(final ITextOutput writer, final Instruction instruction) { for (int i = 0, n = instruction.getOperandCount(); i < n; i++) { if (i != 0) { writer.write(", "); } writeOperand(writer, instruction.getOperand(i)); } }
public static int getLoadOrStoreSlot(final Instruction instruction) { final OpCode code = instruction.getOpCode(); if (!code.isLoad() && !code.isStore()) { return -1; } if (code.getOpCodeType() == OpCodeType.Macro) { return OpCodeHelpers.getLoadStoreMacroArgumentIndex(code); } final VariableReference variable = instruction.getOperand(0); return variable.getSlot(); }
static void extractCalls(MethodDefinition md, Predicate<MethodReference> action) { MethodBody body = md.getBody(); if(body == null) return; for(Instruction inst : body.getInstructions()) { for(int i=0; i<inst.getOperandCount(); i++) { Object operand = inst.getOperand(i); if(operand instanceof MethodReference) { if(!action.test((MethodReference)operand)) return; } if(operand instanceof DynamicCallSite) { MethodHandle mh = Nodes.getMethodHandle((DynamicCallSite) operand); if(mh != null) { if(!action.test(mh.getMethod())) return; } } } } }
public static int getLoadOrStoreSlot(final Instruction instruction) { final OpCode code = instruction.getOpCode(); if (!code.isLoad() && !code.isStore()) { return -1; } if (code.getOpCodeType() == OpCodeType.Macro) { return OpCodeHelpers.getLoadStoreMacroArgumentIndex(code); } final VariableReference variable = instruction.getOperand(0); return variable.getSlot(); }
public static Instruction reverseLoadOrStore(final Instruction instruction) { VerifyArgument.notNull(instruction, "instruction"); final OpCode oldCode = instruction.getOpCode(); final OpCode newCode; if (oldCode.isStore()) { newCode = OpCode.valueOf(oldCode.name().replace("STORE", "LOAD")); } else if (oldCode.isLoad()) { newCode = OpCode.valueOf(oldCode.name().replace("LOAD", "STORE")); } else { throw new IllegalArgumentException("Instruction is neither a load nor store: " + instruction.getOpCode()); } if (instruction.getOperandCount() == 1) { return new Instruction(newCode, instruction.getOperand(0)); } return new Instruction(newCode); } }
public static int getLoadOrStoreSlot(final Instruction instruction) { final OpCode code = instruction.getOpCode(); if (!code.isLoad() && !code.isStore()) { return -1; } if (code.getOpCodeType() == OpCodeType.Macro) { return OpCodeHelpers.getLoadStoreMacroArgumentIndex(code); } final VariableReference variable = instruction.getOperand(0); return variable.getSlot(); }
public static Instruction reverseLoadOrStore(final Instruction instruction) { VerifyArgument.notNull(instruction, "instruction"); final OpCode oldCode = instruction.getOpCode(); final OpCode newCode; if (oldCode.isStore()) { newCode = OpCode.valueOf(oldCode.name().replace("STORE", "LOAD")); } else if (oldCode.isLoad()) { newCode = OpCode.valueOf(oldCode.name().replace("LOAD", "STORE")); } else { throw new IllegalArgumentException("Instruction is neither a load nor store: " + instruction.getOpCode()); } if (instruction.getOperandCount() == 1) { return new Instruction(newCode, instruction.getOperand(0)); } return new Instruction(newCode); } }
private void calculateIncomingJumps() { // // Step 1: Determine which instructions are jump targets. // for (final Instruction instruction : _instructions) { final OpCode opCode = instruction.getOpCode(); if (opCode.getOperandType() == OperandType.BranchTarget || opCode.getOperandType() == OperandType.BranchTargetWide) { _hasIncomingJumps[getInstructionIndex(instruction.<Instruction>getOperand(0))] = true; } else if (opCode.getOperandType() == OperandType.Switch) { final SwitchInfo switchInfo = instruction.getOperand(0); _hasIncomingJumps[getInstructionIndex(switchInfo.getDefaultTarget())] = true; for (final Instruction target : switchInfo.getTargets()) { _hasIncomingJumps[getInstructionIndex(target)] = true; } } } for (final ExceptionTableEntry entry : _tableEntries) { _hasIncomingJumps[getInstructionIndex(_instructions.atOffset(entry.getHandlerOffset()))] = true; } }
public static Instruction reverseLoadOrStore(final Instruction instruction) { VerifyArgument.notNull(instruction, "instruction"); final OpCode oldCode = instruction.getOpCode(); final OpCode newCode; if (oldCode.isStore()) { newCode = OpCode.valueOf(oldCode.name().replace("STORE", "LOAD")); } else if (oldCode.isLoad()) { newCode = OpCode.valueOf(oldCode.name().replace("LOAD", "STORE")); } else { throw new IllegalArgumentException("Instruction is neither a load nor store: " + instruction.getOpCode()); } if (instruction.getOperandCount() == 1) { return new Instruction(newCode, instruction.getOperand(0)); } return new Instruction(newCode); } }
private void calculateIncomingJumps() { // // Step 1: Determine which instructions are jump targets. // for (final Instruction instruction : _instructions) { final OpCode opCode = instruction.getOpCode(); if (opCode.getOperandType() == OperandType.BranchTarget || opCode.getOperandType() == OperandType.BranchTargetWide) { _hasIncomingJumps[getInstructionIndex(instruction.<Instruction>getOperand(0))] = true; } else if (opCode.getOperandType() == OperandType.Switch) { final SwitchInfo switchInfo = instruction.getOperand(0); _hasIncomingJumps[getInstructionIndex(switchInfo.getDefaultTarget())] = true; for (final Instruction target : switchInfo.getTargets()) { _hasIncomingJumps[getInstructionIndex(target)] = true; } } } for (final ExceptionTableEntry entry : _tableEntries) { _hasIncomingJumps[getInstructionIndex(_instructions.atOffset(entry.getHandlerOffset()))] = true; } }
private void calculateIncomingJumps() { // // Step 1: Determine which instructions are jump targets. // for (final Instruction instruction : _instructions) { final OpCode opCode = instruction.getOpCode(); if (opCode.getOperandType() == OperandType.BranchTarget || opCode.getOperandType() == OperandType.BranchTargetWide) { _hasIncomingJumps[getInstructionIndex(instruction.<Instruction>getOperand(0))] = true; } else if (opCode.getOperandType() == OperandType.Switch) { final SwitchInfo switchInfo = instruction.getOperand(0); _hasIncomingJumps[getInstructionIndex(switchInfo.getDefaultTarget())] = true; for (final Instruction target : switchInfo.getTargets()) { _hasIncomingJumps[getInstructionIndex(target)] = true; } } } for (final ExceptionHandler handler : _exceptionHandlers) { _hasIncomingJumps[getInstructionIndex(handler.getHandlerBlock().getFirstInstruction())] = true; } }
private void calculateIncomingJumps() { // // Step 1: Determine which instructions are jump targets. // for (final Instruction instruction : _instructions) { final OpCode opCode = instruction.getOpCode(); if (opCode.getOperandType() == OperandType.BranchTarget || opCode.getOperandType() == OperandType.BranchTargetWide) { _hasIncomingJumps[getInstructionIndex(instruction.<Instruction>getOperand(0))] = true; } else if (opCode.getOperandType() == OperandType.Switch) { final SwitchInfo switchInfo = instruction.getOperand(0); _hasIncomingJumps[getInstructionIndex(switchInfo.getDefaultTarget())] = true; for (final Instruction target : switchInfo.getTargets()) { _hasIncomingJumps[getInstructionIndex(target)] = true; } } } for (final ExceptionHandler handler : _exceptionHandlers) { _hasIncomingJumps[getInstructionIndex(handler.getHandlerBlock().getFirstInstruction())] = true; } }
private void calculateIncomingJumps() { // // Step 1: Determine which instructions are jump targets. // for (final Instruction instruction : _instructions) { final OpCode opCode = instruction.getOpCode(); if (opCode.getOperandType() == OperandType.BranchTarget || opCode.getOperandType() == OperandType.BranchTargetWide) { _hasIncomingJumps[getInstructionIndex(instruction.<Instruction>getOperand(0))] = true; } else if (opCode.getOperandType() == OperandType.Switch) { final SwitchInfo switchInfo = instruction.getOperand(0); _hasIncomingJumps[getInstructionIndex(switchInfo.getDefaultTarget())] = true; for (final Instruction target : switchInfo.getTargets()) { _hasIncomingJumps[getInstructionIndex(target)] = true; } } } for (final ExceptionHandler handler : _exceptionHandlers) { _hasIncomingJumps[getInstructionIndex(handler.getHandlerBlock().getFirstInstruction())] = true; } }
private void calculateIncomingJumps() { // // Step 1: Determine which instructions are jump targets. // for (final Instruction instruction : _instructions) { final OpCode opCode = instruction.getOpCode(); if (opCode.getOperandType() == OperandType.BranchTarget || opCode.getOperandType() == OperandType.BranchTargetWide) { _hasIncomingJumps[getInstructionIndex(instruction.<Instruction>getOperand(0))] = true; } else if (opCode.getOperandType() == OperandType.Switch) { final SwitchInfo switchInfo = instruction.getOperand(0); _hasIncomingJumps[getInstructionIndex(switchInfo.getDefaultTarget())] = true; for (final Instruction target : switchInfo.getTargets()) { _hasIncomingJumps[getInstructionIndex(target)] = true; } } } for (final ExceptionTableEntry entry : _tableEntries) { _hasIncomingJumps[getInstructionIndex(_instructions.atOffset(entry.getHandlerOffset()))] = true; } }