Example usage for org.objectweb.asm Opcodes FLOAD

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

Introduction

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

Prototype

int FLOAD

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

Click Source Link

Usage

From source file:com.sun.fortress.compiler.asmbytecodeoptimizer.Inlining.java

License:Open Source License

public static List<Insn> convertInsns(MethodInsn mi, List<Insn> insns, int[] args, int _index, Label end) {
    List<Insn> result = new ArrayList<Insn>();
    HashMap labels = new HashMap();
    int index = _index;
    for (Insn i : insns) {
        if (i.isExpanded()) {
            MethodInsn expanded = (MethodInsn) i;
            // This use of end should be OK because all returns should have been removed when inlined before.
            // What could go wrong?
            result.addAll(convertInsns(expanded, expanded.inlineExpansionInsns, args, _index, end));
        } else if (i instanceof SingleInsn) {
            SingleInsn si = (SingleInsn) i;
            switch (si.opcode) {
            case Opcodes.IRETURN:
            case Opcodes.LRETURN:
            case Opcodes.FRETURN:
            case Opcodes.DRETURN:
            case Opcodes.ARETURN:
            case Opcodes.RETURN:
                result.add(new JumpInsn("RETURN->GOTO", Opcodes.GOTO, end, newIndex(mi, index++)));
                break;
            default:
                result.add(i.copy(newIndex(mi, index++)));
            }//from  w w  w.  j a  v  a 2 s .c  o m
        } else if (i instanceof VarInsn) {
            VarInsn vi = (VarInsn) i;
            switch (vi.opcode) {
            case Opcodes.ILOAD:
            case Opcodes.LLOAD:
            case Opcodes.FLOAD:
            case Opcodes.DLOAD:
            case Opcodes.ALOAD:
            case Opcodes.ISTORE:
            case Opcodes.LSTORE:
            case Opcodes.FSTORE:
            case Opcodes.DSTORE:
            case Opcodes.ASTORE:
                VarInsn newVarInsn = new VarInsn(vi.name, vi.opcode, args[vi.var], newIndex(mi, index++));
                result.add(newVarInsn);
                break;
            default:
                result.add(i.copy(newIndex(mi, index++)));
            }
        } else if (i instanceof VisitMaxs) {
        } else if (i instanceof VisitEnd) {
        } else if (i instanceof VisitCode) {
        } else if (i instanceof VisitFrame) {
        } else if (i instanceof LabelInsn) {
            LabelInsn li = (LabelInsn) i;
            if (labels.containsKey(li.label))
                result.add(new LabelInsn(li.name, (Label) labels.get(li.label), newIndex(mi, index++)));
            else {
                Label l = new Label();
                labels.put(li.label, l);
                result.add(new LabelInsn(li.name, l, newIndex(mi, index++)));
            }
        } else if (i instanceof JumpInsn) {
            JumpInsn ji = (JumpInsn) i;
            if (labels.containsKey(ji.label))
                result.add(
                        new JumpInsn(ji.name, ji.opcode, (Label) labels.get(ji.label), newIndex(mi, index++)));
            else {
                Label l = new Label();
                labels.put(ji.label, l);
                result.add(new JumpInsn(ji.name, ji.opcode, l, newIndex(mi, index++)));
            }
        } else if (i instanceof VisitLineNumberInsn) {
            VisitLineNumberInsn vlni = (VisitLineNumberInsn) i;
            if (labels.containsKey(vlni.start))
                result.add(new VisitLineNumberInsn(vlni.name, vlni.line, (Label) labels.get(vlni.start),
                        newIndex(mi, index++)));
            else {
                Label l = new Label();
                labels.put(vlni.start, l);
                result.add(new VisitLineNumberInsn(vlni.name, vlni.line, l, newIndex(mi, index++)));
            }
        } else if (i instanceof LocalVariableInsn) {
            LocalVariableInsn lvi = (LocalVariableInsn) i;
            if (labels.containsKey(lvi.start) && labels.containsKey(lvi.end)) {
                result.add(new LocalVariableInsn(lvi.name, lvi._name, lvi.desc, lvi.sig,
                        (Label) labels.get(lvi.start), (Label) labels.get(lvi.end), args[lvi._index],
                        newIndex(mi, index++)));
            } else
                throw new RuntimeException("NYI");
        } else if (i instanceof TryCatchBlock) {
            TryCatchBlock tcb = (TryCatchBlock) i;
            if (labels.containsKey(tcb.start) && labels.containsKey(tcb.end)
                    && labels.containsKey(tcb.handler)) {
                result.add(
                        new TryCatchBlock(tcb.name, (Label) labels.get(tcb.start), (Label) labels.get(tcb.end),
                                (Label) labels.get(tcb.handler), tcb.type, newIndex(mi, index++)));
            } else if (!labels.containsKey(tcb.start) && !labels.containsKey(tcb.end)
                    && !labels.containsKey(tcb.handler)) {
                Label s = new Label();
                Label e = new Label();
                Label h = new Label();
                labels.put(tcb.start, s);
                labels.put(tcb.end, e);
                labels.put(tcb.handler, h);
                result.add(new TryCatchBlock(tcb.name, s, e, h, tcb.type, newIndex(mi, index++)));
            } else
                throw new RuntimeException("NYI");
            // Need to add TableSwitch, LookupSwitch
        } else {
            result.add(i.copy(newIndex(mi, index++)));
        }
    }
    return result;
}

From source file:com.trigersoft.jaque.expression.ExpressionMethodVisitor.java

License:Apache License

@Override
public void visitVarInsn(int opcode, int var) {
    if (_me != null) {
        if (var == 0) {
            _exprStack.push(_me);/*from ww  w  .  j a  v a2  s.c o  m*/
            return;
        }
        var--;
    }
    Class<?> type;
    switch (opcode) {
    case Opcodes.ISTORE:
    case Opcodes.LSTORE:
    case Opcodes.FSTORE:
    case Opcodes.DSTORE:
    case Opcodes.ASTORE:
    case Opcodes.RET:
    default:
        throw notLambda(opcode);
    case Opcodes.ILOAD:
        type = Integer.TYPE;
        break;
    case Opcodes.LLOAD:
        type = Long.TYPE;
        break;
    case Opcodes.FLOAD:
        type = Float.TYPE;
        break;
    case Opcodes.DLOAD:
        type = Double.TYPE;
        break;
    case Opcodes.ALOAD:
        type = _argTypes[var];
        break;
    }

    _exprStack.push(Expression.parameter(type, var));
}

From source file:de.tuberlin.uebb.jbop.optimizer.methodsplitter.Block.java

License:Open Source License

private int getOpcode(final Type type) {
    if (Type.BOOLEAN_TYPE.equals(type)) {
        return Opcodes.ILOAD;
    }/*from   w  w  w  .j a v  a  2  s  .  co  m*/
    if (Type.INT_TYPE.equals(type)) {
        return Opcodes.ILOAD;
    }
    if (Type.FLOAT_TYPE.equals(type)) {
        return Opcodes.FLOAD;
    }
    if (Type.LONG_TYPE.equals(type)) {
        return Opcodes.LLOAD;
    }
    if (Type.DOUBLE_TYPE.equals(type)) {
        return Opcodes.DLOAD;
    }
    if (Type.CHAR_TYPE.equals(type)) {
        return Opcodes.ILOAD;
    }
    return Opcodes.ALOAD;
}

From source file:de.tuberlin.uebb.jbop.optimizer.methodsplitter.Block.java

License:Open Source License

private Type getTypeIfSimpleType(final AbstractInsnNode node) {
    final int opcode = node.getOpcode();
    if ((opcode == Opcodes.ILOAD) || (opcode == Opcodes.ISTORE) || (opcode == Opcodes.IRETURN)) {
        return Type.INT_TYPE;
    }/* w  w w . j ava  2  s . c  o m*/
    if ((opcode == Opcodes.FLOAD) || (opcode == Opcodes.FSTORE) || (opcode == Opcodes.FRETURN)) {
        return Type.FLOAT_TYPE;
    }
    if ((opcode == Opcodes.LLOAD) || (opcode == Opcodes.LSTORE) || (opcode == Opcodes.LRETURN)) {
        return Type.LONG_TYPE;
    }
    if ((opcode == Opcodes.DLOAD) || (opcode == Opcodes.DSTORE) || (opcode == Opcodes.DRETURN)) {
        return Type.DOUBLE_TYPE;
    }
    return null;
}

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

License:Open Source License

public VarInstruction(final ReadMethod readMethod, final int opcode, final int lineNumber,
        final int localVarIndex) {
    super(readMethod, opcode, lineNumber);
    assert opcode == Opcodes.ILOAD || opcode == Opcodes.LLOAD || opcode == Opcodes.FLOAD
            || opcode == Opcodes.DLOAD || opcode == Opcodes.ALOAD || opcode == Opcodes.ISTORE
            || opcode == Opcodes.LSTORE || opcode == Opcodes.FSTORE || opcode == Opcodes.DSTORE
            || opcode == Opcodes.ASTORE || opcode == Opcodes.RET;
    this.localVarIndex = localVarIndex;
}

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

License:Open Source License

private VarInstruction(final ReadMethod readMethod, final int lineNumber, final int opcode,
        final int localVarIndex, final int index) {
    super(readMethod, opcode, lineNumber, index);
    assert opcode == Opcodes.ILOAD || opcode == Opcodes.LLOAD || opcode == Opcodes.FLOAD
            || opcode == Opcodes.DLOAD || opcode == Opcodes.ALOAD || opcode == Opcodes.ISTORE
            || opcode == Opcodes.LSTORE || opcode == Opcodes.FSTORE || opcode == Opcodes.DSTORE
            || opcode == Opcodes.ASTORE || opcode == Opcodes.RET;
    this.localVarIndex = localVarIndex;
}

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

License:Open Source License

@Override
public String toString() {
    String instruction;//from ww w .j ava  2 s. c o m
    switch (getOpcode()) {
    case Opcodes.ILOAD:
        instruction = "ILOAD";
        break;
    case Opcodes.LLOAD:
        instruction = "LLOAD";
        break;
    case Opcodes.FLOAD:
        instruction = "FLOAD";
        break;
    case Opcodes.DLOAD:
        instruction = "DLOAD";
        break;
    case Opcodes.ALOAD:
        instruction = "ALOAD";
        break;
    case Opcodes.ISTORE:
        instruction = "ISTORE";
        break;
    case Opcodes.LSTORE:
        instruction = "LSTORE";
        break;
    case Opcodes.FSTORE:
        instruction = "FSTORE";
        break;
    case Opcodes.DSTORE:
        instruction = "DSTORE";
        break;
    case Opcodes.ASTORE:
        instruction = "ASTORE";
        break;
    case Opcodes.RET:
        instruction = "RET";
        break;
    default:
        instruction = "-ERROR-";
    }
    return new StringBuilder(instruction.length() + 11).append(instruction).append(' ')
            .append(this.localVarIndex).toString();
}

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

License:BSD License

@Override
public void visitVarInsn(final int opcode, final int var) {
    super.visitVarInsn(opcode, var);
    switch (opcode) {
    case Opcodes.ILOAD:
    case Opcodes.FLOAD:
        this.stackFrame.push(OTHER);
        break;//  ww  w  . j  a v  a2 s  .c  om
    case Opcodes.LLOAD:
    case Opcodes.DLOAD:
        this.stackFrame.push(OTHER);
        this.stackFrame.push(OTHER);
        break;
    case Opcodes.ALOAD:
        this.stackFrame.push(var == 0 ? THIS : OTHER);
        break;
    case Opcodes.ASTORE:
    case Opcodes.ISTORE:
    case Opcodes.FSTORE:
        this.stackFrame.pop();
        break;
    case Opcodes.LSTORE:
    case Opcodes.DSTORE:
        this.stackFrame.pop();
        this.stackFrame.pop();
        break;
    }
}

From source file:dyco4j.instrumentation.LoggingHelper.java

License:BSD License

public static int emitLogArgument(final MethodVisitor mv, final int position, final OptionalInt localVarIndex,
        final Type argType) {
    mv.visitLdcInsn(position);/* w  ww.j av  a2  s.co  m*/

    int _typeLength = 1;
    if (localVarIndex.isPresent()) {
        final int _tmp = localVarIndex.getAsInt();
        switch (argType.getSort()) {
        case Type.BOOLEAN:
        case Type.BYTE:
        case Type.CHAR:
        case Type.INT:
        case Type.SHORT:
            mv.visitVarInsn(Opcodes.ILOAD, _tmp);
            break;
        case Type.LONG:
            mv.visitVarInsn(Opcodes.LLOAD, _tmp);
            _typeLength++;
            break;
        case Type.FLOAT:
            mv.visitVarInsn(Opcodes.FLOAD, _tmp);
            break;
        case Type.DOUBLE:
            mv.visitVarInsn(Opcodes.DLOAD, _tmp);
            _typeLength++;
            break;
        case Type.ARRAY:
        case Type.OBJECT:
            mv.visitVarInsn(Opcodes.ALOAD, _tmp);
            break;
        }
    } else {
        mv.visitLdcInsn(Logger.UNINITIALIZED_THIS);
    }
    emitConvertToString(mv, argType);

    emitInvokeLog(mv, LOG_ARGUMENT);

    return _typeLength;
}

From source file:dyco4j.LoggingHelper.java

License:BSD License

public static int emitLogArgument(final MethodVisitor mv, final int index, final Type argType) {
    mv.visitLdcInsn(index);/*from w  w w  . jav  a 2  s .co m*/

    int _typeLength = 1;
    switch (argType.getSort()) {
    case Type.BOOLEAN:
    case Type.BYTE:
    case Type.CHAR:
    case Type.INT:
    case Type.SHORT:
        mv.visitVarInsn(Opcodes.ILOAD, index);
        break;
    case Type.LONG:
        mv.visitVarInsn(Opcodes.LLOAD, index);
        _typeLength++;
        break;
    case Type.FLOAT:
        mv.visitVarInsn(Opcodes.FLOAD, index);
        break;
    case Type.DOUBLE:
        mv.visitVarInsn(Opcodes.DLOAD, index);
        _typeLength++;
        break;
    case Type.ARRAY:
    case Type.OBJECT:
        mv.visitVarInsn(Opcodes.ALOAD, index);
        break;
    }

    emitConvertToString(mv, argType);
    emitInvokeLog(mv, LOG_ARGUMENT);

    return _typeLength;
}