jdk.internal.org.objectweb.asm.tree.TryCatchBlockNode Java Examples

The following examples show how to use jdk.internal.org.objectweb.asm.tree.TryCatchBlockNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JSRInlinerAdapter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #2
Source File: TryCatchBlockSorter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    // Updates the 'target' of each try catch block annotation.
    for (int i = 0; i < tryCatchBlocks.size(); ++i) {
        tryCatchBlocks.get(i).updateIndex(i);
    }
    if (mv != null) {
        accept(mv);
    }
}
 
Example #3
Source File: JSRInlinerAdapter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #4
Source File: TryCatchBlockSorter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    // Updates the 'target' of each try catch block annotation.
    for (int i = 0; i < tryCatchBlocks.size(); ++i) {
        tryCatchBlocks.get(i).updateIndex(i);
    }
    if (mv != null) {
        accept(mv);
    }
}
 
Example #5
Source File: JSRInlinerAdapter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: TryCatchBlockSorter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    // Updates the 'target' of each try catch block annotation.
    for (int i = 0; i < tryCatchBlocks.size(); ++i) {
        tryCatchBlocks.get(i).updateIndex(i);
    }
    if (mv != null) {
        accept(mv);
    }
}
 
Example #7
Source File: JSRInlinerAdapter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #8
Source File: JSRInlinerAdapter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #9
Source File: TryCatchBlockSorter.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    if (mv != null) {
        accept(mv);
    }
}
 
Example #10
Source File: TryCatchBlockSorter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    // Updates the 'target' of each try catch block annotation.
    for (int i = 0; i < tryCatchBlocks.size(); ++i) {
        tryCatchBlocks.get(i).updateIndex(i);
    }
    if (mv != null) {
        accept(mv);
    }
}
 
Example #11
Source File: JSRInlinerAdapter.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #12
Source File: JSRInlinerAdapter.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #13
Source File: TryCatchBlockSorter.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    // Updates the 'target' of each try catch block annotation.
    for (int i = 0; i < tryCatchBlocks.size(); ++i) {
        tryCatchBlocks.get(i).updateIndex(i);
    }
    if (mv != null) {
        accept(mv);
    }
}
 
Example #14
Source File: TryCatchBlockSorter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    // Updates the 'target' of each try catch block annotation.
    for (int i = 0; i < tryCatchBlocks.size(); ++i) {
        tryCatchBlocks.get(i).updateIndex(i);
    }
    if (mv != null) {
        accept(mv);
    }
}
 
Example #15
Source File: JSRInlinerAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #16
Source File: JSRInlinerAdapter.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #17
Source File: TryCatchBlockSorter.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    // Updates the 'target' of each try catch block annotation.
    for (int i = 0; i < tryCatchBlocks.size(); ++i) {
        tryCatchBlocks.get(i).updateIndex(i);
    }
    if (mv != null) {
        accept(mv);
    }
}
 
Example #18
Source File: JSRInlinerAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #19
Source File: JSRInlinerAdapter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #20
Source File: JSRInlinerAdapter.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
  * 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 main "subroutine", which is just the main routine.
    worklist.add(new Instantiation(null, mainSubroutineInsns));

    // 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 instantiation = worklist.removeFirst();
        emitInstantiation(
                instantiation, worklist, newInstructions, newTryCatchBlocks, newLocalVariables);
    }
    instructions = newInstructions;
    tryCatchBlocks = newTryCatchBlocks;
    localVariables = newLocalVariables;
}
 
Example #21
Source File: TryCatchBlockSorter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    // Updates the 'target' of each try catch block annotation.
    for (int i = 0; i < tryCatchBlocks.size(); ++i) {
        tryCatchBlocks.get(i).updateIndex(i);
    }
    if (mv != null) {
        accept(mv);
    }
}
 
Example #22
Source File: JSRInlinerAdapter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #23
Source File: TryCatchBlockSorter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    // Updates the 'target' of each try catch block annotation.
    for (int i = 0; i < tryCatchBlocks.size(); ++i) {
        tryCatchBlocks.get(i).updateIndex(i);
    }
    if (mv != null) {
        accept(mv);
    }
}
 
Example #24
Source File: TryCatchBlockSorter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    // Updates the 'target' of each try catch block annotation.
    for (int i = 0; i < tryCatchBlocks.size(); ++i) {
        tryCatchBlocks.get(i).updateIndex(i);
    }
    if (mv != null) {
        accept(mv);
    }
}
 
Example #25
Source File: JSRInlinerAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #26
Source File: JSRInlinerAdapter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #27
Source File: TryCatchBlockSorter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    // Updates the 'target' of each try catch block annotation.
    for (int i = 0; i < tryCatchBlocks.size(); ++i) {
        tryCatchBlocks.get(i).updateIndex(i);
    }
    if (mv != null) {
        accept(mv);
    }
}
 
Example #28
Source File: TryCatchBlockSorter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    // Updates the 'target' of each try catch block annotation.
    for (int i = 0; i < tryCatchBlocks.size(); ++i) {
        tryCatchBlocks.get(i).updateIndex(i);
    }
    if (mv != null) {
        accept(mv);
    }
}
 
Example #29
Source File: TryCatchBlockSorter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    // Compares TryCatchBlockNodes by the length of their "try" block.
    Comparator<TryCatchBlockNode> comp = new Comparator<TryCatchBlockNode>() {

        public int compare(TryCatchBlockNode t1, TryCatchBlockNode t2) {
            int len1 = blockLength(t1);
            int len2 = blockLength(t2);
            return len1 - len2;
        }

        private int blockLength(TryCatchBlockNode block) {
            int startidx = instructions.indexOf(block.start);
            int endidx = instructions.indexOf(block.end);
            return endidx - startidx;
        }
    };
    Collections.sort(tryCatchBlocks, comp);
    // Updates the 'target' of each try catch block annotation.
    for (int i = 0; i < tryCatchBlocks.size(); ++i) {
        tryCatchBlocks.get(i).updateIndex(i);
    }
    if (mv != null) {
        accept(mv);
    }
}
 
Example #30
Source File: JSRInlinerAdapter.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
  * Finds the instructions that belong to the subroutine starting at the given instruction index.
  * For this the control flow graph is visited with a depth first search (this includes the normal
  * control flow and the exception handlers).
  *
  * @param startInsnIndex the index of the first instruction of the subroutine.
  * @param subroutineInsns where the indices of the instructions of the subroutine must be stored.
  * @param visitedInsns the indices of the instructions that have been visited so far (including in
  *     previous calls to this method). This bitset is updated by this method each time a new
  *     instruction is visited. It is used to make sure each instruction is visited at most once.
  */
private void findSubroutineInsns(
        final int startInsnIndex, final BitSet subroutineInsns, final BitSet visitedInsns) {
    // First find the instructions reachable via normal execution.
    findReachableInsns(startInsnIndex, subroutineInsns, visitedInsns);

    // Then find the instructions reachable via the applicable exception handlers.
    while (true) {
        boolean applicableHandlerFound = false;
        for (TryCatchBlockNode tryCatchBlockNode : tryCatchBlocks) {
            // If the handler has already been processed, skip it.
            int handlerIndex = instructions.indexOf(tryCatchBlockNode.handler);
            if (subroutineInsns.get(handlerIndex)) {
                continue;
            }

            // If an instruction in the exception handler range belongs to the subroutine, the handler
            // can be reached from the routine, and its instructions must be added to the subroutine.
            int startIndex = instructions.indexOf(tryCatchBlockNode.start);
            int endIndex = instructions.indexOf(tryCatchBlockNode.end);
            int firstSubroutineInsnAfterTryCatchStart = subroutineInsns.nextSetBit(startIndex);
            if (firstSubroutineInsnAfterTryCatchStart >= startIndex
                    && firstSubroutineInsnAfterTryCatchStart < endIndex) {
                findReachableInsns(handlerIndex, subroutineInsns, visitedInsns);
                applicableHandlerFound = true;
            }
        }
        // If an applicable exception handler has been found, other handlers may become applicable, so
        // we must examine them again.
        if (!applicableHandlerFound) {
            return;
        }
    }
}