Example usage for org.objectweb.asm Opcodes IFGT

List of usage examples for org.objectweb.asm Opcodes IFGT

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes IFGT.

Prototype

int IFGT

To view the source code for org.objectweb.asm Opcodes IFGT.

Click Source Link

Usage

From source file:de.codesourcery.asm.util.ASMUtil.java

License:Apache License

/**
 * Check whether an instruction is a conditional branch operation.
 *  /*w w w . j  av  a  2 s .  com*/
 * @param node
 * @return
 */
public static boolean isConditionalJump(AbstractInsnNode node) {
    if (node.getType() == AbstractInsnNode.JUMP_INSN) {
        switch (node.getOpcode()) {
        case Opcodes.IFEQ:
        case Opcodes.IFNE:
        case Opcodes.IFLT:
        case Opcodes.IFGE:
        case Opcodes.IFGT:
        case Opcodes.IFLE:
        case Opcodes.IF_ICMPEQ:
        case Opcodes.IF_ICMPNE:
        case Opcodes.IF_ICMPLT:
        case Opcodes.IF_ICMPGE:
        case Opcodes.IF_ICMPGT:
        case Opcodes.IF_ICMPLE:
        case Opcodes.IF_ACMPEQ:
        case Opcodes.IF_ACMPNE:
        case Opcodes.IFNULL:
        case Opcodes.IFNONNULL:
            return true;
        }
    }
    return false;
}

From source file:de.scoopgmbh.copper.instrument.BuildStackInfoAdapter.java

License:Apache License

@Override
public void visitJumpInsn(int arg0, Label arg1) {
    savePreviousFrame();//  www. jav  a2 s . c  o  m
    switch (arg0) {
    case Opcodes.IF_ACMPEQ:
    case Opcodes.IF_ACMPNE:
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
    case Opcodes.IF_ICMPLE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IF_ICMPNE:
        currentFrame.popStack();
    case Opcodes.IFEQ:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
    case Opcodes.IFLE:
    case Opcodes.IFLT:
    case Opcodes.IFNE:
    case Opcodes.IFNONNULL:
    case Opcodes.IFNULL:
        currentFrame.popStack();
    case Opcodes.GOTO:
        forwardFrames.put(arg1, new StackInfo(currentFrame));
        break;
    case Opcodes.JSR:
        currentFrame.pushStack(retAddressType);
        forwardFrames.put(arg1, new StackInfo(currentFrame));
        break;
    default:
        logger.debug("Unhandled: ");
    }
    if (logger.isDebugEnabled())
        logger.debug("jumpInsn " + getOpCode(arg0) + " " + arg1);
    delegate.visitJumpInsn(arg0, arg1);
}

From source file:de.tuberlin.uebb.jbop.optimizer.controlflow.ConstantIfInliner.java

License:Open Source License

private boolean evalSingleOpValue(final Number op1, final int opcode) {
    switch (opcode) {
    case Opcodes.IFEQ:
        return op1.intValue() == 0;
    case Opcodes.IFNE:
        return op1.intValue() != 0;
    case Opcodes.IFLT:
        return op1.intValue() < 0;
    case Opcodes.IFGE:
        return op1.intValue() >= 0;
    case Opcodes.IFGT:
        return op1.intValue() > 0;
    case Opcodes.IFLE:
        return op1.intValue() <= 0;
    case Opcodes.IFNULL:
        return op1 == null;
    case Opcodes.IFNONNULL:
        return op1 != null;
    default://ww  w.j a  v  a  2  s .  c o  m
        return false;
    }
}

From source file:de.tuberlin.uebb.jbop.optimizer.loop.ForLoop.java

License:Open Source License

private boolean eval(final int i, final int loopCount, final int ifNode) {
    if (ifNode == Opcodes.IF_ICMPLE) {
        return i <= loopCount;
    }/*  www .  java  2s.c o m*/
    if (ifNode == Opcodes.IF_ICMPEQ) {
        return i == loopCount;
    }
    if (ifNode == Opcodes.IF_ICMPGE) {
        return i >= loopCount;
    }
    if (ifNode == Opcodes.IF_ICMPGT) {
        return i > loopCount;
    }
    if (ifNode == Opcodes.IF_ICMPLT) {
        return i < loopCount;
    }
    if (ifNode == Opcodes.IF_ICMPNE) {
        return i != loopCount;
    }
    if (ifNode == Opcodes.IFGE) {
        return i >= 0;
    }
    if (ifNode == Opcodes.IFEQ) {
        return i == 0;
    }
    if (ifNode == Opcodes.IFGT) {
        return i > 0;
    }
    if (ifNode == Opcodes.IFLE) {
        return i <= 0;
    }
    if (ifNode == Opcodes.IFLT) {
        return i < 0;
    }
    if (ifNode == Opcodes.IFNE) {
        return i != 0;
    }
    return false;
}

From source file:de.tuberlin.uebb.jbop.optimizer.loop.ForLoopUnrollerTest.java

License:Open Source License

/**
 * Tests that ForLoopUnroller is working correctly.
 * /*  ww  w  .  jav  a2 s . c om*/
 * Used is a loop of the kind:
 * 
 * for(int i=6; i> 0; i=i-2)
 */
@Test
public void testForLoopUnrollerBackward() {
    // INIT
    final LabelNode label1 = new LabelNode();
    final LabelNode label2 = new LabelNode();
    builder.addInsn(NodeHelper.getInsnNodeFor(6)).//
            addInsn(new VarInsnNode(Opcodes.ISTORE, 1)).//
            addInsn(new JumpInsnNode(Opcodes.GOTO, label1)).//
            addInsn(label2).//
            addInsn(new VarInsnNode(Opcodes.ILOAD, 1)).//
            addInsn(new VarInsnNode(Opcodes.ILOAD, 1)).//
            addInsn(new InsnNode(Opcodes.IADD)).//
            addInsn(new IincInsnNode(1, -2)).//
            addInsn(label1).//
            addInsn(new VarInsnNode(Opcodes.ILOAD, 1)).//
            addInsn(new JumpInsnNode(Opcodes.IFGT, label2)).//
            addInsn(new InsnNode(Opcodes.RETURN));

    // RUN
    assertEquals(12, method.instructions.size());
    final InsnList optimized = optimizer.optimize(method.instructions, method);

    // ASSERT
    assertEquals(19, optimized.size());

    int node = 0;
    for (int i = 6; i > 0; i -= 2) {
        assertEquals(i, NodeHelper.getNumberValue(optimized.get(node)).intValue());
        node++;
        assertEquals(Opcodes.ISTORE, optimized.get(node).getOpcode());
        node++;
        assertEquals(Opcodes.ILOAD, optimized.get(node).getOpcode());
        node++;
        assertEquals(Opcodes.ILOAD, optimized.get(node).getOpcode());
        node++;
        assertEquals(Opcodes.IADD, optimized.get(node).getOpcode());
        node++;
        assertEquals(Opcodes.NOP, optimized.get(node).getOpcode());
        node++;
    }
}

From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.JumpInstruction.java

License:Open Source License

@Override
public String toString() {
    String condition;/* ww  w  .  j  a v  a  2 s  .  c  om*/
    switch (getOpcode()) {
    case Opcodes.IFEQ:
        condition = "IFEQ";
        break;
    case Opcodes.IFNE:
        condition = "IFNE";
        break;
    case Opcodes.IFLT:
        condition = "IFLT";
        break;
    case Opcodes.IFGE:
        condition = "IFGE";
        break;
    case Opcodes.IFGT:
        condition = "IFGT";
        break;
    case Opcodes.IFLE:
        condition = "IFLE";
        break;
    case Opcodes.IF_ICMPEQ:
        condition = "IF_ICMPEQ";
        break;
    case Opcodes.IF_ICMPNE:
        condition = "IF_ICMPNE";
        break;
    case Opcodes.IF_ICMPLT:
        condition = "IF_ICMPLT";
        break;
    case Opcodes.IF_ICMPGE:
        condition = "IF_ICMPGE";
        break;
    case Opcodes.IF_ICMPGT:
        condition = "IF_ICMPGT";
        break;
    case Opcodes.IF_ICMPLE:
        condition = "IF_ICMPLE";
        break;
    case Opcodes.IF_ACMPEQ:
        condition = "IF_ACMPEQ";
        break;
    case Opcodes.IF_ACMPNE:
        condition = "IF_ACMPNE";
        break;
    case Opcodes.GOTO:
        condition = "GOTO";
        break;
    case Opcodes.JSR:
        condition = "JSR";
        break;
    case Opcodes.IFNULL:
        condition = "IFNULL";
        break;
    case Opcodes.IFNONNULL:
        condition = "IFNONNULL";
        break;
    default:
        assert false;
        condition = "--ERROR--";
        break;
    }

    return condition + " " + this.label;
}

From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.JumpInstruction2.java

License:Open Source License

@Override
public String toString() {
    String condition;/*  w  w  w.ja v a 2  s.c  om*/
    switch (getOpcode()) {
    case Opcodes.IFEQ:
        condition = "IFEQ";
        break;
    case Opcodes.IFNE:
        condition = "IFNE";
        break;
    case Opcodes.IFLT:
        condition = "IFLT";
        break;
    case Opcodes.IFGE:
        condition = "IFGE";
        break;
    case Opcodes.IFGT:
        condition = "IFGT";
        break;
    case Opcodes.IFLE:
        condition = "IFLE";
        break;
    case Opcodes.IF_ICMPEQ:
        condition = "IF_ICMPEQ";
        break;
    case Opcodes.IF_ICMPNE:
        condition = "IF_ICMPNE";
        break;
    case Opcodes.IF_ICMPLT:
        condition = "IF_ICMPLT";
        break;
    case Opcodes.IF_ICMPGE:
        condition = "IF_ICMPGE";
        break;
    case Opcodes.IF_ICMPGT:
        condition = "IF_ICMPGT";
        break;
    case Opcodes.IF_ICMPLE:
        condition = "IF_ICMPLE";
        break;
    case Opcodes.IF_ACMPEQ:
        condition = "IF_ACMPEQ";
        break;
    case Opcodes.IF_ACMPNE:
        condition = "IF_ACMPNE";
        break;
    case Opcodes.GOTO:
        condition = "GOTO";
        break;
    case Opcodes.JSR:
        condition = "JSR";
        break;
    case Opcodes.IFNULL:
        condition = "IFNULL";
        break;
    case Opcodes.IFNONNULL:
        condition = "IFNONNULL";
        break;
    default:
        assert false;
        condition = "--ERROR--";
        break;
    }

    return condition + " " + this.target;
}

From source file:dyco4j.instrumentation.internals.InitTracingMethodVisitor.java

License:BSD License

@Override
public void visitJumpInsn(final int opcode, final Label label) {
    mv.visitJumpInsn(opcode, label);//from ww w  . j  av  a 2 s  .c  om
    switch (opcode) {
    case Opcodes.IFEQ:
    case Opcodes.IFNE:
    case Opcodes.IFLT:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
    case Opcodes.IFLE:
    case Opcodes.IFNULL:
    case Opcodes.IFNONNULL:
        this.stackFrame.pop();
        break;
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPNE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
    case Opcodes.IF_ICMPLE:
    case Opcodes.IF_ACMPEQ:
    case Opcodes.IF_ACMPNE:
        this.stackFrame.pop();
        this.stackFrame.pop();
        break;
    case Opcodes.JSR:
        this.stackFrame.push(OTHER);
        break;
    }
    addBranch(label);
}

From source file:edu.mit.streamjit.util.bytecode.MethodResolver.java

License:Open Source License

private void interpret(JumpInsnNode insn, FrameState frame, BBInfo block) {
    //All JumpInsnNodes have a target.  Find it.
    BBInfo target = blockByInsn(insn.label);
    assert target != null;

    if (insn.getOpcode() == Opcodes.GOTO) {
        block.block.instructions().add(new JumpInst(target.block));
        return;/* w w w. jav a 2s .  co m*/
    } else if (insn.getOpcode() == Opcodes.JSR)
        throw new UnsupportedOperationException("jsr not supported; upgrade to Java 6-era class files");

    //Remaining opcodes are branches.
    BBInfo fallthrough = blocks.get(blocks.indexOf(block) + 1);
    BranchInst.Sense sense = OPCODE_TO_SENSE.get(insn.getOpcode());
    //The second operand may come from the stack or may be a constant 0 or null.
    Value right;
    switch (insn.getOpcode()) {
    case Opcodes.IFEQ:
    case Opcodes.IFNE:
    case Opcodes.IFLT:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
    case Opcodes.IFLE:
        right = module.constants().getConstant(0);
        break;
    case Opcodes.IFNULL:
    case Opcodes.IFNONNULL:
        right = module.constants().getNullConstant();
        break;
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPNE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
    case Opcodes.IF_ICMPLE:
    case Opcodes.IF_ACMPEQ:
    case Opcodes.IF_ACMPNE:
        right = frame.stack.pop();
        break;
    default:
        throw new AssertionError("Can't happen! Branch opcode missing? " + insn.getOpcode());
    }
    //First operand always comes from the stack.
    Value left = frame.stack.pop();
    block.block.instructions().add(new BranchInst(left, sense, right, target.block, fallthrough.block));
}

From source file:edu.umd.cs.guitar.testcase.plugin.edg.ClassDBVisitor.java

License:Open Source License

@Override
public void visitJumpInsn(int opcode, Label label) {
    currentMethod.setEmpty(false);//from w w w .  j  av  a2  s. c  om
    currentMethod.setEmpty(false);
    switch (opcode) {
    case Opcodes.IFEQ:
    case Opcodes.IFNE:
    case Opcodes.IFLT:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
    case Opcodes.IFLE:
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPNE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
    case Opcodes.IF_ICMPLE:
    case Opcodes.IF_ACMPEQ:
    case Opcodes.IF_ACMPNE:
        //      case Opcodes.GOTO:
        //      case Opcodes.JSR:
    case Opcodes.IFNULL:
    case Opcodes.IFNONNULL:
        // add all label reads/writes as condition reads/writes
        currentMethod.getConditionReads().addAll(labelReads);
        currentMethod.getConditionWrites().addAll(labelWrites);
        break;
    }
}