Example usage for org.objectweb.asm Opcodes IALOAD

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

Introduction

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

Prototype

int IALOAD

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

Click Source Link

Usage

From source file:org.evosuite.graphs.cfg.ASMWrapper.java

License:Open Source License

public boolean isArrayLoadInstruction() {
    return asmNode.getOpcode() == Opcodes.IALOAD || asmNode.getOpcode() == Opcodes.LALOAD
            || asmNode.getOpcode() == Opcodes.FALOAD || asmNode.getOpcode() == Opcodes.DALOAD
            || asmNode.getOpcode() == Opcodes.AALOAD;
}

From source file:org.evosuite.instrumentation.error.ArrayInstrumentation.java

License:Open Source License

@Override
public void visitInsn(int opcode) {
    // Check array accesses
    if (opcode == Opcodes.IALOAD || opcode == Opcodes.BALOAD || opcode == Opcodes.CALOAD
            || opcode == Opcodes.SALOAD || opcode == Opcodes.LALOAD || opcode == Opcodes.FALOAD
            || opcode == Opcodes.DALOAD || opcode == Opcodes.AALOAD) {

        mv.visitInsn(Opcodes.DUP);/*from   w  ww. j a va2 s. c  o  m*/
        insertBranch(Opcodes.IFGE, "java/lang/ArrayIndexOutOfBoundsException");

        mv.visitInsn(Opcodes.DUP2);
        mv.visitInsn(Opcodes.SWAP);
        //mv.visitInsn(Opcodes.POP);
        mv.visitInsn(Opcodes.ARRAYLENGTH);
        insertBranch(Opcodes.IF_ICMPLT, "java/lang/ArrayIndexOutOfBoundsException");

    } else if (opcode == Opcodes.IASTORE || opcode == Opcodes.BASTORE || opcode == Opcodes.CASTORE
            || opcode == Opcodes.SASTORE || opcode == Opcodes.AASTORE || opcode == Opcodes.LASTORE
            || opcode == Opcodes.FASTORE || opcode == Opcodes.DASTORE) {

        int loc = 0;
        if (opcode == Opcodes.IASTORE)
            loc = mv.newLocal(Type.INT_TYPE);
        else if (opcode == Opcodes.BASTORE)
            loc = mv.newLocal(Type.BYTE_TYPE);
        else if (opcode == Opcodes.CASTORE)
            loc = mv.newLocal(Type.CHAR_TYPE);
        else if (opcode == Opcodes.SASTORE)
            loc = mv.newLocal(Type.SHORT_TYPE);
        else if (opcode == Opcodes.AASTORE)
            loc = mv.newLocal(Type.getType(Object.class));
        else if (opcode == Opcodes.LASTORE)
            loc = mv.newLocal(Type.LONG_TYPE);
        else if (opcode == Opcodes.FASTORE)
            loc = mv.newLocal(Type.FLOAT_TYPE);
        else if (opcode == Opcodes.DASTORE)
            loc = mv.newLocal(Type.DOUBLE_TYPE);
        else
            throw new RuntimeException("Unknown type");
        mv.storeLocal(loc);

        mv.visitInsn(Opcodes.DUP);
        insertBranch(Opcodes.IFGE, "java/lang/ArrayIndexOutOfBoundsException");

        mv.visitInsn(Opcodes.DUP2);
        mv.visitInsn(Opcodes.SWAP);
        //mv.visitInsn(Opcodes.POP);
        mv.visitInsn(Opcodes.ARRAYLENGTH);
        insertBranch(Opcodes.IF_ICMPLT, "java/lang/ArrayIndexOutOfBoundsException");

        mv.loadLocal(loc);
    }
}

From source file:org.evosuite.instrumentation.error.NullPointerExceptionInstrumentation.java

License:Open Source License

@Override
public void visitInsn(int opcode) {
    switch (opcode) {
    case Opcodes.ARRAYLENGTH:
        // TODO/*  www . java2s .  co  m*/
        break;
    case Opcodes.BALOAD:
    case Opcodes.CALOAD:
    case Opcodes.SALOAD:
    case Opcodes.IALOAD:
    case Opcodes.LALOAD:
    case Opcodes.FALOAD:
    case Opcodes.DALOAD:
    case Opcodes.AALOAD:
        // TODO
        break;

    case Opcodes.BASTORE:
    case Opcodes.CASTORE:
    case Opcodes.SASTORE:
    case Opcodes.IASTORE:
    case Opcodes.LASTORE:
    case Opcodes.FASTORE:
    case Opcodes.DASTORE:
    case Opcodes.AASTORE:
        // TODO
        break;
    default:
        // Ignore everything else
    }
    super.visitInsn(opcode);
}

From source file:org.evosuite.instrumentation.mutation.ReplaceArithmeticOperator.java

License:Open Source License

@SuppressWarnings("rawtypes")
private static int getNextIndexFromLoad(MethodNode mn) {
    Iterator it = mn.instructions.iterator();
    int index = 0;
    while (it.hasNext()) {
        AbstractInsnNode node = (AbstractInsnNode) it.next();
        if (node instanceof VarInsnNode) {
            VarInsnNode varNode = (VarInsnNode) node;
            int varIndex = varNode.var;
            switch (varNode.getOpcode()) {
            case Opcodes.ALOAD:
            case Opcodes.ILOAD:
            case Opcodes.FLOAD:
            case Opcodes.IALOAD:
            case Opcodes.BALOAD:
            case Opcodes.CALOAD:
            case Opcodes.AALOAD:
            case Opcodes.ASTORE:
            case Opcodes.ISTORE:
            case Opcodes.FSTORE:
            case Opcodes.IASTORE:
            case Opcodes.BASTORE:
            case Opcodes.CASTORE:
            case Opcodes.AASTORE:
                index = Math.max(index, varIndex + 1);
                break;
            case Opcodes.DLOAD:
            case Opcodes.DSTORE:
            case Opcodes.LLOAD:
            case Opcodes.LSTORE:
            case Opcodes.DALOAD:
            case Opcodes.DASTORE:
            case Opcodes.LALOAD:
            case Opcodes.LASTORE:
                index = Math.max(index, varIndex + 2);
                break;
            }/*from w  w  w  .j a  v a 2 s.  c o m*/
        }
    }

    return index;
}

From source file:org.evosuite.instrumentation.testability.transformer.BooleanArrayIndexTransformer.java

License:Open Source License

@Override
protected AbstractInsnNode transformInsnNode(MethodNode mn, InsnNode insnNode) {
    if (frames == null) {
        return insnNode;
    }//from w w  w  . ja  v a  2  s  . c o  m

    if (insnNode.getOpcode() == Opcodes.BALOAD) {
        Frame current = frames[mn.instructions.indexOf(insnNode)];
        int size = current.getStackSize();
        if (current.getStack(size - 2) == BooleanArrayInterpreter.INT_ARRAY) {
            BooleanTestabilityTransformation.logger.info("Array is of boolean type, changing BALOAD to IALOAD");
            InsnNode replacement = new InsnNode(Opcodes.IALOAD);
            mn.instructions.insertBefore(insnNode, replacement);
            mn.instructions.remove(insnNode);
            return replacement;
        }
    } else if (insnNode.getOpcode() == Opcodes.BASTORE) {
        Frame current = frames[mn.instructions.indexOf(insnNode)];
        int size = current.getStackSize();
        if (current.getStack(size - 3) == BooleanArrayInterpreter.INT_ARRAY) {
            BooleanTestabilityTransformation.logger
                    .info("Array is of boolean type, changing BASTORE to IASTORE");
            InsnNode replacement = new InsnNode(Opcodes.IASTORE);
            mn.instructions.insertBefore(insnNode, replacement);
            mn.instructions.remove(insnNode);
            return replacement;
        }
    }
    return insnNode;
}

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;/*ww w. j a v a  2  s  .c  o 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.agent.adapter.RuleGeneratorAdapter.java

License:Open Source License

/**
 * Generates the instruction to load an element from an array.
 *
 * @param type the type of the array element to be loaded.
 *///from   ww  w  .ja va2  s.c o m
public void arrayLoad(final Type type) {
    visitInsn(type.getOpcode(Opcodes.IALOAD));
}

From source file:org.jboss.byteman.rule.expression.ArrayExpression.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);

    Type valueType = arrayRef.getType().getBaseType();
    int currentStack = compileContext.getStackCount();
    int expected = 0;

    // compile load of array reference -- adds 1 to stack height
    arrayRef.compile(mv, compileContext);
    // for each index expression compile the expression and the do an array load
    Iterator<Expression> iterator = idxList.iterator();

    while (iterator.hasNext()) {
        Expression idxExpr = iterator.next();
        // compile expression index -- adds 1 to height
        idxExpr.compile(mv, compileContext);
        // make sure the index is an integer
        compileTypeConversion(idxExpr.getType(), Type.I, mv, compileContext);

        if (valueType.isObject() || valueType.isArray()) {
            // compile load object - pops 2 and adds 1
            mv.visitInsn(Opcodes.AALOAD);
            expected = 1;/*from  ww w .  j a  v a 2  s. c om*/
        } else if (valueType == Type.Z || valueType == Type.B) {
            // compile load byte - pops 2 and adds 1
            mv.visitInsn(Opcodes.BALOAD);
            expected = 1;
        } else if (valueType == Type.S) {
            // compile load short - pops 2 and adds 1
            mv.visitInsn(Opcodes.SALOAD);
            expected = 1;
        } else if (valueType == Type.C) {
            // compile load char - pops 2 and adds 1
            mv.visitInsn(Opcodes.CALOAD);
            expected = 1;
        } else if (valueType == Type.I) {
            // compile load int - pops 2 and adds 1
            mv.visitInsn(Opcodes.IALOAD);
            expected = 1;
        } else if (valueType == Type.J) {
            // compile load long - pops 2 and adds 2
            mv.visitInsn(Opcodes.LALOAD);
            expected = 2;
        } else if (valueType == Type.F) {
            // compile load float - pops 2 and adds 1
            mv.visitInsn(Opcodes.FALOAD);
            expected = 1;
        } else if (valueType == Type.D) {
            // compile load double - pops 2 and adds 2
            mv.visitInsn(Opcodes.DALOAD);
            expected = 2;
        }
        compileContext.addStackCount(expected - 2);
        if (iterator.hasNext()) {
            assert valueType.isArray();
            valueType = valueType.getBaseType();
        }
    }

    // check stack height
    if (compileContext.getStackCount() != currentStack + expected) {
        throw new CompileException("ArrayExpression.compile : invalid stack height "
                + compileContext.getStackCount() + " expecting " + (currentStack + expected));
    }

    // we needed room for an aray and an index or for a one or two word result
    // but the recursive evaluations will have made sure the max stack is big enough
    // so there is no need to update the maximum stack height
}

From source file:org.openquark.cal.internal.javamodel.AsmJavaBytecodeGenerator.java

License:Open Source License

/**
 * @param elemType element type of the array.
 * @return java op-code to use for loading arrays with elements of the specified type.
 *//*from  ww  w  .j  a  v  a 2s  . c om*/
private static int getArrayLoadOpCode(JavaTypeName elemType) {

    switch (elemType.getTag()) {

    case JavaTypeName.VOID_TAG:
        throw new IllegalArgumentException();

    case JavaTypeName.BOOLEAN_TAG:
    case JavaTypeName.BYTE_TAG:
        return Opcodes.BALOAD;

    case JavaTypeName.SHORT_TAG:
        return Opcodes.SALOAD;

    case JavaTypeName.CHAR_TAG:
        return Opcodes.CALOAD;

    case JavaTypeName.INT_TAG:
        return Opcodes.IALOAD;

    case JavaTypeName.LONG_TAG:
        return Opcodes.LALOAD;

    case JavaTypeName.DOUBLE_TAG:
        return Opcodes.DALOAD;

    case JavaTypeName.FLOAT_TAG:
        return Opcodes.FALOAD;

    case JavaTypeName.ARRAY_TAG:
    case JavaTypeName.OBJECT_TAG:
        return Opcodes.AALOAD;

    default: {
        throw new IllegalArgumentException();
    }
    }
}

From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator1.java

License:Apache License

@Override
public void visitInsn(final int opcode) {
    // I F L D + BS
    switch (opcode) {
    case Opcodes.IALOAD:
        if (this.shouldMutate("Incremented (a++) integer array field")) {
            mv.visitInsn(Opcodes.DUP2); // Array and its index on stack, times two
            mv.visitInsn(opcode); // IALOAD
            mv.visitInsn(Opcodes.DUP_X2); // put the result of array[index] under [array ref] [index] [array[index]]
            mv.visitInsn(Opcodes.ICONST_1);
            mv.visitInsn(Opcodes.IADD);/*from  ww w.j  av a2  s . co  m*/
            mv.visitInsn(Opcodes.IASTORE);
        } else {
            mv.visitInsn(opcode);
        }
        break;
    case Opcodes.FALOAD:
        if (this.shouldMutate("Incremented (a++) float array field")) {
            mv.visitInsn(Opcodes.DUP2);
            mv.visitInsn(opcode);
            mv.visitInsn(Opcodes.DUP_X2);
            mv.visitInsn(Opcodes.FCONST_1);
            mv.visitInsn(Opcodes.FADD);
            mv.visitInsn(Opcodes.FASTORE);
        } else {
            mv.visitInsn(opcode);
        }
        break;
    case Opcodes.LALOAD:
        if (this.shouldMutate("Incremented (a++) long array field")) {
            mv.visitInsn(Opcodes.DUP2);
            mv.visitInsn(opcode);
            mv.visitInsn(Opcodes.DUP2_X2);
            mv.visitInsn(Opcodes.LCONST_1);
            mv.visitInsn(Opcodes.LADD);
            mv.visitInsn(Opcodes.LASTORE);
        } else {
            mv.visitInsn(opcode);
        }
        break;
    case Opcodes.DALOAD:
        if (this.shouldMutate("Incremented (a++) double array field")) {
            mv.visitInsn(Opcodes.DUP2);
            mv.visitInsn(opcode);
            mv.visitInsn(Opcodes.DUP2_X2);
            mv.visitInsn(Opcodes.DCONST_1);
            mv.visitInsn(Opcodes.DADD);
            mv.visitInsn(Opcodes.DASTORE);
        } else {
            mv.visitInsn(opcode);
        }
        break;

    case Opcodes.BALOAD:
        if (this.shouldMutate("Incremented (a++) byte array field")) {
            mv.visitInsn(Opcodes.DUP2);
            mv.visitInsn(opcode);
            mv.visitInsn(Opcodes.DUP_X2);
            mv.visitInsn(Opcodes.ICONST_1);
            mv.visitInsn(Opcodes.IADD);
            mv.visitInsn(Opcodes.I2B);
            mv.visitInsn(Opcodes.BASTORE);
        } else {
            mv.visitInsn(opcode);
        }
        break;

    case Opcodes.SALOAD:
        if (this.shouldMutate("Incremented (a++) short array field")) {
            mv.visitInsn(Opcodes.DUP2);
            mv.visitInsn(opcode);
            mv.visitInsn(Opcodes.DUP_X2);
            mv.visitInsn(Opcodes.ICONST_1);
            mv.visitInsn(Opcodes.IADD);
            mv.visitInsn(Opcodes.I2S);
            mv.visitInsn(Opcodes.SASTORE);
        } else {
            mv.visitInsn(opcode);
        }
        break;

    default:
        mv.visitInsn(opcode);
        break;
    }
}