List of usage examples for org.objectweb.asm Opcodes IF_ICMPEQ
int IF_ICMPEQ
To view the source code for org.objectweb.asm Opcodes IF_ICMPEQ.
Click Source Link
From source file:edu.illinois.nondex.instr.PriorityQueueShufflingAdder.java
License:Open Source License
public void addNext() { MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC, "next", "()Ljava/lang/Object;", "()TE;", null); mv.visitCode();/* w ww. j a va 2s . c o m*/ mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue$Itr", "expectedModCount", "I"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue$Itr", "this$0", "Ljava/util/PriorityQueue;"); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue", "modCount", "I"); Label l0 = new Label(); mv.visitJumpInsn(Opcodes.IF_ICMPEQ, l0); mv.visitTypeInsn(Opcodes.NEW, "java/util/ConcurrentModificationException"); mv.visitInsn(Opcodes.DUP); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/util/ConcurrentModificationException", "<init>", "()V", false); mv.visitInsn(Opcodes.ATHROW); mv.visitLabel(l0); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue$Itr", "iter", "Ljava/util/Iterator;"); mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); mv.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "lastRetElt", "Ljava/lang/Object;"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitInsn(Opcodes.ICONST_M1); mv.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "lastRet", "I"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue$Itr", "lastRetElt", "Ljava/lang/Object;"); mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(2, 1); mv.visitEnd(); }
From source file:edu.illinois.nondex.instr.WeakHashMapShufflingAdder.java
License:Open Source License
public void addNextEntry() { MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC, "nextEntry", "()Ljava/util/WeakHashMap$Entry;", "()Ljava/util/WeakHashMap$Entry<TK;TV;>;", null); mv.visitCode();/*from ww w . jav a 2 s. com*/ mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap$HashIterator", "this$0", "Ljava/util/WeakHashMap;"); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap", "modCount", "I"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap$HashIterator", "expectedModCount", "I"); Label l0 = new Label(); mv.visitJumpInsn(Opcodes.IF_ICMPEQ, l0); mv.visitTypeInsn(Opcodes.NEW, "java/util/ConcurrentModificationException"); mv.visitInsn(Opcodes.DUP); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/util/ConcurrentModificationException", "<init>", "()V", false); mv.visitInsn(Opcodes.ATHROW); mv.visitLabel(l0); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap$HashIterator", "iter", "Ljava/util/Iterator;"); mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); mv.visitTypeInsn(Opcodes.CHECKCAST, "java/util/WeakHashMap$Entry"); mv.visitFieldInsn(Opcodes.PUTFIELD, "java/util/WeakHashMap$HashIterator", "lastReturned", "Ljava/util/WeakHashMap$Entry;"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap$HashIterator", "lastReturned", "Ljava/util/WeakHashMap$Entry;"); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/WeakHashMap$Entry", "get", "()Ljava/lang/Object;", false); mv.visitFieldInsn(Opcodes.PUTFIELD, "java/util/WeakHashMap$HashIterator", "currentKey", "Ljava/lang/Object;"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap$HashIterator", "lastReturned", "Ljava/util/WeakHashMap$Entry;"); mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(2, 1); mv.visitEnd(); }
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;/*from www. j a va 2 s.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.mit.streamjit.util.bytecode.MethodUnresolver.java
License:Open Source License
private void emit(BranchInst i, InsnList insns) { //TODO: accessor methods on BranchInst Value left = i.getOperand(0), right = i.getOperand(1); BasicBlock target = (BasicBlock) i.getOperand(2), fallthrough = (BasicBlock) i.getOperand(3); if (!method.basicBlocks().contains(target)) throw new IllegalArgumentException("Branch targets block not in method: " + i); if (!method.basicBlocks().contains(fallthrough)) throw new IllegalArgumentException("Branch falls through to block not in method: " + i); load(i.getOperand(0), insns);/*from w ww . ja v a2 s .c o m*/ load(i.getOperand(1), insns); //TODO: long, float, doubles need to go through CMP inst first int opcode; if (left.getType() instanceof ReferenceType || left.getType() instanceof VoidType) { switch (i.getSense()) { case EQ: opcode = Opcodes.IF_ACMPEQ; break; case NE: opcode = Opcodes.IF_ACMPNE; break; default: throw new AssertionError(i); } } else if (left.getType().isSubtypeOf(intType)) { switch (i.getSense()) { case EQ: opcode = Opcodes.IF_ICMPEQ; break; case NE: opcode = Opcodes.IF_ICMPNE; break; case LT: opcode = Opcodes.IF_ICMPLT; break; case GT: opcode = Opcodes.IF_ICMPGT; break; case LE: opcode = Opcodes.IF_ICMPLE; break; case GE: opcode = Opcodes.IF_ICMPGE; break; default: throw new AssertionError(i); } } else throw new AssertionError(i); insns.add(new JumpInsnNode(opcode, labels.get(target))); insns.add(new JumpInsnNode(Opcodes.GOTO, labels.get(fallthrough))); }
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 a v a 2 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; } }
From source file:jpcsp.Allegrex.compiler.CodeInstruction.java
License:Open Source License
private int loadRegistersForBranchingOpcodeBranch2(CompilerContext context, MethodVisitor mv, int branchingOpcode) { boolean loadRs = true; boolean loadRt = true; if (context.getRsRegisterIndex() == context.getRtRegisterIndex()) { if (branchingOpcode == Opcodes.IF_ICMPEQ) { loadRs = false;//from ww w. j a v a 2 s . c o m loadRt = false; branchingOpcode = Opcodes.GOTO; // The ASM library has problems with small frames having no // stack (NullPointerException). Generate a dummy stack requirement: // ILOAD 0 // POP context.loadImm(0); context.getMethodVisitor().visitInsn(Opcodes.POP); } else if (branchingOpcode == Opcodes.IF_ICMPNE) { loadRs = false; loadRt = false; branchingOpcode = Opcodes.NOP; } } else if (context.isRsRegister0()) { if (branchingOpcode == Opcodes.IF_ICMPEQ) { loadRs = false; branchingOpcode = Opcodes.IFEQ; } else if (branchingOpcode == Opcodes.IF_ICMPNE) { loadRs = false; branchingOpcode = Opcodes.IFNE; } } else if (context.isRtRegister0()) { if (branchingOpcode == Opcodes.IF_ICMPEQ) { loadRt = false; branchingOpcode = Opcodes.IFEQ; } else if (branchingOpcode == Opcodes.IF_ICMPNE) { loadRt = false; branchingOpcode = Opcodes.IFNE; } } if (loadRs) { context.loadRs(); } if (loadRt) { context.loadRt(); } return branchingOpcode; }
From source file:jpcsp.Allegrex.compiler.CodeInstruction.java
License:Open Source License
private int getBranchingOpcode(CompilerContext context, MethodVisitor mv) { int branchingOpcode = Opcodes.NOP; if (insn == Instructions.BEQ) { branchingOpcode = getBranchingOpcodeBranch2(context, mv, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPNE); } else if (insn == Instructions.BEQL) { branchingOpcode = getBranchingOpcodeBranch2L(context, mv, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPNE); } else if (insn == Instructions.BNE) { branchingOpcode = getBranchingOpcodeBranch2(context, mv, Opcodes.IF_ICMPNE, Opcodes.IF_ICMPEQ); } else if (insn == Instructions.BNEL) { branchingOpcode = getBranchingOpcodeBranch2L(context, mv, Opcodes.IF_ICMPNE, Opcodes.IF_ICMPEQ); } else if (insn == Instructions.BGEZ) { branchingOpcode = getBranchingOpcodeBranch1(context, mv, Opcodes.IFGE, Opcodes.IFLT); } else if (insn == Instructions.BGEZL) { branchingOpcode = getBranchingOpcodeBranch1L(context, mv, Opcodes.IFGE, Opcodes.IFLT); } else if (insn == Instructions.BGTZ) { branchingOpcode = getBranchingOpcodeBranch1(context, mv, Opcodes.IFGT, Opcodes.IFLE); } else if (insn == Instructions.BGTZL) { branchingOpcode = getBranchingOpcodeBranch1L(context, mv, Opcodes.IFGT, Opcodes.IFLE); } else if (insn == Instructions.BLEZ) { branchingOpcode = getBranchingOpcodeBranch1(context, mv, Opcodes.IFLE, Opcodes.IFGT); } else if (insn == Instructions.BLEZL) { branchingOpcode = getBranchingOpcodeBranch1L(context, mv, Opcodes.IFLE, Opcodes.IFGT); } else if (insn == Instructions.BLTZ) { branchingOpcode = getBranchingOpcodeBranch1(context, mv, Opcodes.IFLT, Opcodes.IFGE); } else if (insn == Instructions.BLTZL) { branchingOpcode = getBranchingOpcodeBranch1L(context, mv, Opcodes.IFLT, Opcodes.IFGE); } else if (insn == Instructions.J) { branchingOpcode = getBranchingOpcodeBranch0(context, mv); } else if (insn == Instructions.JAL) { branchingOpcode = getBranchingOpcodeCall0(context, mv); } else if (insn == Instructions.BLTZAL) { branchingOpcode = getBranchingOpcodeCall1(context, mv, Opcodes.IFLT, Opcodes.IFGE); } else if (insn == Instructions.BLTZALL) { branchingOpcode = getBranchingOpcodeCall1L(context, mv, Opcodes.IFLT, Opcodes.IFGE); } else if (insn == Instructions.BGEZAL) { branchingOpcode = getBranchingOpcodeCall1(context, mv, Opcodes.IFGE, Opcodes.IFLT); } else if (insn == Instructions.BGEZALL) { branchingOpcode = getBranchingOpcodeCall1L(context, mv, Opcodes.IFGE, Opcodes.IFLT); } else if (insn == Instructions.BC1F) { branchingOpcode = getBranchingOpcodeBC1(context, mv, Opcodes.IFEQ, Opcodes.IFNE); } else if (insn == Instructions.BC1FL) { branchingOpcode = getBranchingOpcodeBC1L(context, mv, Opcodes.IFEQ, Opcodes.IFNE); } else if (insn == Instructions.BC1T) { branchingOpcode = getBranchingOpcodeBC1(context, mv, Opcodes.IFNE, Opcodes.IFEQ); } else if (insn == Instructions.BC1TL) { branchingOpcode = getBranchingOpcodeBC1L(context, mv, Opcodes.IFNE, Opcodes.IFEQ); } else if (insn == Instructions.BVF) { branchingOpcode = getBranchingOpcodeBV(context, mv, Opcodes.IFEQ, Opcodes.IFNE); } else if (insn == Instructions.BVT) { branchingOpcode = getBranchingOpcodeBV(context, mv, Opcodes.IFNE, Opcodes.IFEQ); } else if (insn == Instructions.BVFL) { branchingOpcode = getBranchingOpcodeBVL(context, mv, Opcodes.IFEQ, Opcodes.IFNE); } else if (insn == Instructions.BVTL) { branchingOpcode = getBranchingOpcodeBVL(context, mv, Opcodes.IFNE, Opcodes.IFEQ); } else {/*w w w . j av a2 s .c o m*/ log.error("CodeInstruction.getBranchingOpcode: unknown instruction " + insn.disasm(getAddress(), getOpcode())); } return branchingOpcode; }
From source file:jpcsp.Allegrex.compiler.CompilerContext.java
License:Open Source License
private void visitContinueToAddress(int returnAddress, boolean returnOnUnknownAddress) { // if (x != returnAddress) { // RuntimeContext.jump(x, returnAddress); // }//w w w .j a v a2s.c om Label continueLabel = new Label(); Label isReturnAddress = new Label(); mv.visitInsn(Opcodes.DUP); loadImm(returnAddress); visitJump(Opcodes.IF_ICMPEQ, isReturnAddress); if (returnOnUnknownAddress) { visitJump(); } else { loadImm(returnAddress); mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextInternalName, "jump", "(II)V"); mv.visitJumpInsn(Opcodes.GOTO, continueLabel); } mv.visitLabel(isReturnAddress); mv.visitInsn(Opcodes.POP); mv.visitLabel(continueLabel); }
From source file:jpcsp.Allegrex.compiler.CompilerContext.java
License:Open Source License
private void visitContinueToAddressInRegister(int reg) { // if (x != cpu.reg) { // RuntimeContext.jump(x, cpu.reg); // }/*from w ww .j a v a2 s .c o m*/ Label continueLabel = new Label(); Label isReturnAddress = new Label(); mv.visitInsn(Opcodes.DUP); loadRegister(reg); visitJump(Opcodes.IF_ICMPEQ, isReturnAddress); loadRegister(reg); mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextInternalName, "jump", "(II)V"); mv.visitJumpInsn(Opcodes.GOTO, continueLabel); mv.visitLabel(isReturnAddress); mv.visitInsn(Opcodes.POP); mv.visitLabel(continueLabel); }
From source file:jpcsp.Allegrex.compiler.CompilerContext.java
License:Open Source License
@SuppressWarnings("unused") public void startInstruction(CodeInstruction codeInstruction) { if (RuntimeContext.enableLineNumbers) { int lineNumber = codeInstruction.getAddress() - getCodeBlock().getLowestAddress(); // Java line number is unsigned 16bits if (lineNumber >= 0 && lineNumber <= 0xFFFF) { mv.visitLineNumber(lineNumber, codeInstruction.getLabel()); }/* ww w . j ava2 s . c o m*/ } // The pc is used by the DebuggerMemory or the LLE/MMIO if (Memory.getInstance() instanceof DebuggerMemory || RuntimeContextLLE.isLLEActive()) { storePc(); } if (RuntimeContextLLE.isLLEActive()) { startInstructionLLE(codeInstruction); } if (RuntimeContext.debugCodeInstruction) { loadImm(codeInstruction.getAddress()); loadImm(codeInstruction.getOpcode()); mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextInternalName, RuntimeContext.debugCodeInstructionName, "(II)V"); } if (RuntimeContext.enableInstructionTypeCounting) { if (codeInstruction.getInsn() != null) { loadInstruction(codeInstruction.getInsn()); loadImm(codeInstruction.getOpcode()); mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextInternalName, RuntimeContext.instructionTypeCount, "(" + instructionDescriptor + "I)V"); } } if (RuntimeContext.enableDebugger) { loadImm(codeInstruction.getAddress()); mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextInternalName, RuntimeContext.debuggerName, "(I)V"); } if (RuntimeContext.checkCodeModification && !(codeInstruction instanceof NativeCodeInstruction)) { // Generate the following sequence: // // if (memory.read32(pc) != opcode) { // RuntimeContext.onCodeModification(pc, opcode); // } // loadMemory(); loadImm(codeInstruction.getAddress()); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, memoryInternalName, "read32", "(I)I"); loadImm(codeInstruction.getOpcode()); Label codeUnchanged = new Label(); mv.visitJumpInsn(Opcodes.IF_ICMPEQ, codeUnchanged); loadImm(codeInstruction.getAddress()); loadImm(codeInstruction.getOpcode()); mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextInternalName, "onCodeModification", "(II)V"); mv.visitLabel(codeUnchanged); } if (!isNonBranchingCodeSequence(codeInstruction)) { startNonBranchingCodeSequence(); } // This instructions consumes the PFXT prefix but does not use it. if (codeInstruction.hasFlags(Instruction.FLAG_CONSUMES_VFPU_PFXT)) { disablePfxSrc(vfpuPfxtState); } }