public static boolean isThrower(MethodDefinition md) { MethodBody body = md.getBody(); if(body == null) return false; for(Instruction inst : body.getInstructions()) { if(inst.hasLabel() || inst.getOpCode() == OpCode.RETURN || inst.getOpCode() == OpCode.ARETURN) return false; if(inst.getOpCode() == OpCode.ATHROW) return true; } // Actually should not go here for valid bytecode return false; }
public static FrameValue makeUninitializedReference(final Instruction newInstruction) { VerifyArgument.notNull(newInstruction, "newInstruction"); if (newInstruction.getOpCode() != OpCode.NEW) { throw new IllegalArgumentException("Parameter must be a NEW instruction."); } return new FrameValue(FrameValueType.Uninitialized, newInstruction); }
public static FrameValue makeUninitializedReference(final Instruction newInstruction) { VerifyArgument.notNull(newInstruction, "newInstruction"); if (newInstruction.getOpCode() != OpCode.NEW) { throw new IllegalArgumentException("Parameter must be a NEW instruction."); } return new FrameValue(FrameValueType.Uninitialized, newInstruction); }
public static FrameValue makeUninitializedReference(final Instruction newInstruction) { VerifyArgument.notNull(newInstruction, "newInstruction"); if (newInstruction.getOpCode() != OpCode.NEW) { throw new IllegalArgumentException("Parameter must be a NEW instruction."); } return new FrameValue(FrameValueType.Uninitialized, newInstruction); }
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 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 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"); }
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 SubroutineInfo(final ControlFlowNode entryNode, final List<ControlFlowNode> contents, final ControlFlowGraph cfg) { this.start = entryNode.getStart(); this.end = last(contents).getEnd(); this.entryNode = entryNode; this.contents = contents; this.cfg = cfg; for (final ControlFlowNode node : contents) { if (node.getNodeType() == ControlFlowNodeType.Normal && node.getEnd().getOpCode().isReturnFromSubroutine()) { this.exitNodes.add(node); } } } }
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 SubroutineInfo(final ControlFlowNode entryNode, final List<ControlFlowNode> contents, final ControlFlowGraph cfg) { this.start = entryNode.getStart(); this.end = last(contents).getEnd(); this.entryNode = entryNode; this.contents = contents; this.cfg = cfg; for (final ControlFlowNode node : contents) { if (node.getNodeType() == ControlFlowNodeType.Normal && node.getEnd().getOpCode().isReturnFromSubroutine()) { this.exitNodes.add(node); } } } }
public SubroutineInfo(final ControlFlowNode entryNode, final List<ControlFlowNode> contents, final ControlFlowGraph cfg) { this.start = entryNode.getStart(); this.end = last(contents).getEnd(); this.entryNode = entryNode; this.contents = contents; this.cfg = cfg; for (final ControlFlowNode node : contents) { if (node.getNodeType() == ControlFlowNodeType.Normal && node.getEnd().getOpCode().isReturnFromSubroutine()) { this.exitNodes.add(node); } } } }
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 void writeInstruction(final ITextOutput writer, final Instruction instruction) { VerifyArgument.notNull(writer, "writer"); VerifyArgument.notNull(instruction, "instruction"); writer.writeDefinition(offsetToString(instruction.getOffset()), instruction); writer.write(": "); writer.writeReference(instruction.getOpCode().name(), instruction.getOpCode()); if (instruction.hasOperand()) { writer.write(' '); writeOperandList(writer, instruction); } }
public static void writeInstruction(final ITextOutput writer, final Instruction instruction) { VerifyArgument.notNull(writer, "writer"); VerifyArgument.notNull(instruction, "instruction"); writer.writeDefinition(offsetToString(instruction.getOffset()), instruction); writer.write(": "); writer.writeReference(instruction.getOpCode().name(), instruction.getOpCode()); if (instruction.hasOperand()) { writer.write(' '); writeOperandList(writer, instruction); } }
public static void writeInstruction(final ITextOutput writer, final Instruction instruction) { VerifyArgument.notNull(writer, "writer"); VerifyArgument.notNull(instruction, "instruction"); writer.writeDefinition(offsetToString(instruction.getOffset()), instruction); writer.write(": "); writer.writeReference(instruction.getOpCode().name(), instruction.getOpCode()); if (instruction.hasOperand()) { writer.write(' '); writeOperandList(writer, instruction); } }
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 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 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(); }
private static boolean shouldIncludeExceptionalExit( final ControlFlowGraph cfg, final ControlFlowNode head, final ControlFlowNode node) { if (node.getNodeType() != ControlFlowNodeType.Normal) { return false; } if (!node.getDominanceFrontier().contains(cfg.getExceptionalExit()) && !node.dominates(cfg.getExceptionalExit())) { final ControlFlowNode innermostHandlerNode = findInnermostExceptionHandlerNode(cfg, node.getEnd().getOffset(), false); if (innermostHandlerNode == null || !node.getDominanceFrontier().contains(innermostHandlerNode)) { return false; } } return head.getNodeType() == ControlFlowNodeType.Normal && node.getNodeType() == ControlFlowNodeType.Normal && node.getStart().getNext() == node.getEnd() && head.getStart().getOpCode().isStore() && node.getStart().getOpCode().isLoad() && node.getEnd().getOpCode() == OpCode.ATHROW && InstructionHelper.getLoadOrStoreSlot(head.getStart()) == InstructionHelper.getLoadOrStoreSlot(node.getStart()); }