List of usage examples for org.objectweb.asm Opcodes IUSHR
int IUSHR
To view the source code for org.objectweb.asm Opcodes IUSHR.
Click Source Link
From source file:org.evosuite.instrumentation.mutation.TestReplaceBitwiseOperator.java
License:Open Source License
@Test public void testGetInfectionDistanceIntShift() { assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(1, 0, Opcodes.ISHL, Opcodes.ISHR), 1.0, 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(1, 1, Opcodes.ISHL, Opcodes.ISHR), 0.0, 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(1, 0, Opcodes.ISHL, Opcodes.IUSHR), 1.0, 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(1, 1, Opcodes.ISHL, Opcodes.IUSHR), 0.0, 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(1, 0, Opcodes.ISHR, Opcodes.IUSHR), 1.0, 0.0); assertEquals(2.0, ReplaceBitwiseOperator.getInfectionDistanceInt(1, 1, Opcodes.ISHR, Opcodes.IUSHR), 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(-1, 1, Opcodes.ISHR, Opcodes.IUSHR), 0.0, 0.0); assertEquals(2.0, ReplaceBitwiseOperator.getInfectionDistanceInt(1, -1, Opcodes.ISHR, Opcodes.IUSHR), 0.0); assertEquals(ReplaceBitwiseOperator.getInfectionDistanceInt(-1, -1, Opcodes.ISHR, Opcodes.IUSHR), 0.0, 0.0); assertEquals(0.0, ReplaceBitwiseOperator.getInfectionDistanceInt(-1449, -1, Opcodes.ISHR, Opcodes.IUSHR), 0.0);//from www. j a v a 2s. c om }
From source file:org.jacoco.core.internal.instr.FrameTracker.java
License:Open Source License
@Override public void visitInsn(final int opcode) { final Object t1, t2, t3, t4; switch (opcode) { case Opcodes.NOP: case Opcodes.RETURN: break;/*from w w w .j a va 2s. co m*/ case Opcodes.ARETURN: case Opcodes.ATHROW: case Opcodes.FRETURN: case Opcodes.IRETURN: case Opcodes.MONITORENTER: case Opcodes.MONITOREXIT: case Opcodes.POP: pop(1); break; case Opcodes.DRETURN: case Opcodes.LRETURN: case Opcodes.POP2: pop(2); break; case Opcodes.AASTORE: case Opcodes.BASTORE: case Opcodes.CASTORE: case Opcodes.FASTORE: case Opcodes.IASTORE: case Opcodes.SASTORE: pop(3); break; case Opcodes.LASTORE: case Opcodes.DASTORE: pop(4); break; case Opcodes.ICONST_M1: case Opcodes.ICONST_0: case Opcodes.ICONST_1: case Opcodes.ICONST_2: case Opcodes.ICONST_3: case Opcodes.ICONST_4: case Opcodes.ICONST_5: push(Opcodes.INTEGER); break; case Opcodes.ARRAYLENGTH: case Opcodes.F2I: case Opcodes.I2B: case Opcodes.I2C: case Opcodes.I2S: case Opcodes.INEG: pop(1); push(Opcodes.INTEGER); break; case Opcodes.BALOAD: case Opcodes.CALOAD: case Opcodes.D2I: case Opcodes.FCMPG: case Opcodes.FCMPL: case Opcodes.IADD: case Opcodes.IALOAD: case Opcodes.IAND: case Opcodes.IDIV: case Opcodes.IMUL: case Opcodes.IOR: case Opcodes.IREM: case Opcodes.ISHL: case Opcodes.ISHR: case Opcodes.ISUB: case Opcodes.IUSHR: case Opcodes.IXOR: case Opcodes.L2I: case Opcodes.SALOAD: pop(2); push(Opcodes.INTEGER); break; case Opcodes.DCMPG: case Opcodes.DCMPL: case Opcodes.LCMP: pop(4); push(Opcodes.INTEGER); break; case Opcodes.FCONST_0: case Opcodes.FCONST_1: case Opcodes.FCONST_2: push(Opcodes.FLOAT); break; case Opcodes.FNEG: case Opcodes.I2F: pop(1); push(Opcodes.FLOAT); break; case Opcodes.D2F: case Opcodes.FADD: case Opcodes.FALOAD: case Opcodes.FDIV: case Opcodes.FMUL: case Opcodes.FREM: case Opcodes.FSUB: case Opcodes.L2F: pop(2); push(Opcodes.FLOAT); break; case Opcodes.LCONST_0: case Opcodes.LCONST_1: push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.F2L: case Opcodes.I2L: pop(1); push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.D2L: case Opcodes.LALOAD: case Opcodes.LNEG: pop(2); push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.LSHL: case Opcodes.LSHR: case Opcodes.LUSHR: pop(3); push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.LADD: case Opcodes.LAND: case Opcodes.LDIV: case Opcodes.LMUL: case Opcodes.LOR: case Opcodes.LREM: case Opcodes.LSUB: case Opcodes.LXOR: pop(4); push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.DCONST_0: case Opcodes.DCONST_1: push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Opcodes.F2D: case Opcodes.I2D: pop(1); push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Opcodes.DALOAD: case Opcodes.DNEG: case Opcodes.L2D: pop(2); push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Opcodes.DADD: case Opcodes.DDIV: case Opcodes.DMUL: case Opcodes.DREM: case Opcodes.DSUB: pop(4); push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Opcodes.ACONST_NULL: push(Opcodes.NULL); break; case Opcodes.AALOAD: pop(1); t1 = pop(); push(Type.getType(((String) t1).substring(1))); break; case Opcodes.DUP: t1 = pop(); push(t1); push(t1); break; case Opcodes.DUP_X1: t1 = pop(); t2 = pop(); push(t1); push(t2); push(t1); break; case Opcodes.DUP_X2: t1 = pop(); t2 = pop(); t3 = pop(); push(t1); push(t3); push(t2); push(t1); break; case Opcodes.DUP2: t1 = pop(); t2 = pop(); push(t2); push(t1); push(t2); push(t1); break; case Opcodes.DUP2_X1: t1 = pop(); t2 = pop(); t3 = pop(); push(t2); push(t1); push(t3); push(t2); push(t1); break; case Opcodes.DUP2_X2: t1 = pop(); t2 = pop(); t3 = pop(); t4 = pop(); push(t2); push(t1); push(t4); push(t3); push(t2); push(t1); break; case Opcodes.SWAP: t1 = pop(); t2 = pop(); push(t1); push(t2); break; default: throw new IllegalArgumentException(); } mv.visitInsn(opcode); }
From source file:org.jboss.byteman.rule.expression.ShiftExpression.java
License:Open Source License
public void compile(MethodVisitor mv, CompileContext compileContext) throws CompileException { // make sure we are at the right source line compileContext.notifySourceLine(line); int currentStack = compileContext.getStackCount(); int expected = 0; Expression oper0 = getOperand(0); Expression oper1 = getOperand(1); // compile the operands and make sure the first result is our target type and the second is int oper0.compile(mv, compileContext);//from w w w . j av a 2 s. c om compileTypeConversion(oper0.getType(), type, mv, compileContext); oper1.compile(mv, compileContext); compileTypeConversion(oper1.getType(), Type.I, mv, compileContext); if (type == Type.B || type == Type.S || type == Type.I) { switch (oper) { case LSH: mv.visitInsn(Opcodes.ISHL); break; case RSH: if (type == Type.C) { mv.visitInsn(Opcodes.IUSHR); } else { mv.visitInsn(Opcodes.ISHR); } break; case URSH: mv.visitInsn(Opcodes.IUSHR); break; } if (type == Type.B) { mv.visitInsn(Opcodes.I2B); } else if (type == Type.S) { mv.visitInsn(Opcodes.I2S); } else if (type == Type.C) { mv.visitInsn(Opcodes.I2C); } // ok, we popped two words but added one compileContext.addStackCount(-1); expected = 1; } else if (type == Type.J) { switch (oper) { case LSH: mv.visitInsn(Opcodes.LSHL); break; case RSH: mv.visitInsn(Opcodes.LSHR); break; case URSH: mv.visitInsn(Opcodes.LUSHR); break; } // ok, we popped three words but added two compileContext.addStackCount(-1); expected = 2; } // we have either a 1 words or a 2 words result // check that the stack height is what we expect if (compileContext.getStackCount() != currentStack + expected) { throw new CompileException("ShiftExpression.compile : invalid stack height " + compileContext.getStackCount() + " expecting " + currentStack + expected); } }
From source file:org.openquark.cal.internal.javamodel.AsmJavaBytecodeGenerator.java
License:Open Source License
private static final int getBinaryIntOpCode(String op) { switch (op.charAt(0)) { case '-': return Opcodes.ISUB; case '+': return Opcodes.IADD; case '%': return Opcodes.IREM; case '*': return Opcodes.IMUL; case '/': return Opcodes.IDIV; case '&': return Opcodes.IAND; case '|': return Opcodes.IOR; case '^': return Opcodes.IXOR; case '<': return Opcodes.ISHL; case '>': return op.equals(">>>") ? Opcodes.IUSHR : Opcodes.ISHR; default:/*from w w w.ja va2s.c om*/ throw new IllegalArgumentException("Invalid operand " + op); } }
From source file:org.sonar.java.bytecode.se.BytecodeEGWalkerExecuteTest.java
License:Open Source License
@Test public void test_shift() throws Exception { int[] shiftOpcodes = new int[] { Opcodes.ISHL, Opcodes.LSHL, Opcodes.ISHR, Opcodes.LSHR, Opcodes.IUSHR, Opcodes.LUSHR };/*from www .jav a 2 s. c o m*/ assertConsume2produceNotNull(shiftOpcodes); assertThrowWhenInvalidStack(shiftOpcodes, " needs 2 values on stack"); }
From source file:org.sonar.java.bytecode.se.BytecodeSECheckTest.java
License:Open Source License
@Test public void zeroness_check_shifts() { int[] opCodes = { Opcodes.ISHL, Opcodes.LSHL, Opcodes.ISHR, Opcodes.LSHR, Opcodes.IUSHR, Opcodes.LUSHR }; for (int shiftOpCode : opCodes) { Instruction instruction = new Instruction(shiftOpCode); ProgramState ps = execute(instruction, zeroZeroPs); SymbolicValue peekValue = ps.peekValue(); assertThat(peekValue).isEqualTo(sv2); ConstraintsByDomain constraints = ps.getConstraints(peekValue); assertThat(constraints.get(ZeroConstraint.class)).isEqualTo(ZeroConstraint.ZERO); assertThat(constraints.get(BooleanConstraint.class)).isEqualTo(BooleanConstraint.FALSE); ps = execute(instruction, zeroNonZeroPs); peekValue = ps.peekValue();/*from w ww. j av a2s . co m*/ assertThat(peekValue).isNotIn(sv1, sv2); constraints = ps.getConstraints(peekValue); assertThat(constraints.get(ZeroConstraint.class)).isEqualTo(ZeroConstraint.NON_ZERO); assertThat(constraints.get(BooleanConstraint.class)).isNull(); ps = execute(instruction, nonZeroZeroPs); peekValue = ps.peekValue(); assertThat(peekValue).isEqualTo(sv2); constraints = ps.getConstraints(peekValue); assertThat(constraints.get(ZeroConstraint.class)).isEqualTo(ZeroConstraint.ZERO); assertThat(constraints.get(BooleanConstraint.class)).isEqualTo(BooleanConstraint.FALSE); ps = execute(instruction, nonZeroNonZeroPs); peekValue = ps.peekValue(); assertThat(peekValue).isNotIn(sv1, sv2); constraints = ps.getConstraints(peekValue); assertThat(constraints.get(ZeroConstraint.class)).isEqualTo(ZeroConstraint.NON_ZERO); assertThat(constraints.get(BooleanConstraint.class)).isNull(); } }
From source file:serianalyzer.JVMImpl.java
License:Open Source License
/** * @param opcode/*from w ww . ja v a2 s. com*/ * @param s */ static void handleJVMInsn(int opcode, JVMStackState s) { BaseType o1; BaseType o2; BaseType o3; List<BaseType> l1; List<BaseType> l2; switch (opcode) { case Opcodes.NOP: break; case Opcodes.ARRAYLENGTH: o1 = s.pop(); s.push(new BasicConstant(Type.INT_TYPE, 0, !(o1 != null && !o1.isTainted()))); break; case Opcodes.ACONST_NULL: s.push(new BasicConstant(Type.VOID_TYPE, "<null>")); //$NON-NLS-1$ break; case Opcodes.ICONST_M1: case Opcodes.ICONST_0: case Opcodes.ICONST_1: case Opcodes.ICONST_2: case Opcodes.ICONST_3: case Opcodes.ICONST_4: case Opcodes.ICONST_5: s.push(new BasicConstant(Type.INT_TYPE, opcode - 3)); break; case Opcodes.LCONST_0: case Opcodes.LCONST_1: s.push(new BasicConstant(Type.LONG_TYPE, opcode - 9L)); break; case Opcodes.FCONST_0: case Opcodes.FCONST_1: case Opcodes.FCONST_2: s.push(new BasicConstant(Type.FLOAT_TYPE, opcode - 11f)); break; case Opcodes.DCONST_0: case Opcodes.DCONST_1: s.push(new BasicConstant(Type.DOUBLE_TYPE, opcode - 14d)); break; case Opcodes.IALOAD: case Opcodes.LALOAD: case Opcodes.FALOAD: case Opcodes.DALOAD: case Opcodes.BALOAD: case Opcodes.CALOAD: case Opcodes.SALOAD: o1 = s.pop(); o2 = s.pop(); s.push(new BasicVariable(toType(opcode), "primitive array elem", //$NON-NLS-1$ (o1 == null || o1.isTainted()) | (o2 == null || o2.isTainted()))); break; case Opcodes.AALOAD: o1 = s.pop(); o2 = s.pop(); if (o1 != null && o2 instanceof SimpleType && ((SimpleType) o2).getType().toString().startsWith("[")) { //$NON-NLS-1$ Type atype = Type.getType(((SimpleType) o2).getType().toString().substring(1)); if (o2.getAlternativeTypes() != null && !o2.getAlternativeTypes().isEmpty()) { s.clear(); break; } s.push(new BasicVariable(atype, "array elem " + atype, o1.isTainted() | o2.isTainted())); //$NON-NLS-1$ } else { s.clear(); } break; case Opcodes.IASTORE: case Opcodes.LASTORE: case Opcodes.FASTORE: case Opcodes.DASTORE: case Opcodes.AASTORE: case Opcodes.BASTORE: case Opcodes.CASTORE: case Opcodes.SASTORE: s.pop(3); break; case Opcodes.POP2: s.pop(); case Opcodes.MONITORENTER: case Opcodes.MONITOREXIT: case Opcodes.POP: s.pop(); break; case Opcodes.DUP: if (!s.isEmpty()) { o1 = s.pop(); s.push(o1); s.push(o1); } break; case Opcodes.DUP_X1: o1 = s.pop(); o2 = s.pop(); s.push(o1); s.push(o2); s.push(o1); break; case Opcodes.DUP_X2: o1 = s.pop(); o2 = s.pop(); o3 = s.pop(); s.push(o1); s.push(o3); s.push(o2); s.push(o1); break; case Opcodes.DUP2: l1 = s.popWord(); if (l1.isEmpty()) { log.trace("DUP2 with unknown operand"); //$NON-NLS-1$ s.clear(); } else { s.pushWord(l1); s.pushWord(l1); } break; case Opcodes.DUP2_X1: l1 = s.popWord(); o1 = s.pop(); if (l1.isEmpty()) { log.trace("DUP2 with unknown operand"); //$NON-NLS-1$ s.clear(); } else { s.pushWord(l1); s.push(o1); s.pushWord(l1); } break; case Opcodes.DUP2_X2: l1 = s.popWord(); l2 = s.popWord(); if (l1.isEmpty() || l2.isEmpty()) { log.trace("DUP2 with unknown operand"); //$NON-NLS-1$ s.clear(); } else { s.pushWord(l1); s.pushWord(l2); s.pushWord(l1); } break; case Opcodes.SWAP: o1 = s.pop(); o2 = s.pop(); s.push(o1); s.push(o2); break; case Opcodes.IADD: case Opcodes.LADD: case Opcodes.FADD: case Opcodes.DADD: case Opcodes.ISUB: case Opcodes.LSUB: case Opcodes.FSUB: case Opcodes.DSUB: case Opcodes.IMUL: case Opcodes.LMUL: case Opcodes.FMUL: case Opcodes.DMUL: case Opcodes.IDIV: case Opcodes.LDIV: case Opcodes.FDIV: case Opcodes.DDIV: case Opcodes.IREM: case Opcodes.LREM: case Opcodes.FREM: case Opcodes.DREM: case Opcodes.IAND: case Opcodes.LAND: case Opcodes.IOR: case Opcodes.LOR: case Opcodes.IXOR: case Opcodes.LXOR: case Opcodes.LCMP: case Opcodes.FCMPL: case Opcodes.FCMPG: case Opcodes.DCMPL: case Opcodes.DCMPG: s.merge(2); break; case Opcodes.ISHL: case Opcodes.LSHL: case Opcodes.ISHR: case Opcodes.LSHR: case Opcodes.IUSHR: case Opcodes.LUSHR: s.pop(); // amount // ignore value break; case Opcodes.INEG: case Opcodes.F2I: case Opcodes.D2I: case Opcodes.L2I: s.push(cast(s.pop(), Type.INT_TYPE)); break; case Opcodes.LNEG: case Opcodes.I2L: case Opcodes.F2L: case Opcodes.D2L: s.push(cast(s.pop(), Type.LONG_TYPE)); break; case Opcodes.FNEG: case Opcodes.I2F: case Opcodes.L2F: case Opcodes.D2F: s.push(cast(s.pop(), Type.FLOAT_TYPE)); case Opcodes.DNEG: case Opcodes.I2D: case Opcodes.L2D: case Opcodes.F2D: s.push(cast(s.pop(), Type.DOUBLE_TYPE)); case Opcodes.I2B: s.push(cast(s.pop(), Type.BYTE_TYPE)); break; case Opcodes.I2C: s.push(cast(s.pop(), Type.CHAR_TYPE)); break; case Opcodes.I2S: s.push(cast(s.pop(), Type.SHORT_TYPE)); break; case Opcodes.ARETURN: s.clear(); break; case Opcodes.IRETURN: case Opcodes.LRETURN: case Opcodes.FRETURN: case Opcodes.DRETURN: case Opcodes.RETURN: if (log.isTraceEnabled()) { log.trace("Found return " + s.pop()); //$NON-NLS-1$ } s.clear(); break; case Opcodes.ATHROW: Object thrw = s.pop(); log.trace("Found throw " + thrw); //$NON-NLS-1$ s.clear(); break; default: log.warn("Unsupported instruction code " + opcode); //$NON-NLS-1$ } }