private void cleanDebug(MethodNode mn) { for (AbstractInsnNode p = mn.instructions.getFirst(); p != null; ) { if (p.getType() == AbstractInsnNode.LINE) { AbstractInsnNode q = p.getNext(); mn.instructions.remove(p); p = q; } else { p = p.getNext(); } } mn.localVariables = null; }
ctor.instructions.remove(insns[startIndex]); removedInstructions.add(insns[startIndex]); startIndex++;
if (useConstants && code.getLast() instanceof LdcInsnNode) { LdcInsnNode node = (LdcInsnNode) code.getLast(); code.remove(node); if (useConstants && code.getLast() instanceof LdcInsnNode) { LdcInsnNode node = (LdcInsnNode) code.getLast(); code.remove(node); if (useConstants && code.getLast() instanceof LdcInsnNode) { LdcInsnNode node = (LdcInsnNode) code.getLast(); code.remove(node);
public void remove() { if (remove != null) { if (remove == next) { next = next.next; } else { prev = prev.prev; } InsnList.this.remove(remove); remove = null; } else { throw new IllegalStateException(); } }
@Override public void remove() { if (remove != null) { if (remove == nextInsn) { nextInsn = nextInsn.nextInsn; } else { previousInsn = previousInsn.previousInsn; } InsnList.this.remove(remove); remove = null; } else { throw new IllegalStateException(); } }
@Override public void apply(MethodPatcher.PatchData patch, MethodNode methodNode, AbstractInsnNode location, Method method) { methodNode.instructions.insertBefore(location, method.insnList); methodNode.instructions.remove(location); } };
/** Replace an instruction with a list of instructions. */ static int replace(final InsnList instructions, final int i, final AbstractInsnNode location, final InsnList list) { final int size = list.size(); instructions.insert(location, list); instructions.remove(location); return i + (size - 1); }
private void insertDoubleComparisonL(AbstractInsnNode position, InsnList list) { MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "doubleSubL", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.DOUBLE_TYPE, Type.DOUBLE_TYPE }), false); list.insert(position, get); list.remove(position); }
private void removeGroupRootInstruction() { method.instructions.remove(group.getRoot().getInstruction()); }
private void insertDoubleComparisonG(AbstractInsnNode position, InsnList list) { MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "doubleSubG", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.DOUBLE_TYPE, Type.DOUBLE_TYPE }), false); list.insert(position, get); list.remove(position); }
private void insertFloatComparisonG(AbstractInsnNode position, InsnList list) { MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "floatSubG", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.FLOAT_TYPE, Type.FLOAT_TYPE }), false); list.insert(position, get); list.remove(position); }
private void insertFloatComparisonL(AbstractInsnNode position, InsnList list) { MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "floatSubL", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.FLOAT_TYPE, Type.FLOAT_TYPE }), false); list.insert(position, get); list.remove(position); }
public static SpecificMethodNodeTransformer instructionsNodesTransformer(String target, int priority, Function<AbstractInsnNode, AbstractInsnNode> insnOld2new) { return instructionsTransformer(priority, target, instructions -> { for (AbstractInsnNode node : instructions.toArray()) { AbstractInsnNode res = insnOld2new.apply(node); if (res != null) instructions.set(node, res); else instructions.remove(node); } }); }
private void insertLongComparison(AbstractInsnNode position, InsnList list) { MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "longSub", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.LONG_TYPE, Type.LONG_TYPE }), false); list.insert(position, get); list.remove(position); }
@Override public void transform() { AtomicInteger count = new AtomicInteger(); long current = System.currentTimeMillis(); getClassWrappers().parallelStream().filter(classWrapper -> !excluded(classWrapper)).forEach(classWrapper -> classWrapper.methods.parallelStream().filter(methodWrapper -> !excluded(methodWrapper) && hasInstructions(methodWrapper.methodNode)).forEach(methodWrapper -> { MethodNode methodNode = methodWrapper.methodNode; for (AbstractInsnNode insn : methodNode.instructions.toArray()) { if (insn.getOpcode() == NOP) { methodNode.instructions.remove(insn); } } }) ); LoggerUtils.stdOut(String.format("Removed %d NOP instructions. [%dms]", count.get(), tookThisLong(current))); }
@SuppressWarnings({"SuspiciousMethodCalls"}) public void process(ParserClassNode classNode, RuleMethod method) throws Exception { checkArgNotNull(classNode, "classNode"); checkArgNotNull(method, "method"); AbstractInsnNode current = method.instructions.getFirst(); while (current != null) { AbstractInsnNode next = current.getNext(); if (current.getType() == AbstractInsnNode.LABEL && !method.getUsedLabels().contains(current)) { method.instructions.remove(current); } current = next; } }
private void extractInstructions(InstructionGroup group) { for (InstructionGraphNode node : group.getNodes()) { if (node != group.getRoot()) { AbstractInsnNode insn = node.getInstruction(); method.instructions.remove(insn); group.getInstructions().add(insn); } } }
private void extractInstructions(final InstructionGroup group) { AbstractInsnNode insn; for (final InstructionGraphNode node: group.getNodes()) { if (node == group.getRoot()) continue; insn = node.getInstruction(); method.instructions.remove(insn); group.getInstructions().add(insn); } }
@Override protected AbstractInsnNode transformTypeInsnNode(MethodNode mn, TypeInsnNode typeNode) { if (frames == null) return typeNode; if (typeNode.getOpcode() == Opcodes.CHECKCAST) { Frame current = frames[mn.instructions.indexOf(typeNode)]; int size = current.getStackSize(); if (current.getStack(size - 1) == BooleanArrayInterpreter.INT_ARRAY) { BooleanTestabilityTransformation.logger.info("Array is of boolean type, changing CHECKCAST to [I"); TypeInsnNode replacement = new TypeInsnNode(Opcodes.CHECKCAST, "[I"); mn.instructions.insertBefore(typeNode, replacement); mn.instructions.remove(typeNode); return replacement; } } return typeNode; } }