Search in sources :

Example 1 with InsnList

use of jdk.internal.org.objectweb.asm.tree.InsnList in project jdk8u_jdk by JetBrains.

the class JSRInlinerAdapter method emitCode.

/**
     * Creates the new instructions, inlining each instantiation of each
     * subroutine until the code is fully elaborated.
     */
private void emitCode() {
    LinkedList<Instantiation> worklist = new LinkedList<Instantiation>();
    // Create an instantiation of the "root" subroutine, which is just the
    // main routine
    worklist.add(new Instantiation(null, mainSubroutine));
    // Emit instantiations of each subroutine we encounter, including the
    // main subroutine
    InsnList newInstructions = new InsnList();
    List<TryCatchBlockNode> newTryCatchBlocks = new ArrayList<TryCatchBlockNode>();
    List<LocalVariableNode> newLocalVariables = new ArrayList<LocalVariableNode>();
    while (!worklist.isEmpty()) {
        Instantiation inst = worklist.removeFirst();
        emitSubroutine(inst, worklist, newInstructions, newTryCatchBlocks, newLocalVariables);
    }
    instructions = newInstructions;
    tryCatchBlocks = newTryCatchBlocks;
    localVariables = newLocalVariables;
}
Also used : TryCatchBlockNode(jdk.internal.org.objectweb.asm.tree.TryCatchBlockNode) ArrayList(java.util.ArrayList) InsnList(jdk.internal.org.objectweb.asm.tree.InsnList) LinkedList(java.util.LinkedList) LocalVariableNode(jdk.internal.org.objectweb.asm.tree.LocalVariableNode)

Example 2 with InsnList

use of jdk.internal.org.objectweb.asm.tree.InsnList in project Bytecoder by mirkosertic.

the class JSRInlinerAdapter method emitCode.

/**
 * Creates the new instructions, inlining each instantiation of each
 * subroutine until the code is fully elaborated.
 */
private void emitCode() {
    LinkedList<Instantiation> worklist = new LinkedList<Instantiation>();
    // Create an instantiation of the "root" subroutine, which is just the
    // main routine
    worklist.add(new Instantiation(null, mainSubroutine));
    // Emit instantiations of each subroutine we encounter, including the
    // main subroutine
    InsnList newInstructions = new InsnList();
    List<TryCatchBlockNode> newTryCatchBlocks = new ArrayList<TryCatchBlockNode>();
    List<LocalVariableNode> newLocalVariables = new ArrayList<LocalVariableNode>();
    while (!worklist.isEmpty()) {
        Instantiation inst = worklist.removeFirst();
        emitSubroutine(inst, worklist, newInstructions, newTryCatchBlocks, newLocalVariables);
    }
    instructions = newInstructions;
    tryCatchBlocks = newTryCatchBlocks;
    localVariables = newLocalVariables;
}
Also used : TryCatchBlockNode(jdk.internal.org.objectweb.asm.tree.TryCatchBlockNode) ArrayList(java.util.ArrayList) InsnList(jdk.internal.org.objectweb.asm.tree.InsnList) LinkedList(java.util.LinkedList) LocalVariableNode(jdk.internal.org.objectweb.asm.tree.LocalVariableNode)

Example 3 with InsnList

use of jdk.internal.org.objectweb.asm.tree.InsnList in project CorfuDB by CorfuDB.

the class Utils method printByteCode.

public static String printByteCode(byte[] bytes) {
    ClassReader cr = new ClassReader(bytes);
    ClassNode cn = new ClassNode();
    cr.accept(cn, 0);
    final List<MethodNode> methods = cn.methods;
    StringBuilder sb = new StringBuilder();
    for (MethodNode m : methods) {
        InsnList inList = m.instructions;
        sb.append(m.name);
        for (int i = 0; i < inList.size(); i++) {
            sb.append(insnToString(inList.get(i)));
        }
    }
    return sb.toString();
}
Also used : ClassNode(jdk.internal.org.objectweb.asm.tree.ClassNode) MethodNode(jdk.internal.org.objectweb.asm.tree.MethodNode) ClassReader(jdk.internal.org.objectweb.asm.ClassReader) InsnList(jdk.internal.org.objectweb.asm.tree.InsnList)

Aggregations

InsnList (jdk.internal.org.objectweb.asm.tree.InsnList)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 LocalVariableNode (jdk.internal.org.objectweb.asm.tree.LocalVariableNode)2 TryCatchBlockNode (jdk.internal.org.objectweb.asm.tree.TryCatchBlockNode)2 ClassReader (jdk.internal.org.objectweb.asm.ClassReader)1 ClassNode (jdk.internal.org.objectweb.asm.tree.ClassNode)1 MethodNode (jdk.internal.org.objectweb.asm.tree.MethodNode)1