annotate graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java @ 19493:45c90acd813e

Fix startBci for returnBlock and unwindBlock.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 18 Feb 2015 23:34:48 +0100
parents 82475095334f
children b1530a6cce8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
2 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.java;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
5568
fdf19fa15ce4 Split bytecode utilities into separate project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
25 import static com.oracle.graal.bytecode.Bytecodes.*;
15259
d90e5c22ba55 Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15192
diff changeset
26 import static com.oracle.graal.compiler.common.GraalOptions.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
30 import com.oracle.graal.api.code.*;
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5256
diff changeset
31 import com.oracle.graal.api.meta.*;
5568
fdf19fa15ce4 Split bytecode utilities into separate project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
32 import com.oracle.graal.bytecode.*;
18743
220d7f242e57 use deterministic iteration-order data structures
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
33 import com.oracle.graal.compiler.common.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
34 import com.oracle.graal.debug.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
37 * Builds a mapping between bytecodes and basic blocks and builds a conservative control flow graph
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
38 * (CFG). It makes one linear passes over the bytecodes to build the CFG where it detects block
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
39 * headers and connects them.
7521
d4bc143c575a replaced use of <br> in javadoc with <p>
Doug Simon <doug.simon@oracle.com>
parents: 7096
diff changeset
40 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
41 * It also creates exception dispatch blocks for exception handling. These blocks are between a
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
42 * bytecode that might throw an exception, and the actual exception handler entries, and are later
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
43 * used to create the type checks with the exception handler catch types. If a bytecode is covered
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
44 * by an exception handler, this bytecode ends the basic block. This guarantees that a) control flow
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
45 * cannot be transferred to an exception dispatch block in the middle of a block, and b) that every
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
46 * block has at most one exception dispatch block (which is always the last entry in the successor
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
47 * list).
7521
d4bc143c575a replaced use of <br> in javadoc with <p>
Doug Simon <doug.simon@oracle.com>
parents: 7096
diff changeset
48 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
49 * If a bytecode is covered by multiple exception handlers, a chain of exception dispatch blocks is
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
50 * created so that multiple exception handler types can be checked. The chains are re-used if
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
51 * multiple bytecodes are covered by the same exception handlers.
7521
d4bc143c575a replaced use of <br> in javadoc with <p>
Doug Simon <doug.simon@oracle.com>
parents: 7096
diff changeset
52 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
53 * Note that exception unwinds, i.e., bytecodes that can throw an exception but the exception is not
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
54 * handled in this method, do not end a basic block. Not modeling the exception unwind block reduces
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
55 * the complexity of the CFG, and there is no algorithm yet where the exception unwind block would
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
56 * matter.
7521
d4bc143c575a replaced use of <br> in javadoc with <p>
Doug Simon <doug.simon@oracle.com>
parents: 7096
diff changeset
57 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
58 * The class also handles subroutines (jsr and ret bytecodes): subroutines are inlined by
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
59 * duplicating the subroutine blocks. This is limited to simple, structured subroutines with a
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
60 * maximum subroutine nesting of 4. Otherwise, a bailout is thrown.
7521
d4bc143c575a replaced use of <br> in javadoc with <p>
Doug Simon <doug.simon@oracle.com>
parents: 7096
diff changeset
61 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
62 * Loops in the methods are detected. If a method contains an irreducible loop (a loop with more
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
63 * than one entry), a bailout is thrown. This simplifies the compiler later on since only structured
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
64 * loops need to be supported.
7521
d4bc143c575a replaced use of <br> in javadoc with <p>
Doug Simon <doug.simon@oracle.com>
parents: 7096
diff changeset
65 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
66 * A data flow analysis computes the live local variables from the point of view of the interpreter.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
67 * The result is used later to prune frame states, i.e., remove local variable entries that are
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
68 * guaranteed to be never used again (even in the case of deoptimization).
7521
d4bc143c575a replaced use of <br> in javadoc with <p>
Doug Simon <doug.simon@oracle.com>
parents: 7096
diff changeset
69 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
70 * The algorithms and analysis in this class are conservative and do not use any assumptions or
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
71 * profiling information.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 */
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4423
diff changeset
73 public final class BciBlockMapping {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74
19333
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
75 public static class BciBlock implements Cloneable {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
76
19333
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
77 protected int id;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 public int startBci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 public int endBci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 public boolean isExceptionEntry;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81 public boolean isLoopHeader;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
82 public int loopId;
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
83 public int loopEnd;
19333
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
84 protected List<BciBlock> successors;
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
85 private int predecessorCount;
15111
a775a766a3c8 Add more loop info to BciBlocks.
Josef Eisl <josef.eisl@jku.at>
parents: 15107
diff changeset
86
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87 private boolean visited;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88 private boolean active;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
89 public long loops;
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
90 public JSRData jsrData;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
91
18850
3a59e1411192 Make sure the JSRData is cloned when the BciBlock is cloned.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18831
diff changeset
92 public static class JSRData implements Cloneable {
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
93 public HashMap<JsrScope, BciBlock> jsrAlternatives;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
94 public JsrScope jsrScope = JsrScope.EMPTY_SCOPE;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
95 public BciBlock jsrSuccessor;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
96 public int jsrReturnBci;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
97 public BciBlock retSuccessor;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
98 public boolean endsWithRet = false;
18850
3a59e1411192 Make sure the JSRData is cloned when the BciBlock is cloned.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18831
diff changeset
99
3a59e1411192 Make sure the JSRData is cloned when the BciBlock is cloned.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18831
diff changeset
100 public JSRData copy() {
3a59e1411192 Make sure the JSRData is cloned when the BciBlock is cloned.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18831
diff changeset
101 try {
3a59e1411192 Make sure the JSRData is cloned when the BciBlock is cloned.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18831
diff changeset
102 return (JSRData) this.clone();
3a59e1411192 Make sure the JSRData is cloned when the BciBlock is cloned.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18831
diff changeset
103 } catch (CloneNotSupportedException e) {
3a59e1411192 Make sure the JSRData is cloned when the BciBlock is cloned.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18831
diff changeset
104 return null;
3a59e1411192 Make sure the JSRData is cloned when the BciBlock is cloned.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18831
diff changeset
105 }
3a59e1411192 Make sure the JSRData is cloned when the BciBlock is cloned.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18831
diff changeset
106 }
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
107 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
108
14829
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
109 public BciBlock() {
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
110 this.successors = new ArrayList<>(4);
14829
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
111 }
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
112
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
113 public BciBlock exceptionDispatchBlock() {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
114 if (successors.size() > 0 && successors.get(successors.size() - 1) instanceof ExceptionDispatchBlock) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
115 return successors.get(successors.size() - 1);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
116 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
117 return null;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
118 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
119
19333
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
120 public int getId() {
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
121 return id;
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
122 }
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
123
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
124 public int getPredecessorCount() {
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
125 return this.predecessorCount;
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
126 }
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
127
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
128 public int numNormalSuccessors() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
129 if (exceptionDispatchBlock() != null) {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
130 return successors.size() - 1;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
131 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
132 return successors.size();
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
133 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
134
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
135 public BciBlock copy() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 try {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
137 BciBlock block = (BciBlock) super.clone();
18850
3a59e1411192 Make sure the JSRData is cloned when the BciBlock is cloned.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18831
diff changeset
138 if (block.jsrData != null) {
3a59e1411192 Make sure the JSRData is cloned when the BciBlock is cloned.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18831
diff changeset
139 block.jsrData = block.jsrData.copy();
3a59e1411192 Make sure the JSRData is cloned when the BciBlock is cloned.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18831
diff changeset
140 }
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
141 block.successors = new ArrayList<>(successors);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
142 return block;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 } catch (CloneNotSupportedException e) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144 throw new RuntimeException(e);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
146 }
4614
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
147
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
148 @Override
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
149 public String toString() {
14832
4e784d4f5aea BciBlockMapping use AbstractBlockBase.id instead of blockID.
Josef Eisl <josef.eisl@jku.at>
parents: 14829
diff changeset
150 StringBuilder sb = new StringBuilder("B").append(getId());
4614
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
151 sb.append('[').append(startBci).append("->").append(endBci);
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
152 if (isLoopHeader || isExceptionEntry) {
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
153 sb.append(' ');
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
154 if (isLoopHeader) {
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
155 sb.append('L');
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
156 }
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
157 if (isExceptionEntry) {
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
158 sb.append('!');
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
159 }
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
160 }
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
161 sb.append(']');
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
162 return sb.toString();
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
163 }
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
164
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
165 public int getLoopDepth() {
15111
a775a766a3c8 Add more loop info to BciBlocks.
Josef Eisl <josef.eisl@jku.at>
parents: 15107
diff changeset
166 return Long.bitCount(loops);
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
167 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
168
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
169 public boolean isLoopHeader() {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
170 return isLoopHeader;
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
171 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
172
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
173 public boolean isExceptionEntry() {
15111
a775a766a3c8 Add more loop info to BciBlocks.
Josef Eisl <josef.eisl@jku.at>
parents: 15107
diff changeset
174 return isExceptionEntry;
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
175 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
176
14829
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
177 public BciBlock getSuccessor(int index) {
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
178 return successors.get(index);
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
179 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
180
15540
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
181 /**
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
182 * Get the loop id of the inner most loop.
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
183 *
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
184 * @return the loop id of the most inner loop or -1 if not part of any loop
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
185 */
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
186 public int getLoopId() {
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
187 long l = loops;
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
188 if (l == 0) {
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
189 return -1;
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
190 }
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
191 int pos = 0;
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
192 for (int lMask = 1; (l & lMask) == 0; lMask = lMask << 1) {
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
193 pos++;
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
194 }
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
195 return pos;
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
196 }
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
197
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
198 /**
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
199 * Iterate over loop ids.
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
200 */
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
201 public Iterable<Integer> loopIdIterable() {
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
202 return new Iterable<Integer>() {
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
203 public Iterator<Integer> iterator() {
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
204 return idIterator(loops);
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
205 }
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
206 };
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
207 }
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
208
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
209 private static Iterator<Integer> idIterator(long field) {
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
210 return new Iterator<Integer>() {
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
211
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
212 long l = field;
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
213 int pos = 0;
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
214 int lMask = 1;
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
215
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
216 public Integer next() {
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
217 for (; (l & lMask) == 0; lMask = lMask << 1) {
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
218 pos++;
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
219 }
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
220 l &= ~lMask;
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
221 return pos;
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
222 }
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
223
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
224 public boolean hasNext() {
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
225 return l != 0;
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
226 }
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
227 };
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
228
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
229 }
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
230
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
231 public double probability() {
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
232 return 1D;
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
233 }
16502
5f458fcc4f5a Move CFGVerifier to graal.compiler.common and make it abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 16480
diff changeset
234
5f458fcc4f5a Move CFGVerifier to graal.compiler.common and make it abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 16480
diff changeset
235 public BciBlock getPostdominator() {
5f458fcc4f5a Move CFGVerifier to graal.compiler.common and make it abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 16480
diff changeset
236 return null;
5f458fcc4f5a Move CFGVerifier to graal.compiler.common and make it abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 16480
diff changeset
237 }
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
238
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
239 private JSRData getOrCreateJSRData() {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
240 if (jsrData == null) {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
241 jsrData = new JSRData();
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
242 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
243 return jsrData;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
244 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
245
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
246 void setEndsWithRet() {
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
247 getOrCreateJSRData().endsWithRet = true;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
248 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
249
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
250 public JsrScope getJsrScope() {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
251 if (this.jsrData == null) {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
252 return JsrScope.EMPTY_SCOPE;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
253 } else {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
254 return jsrData.jsrScope;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
255 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
256 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
257
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
258 public boolean endsWithRet() {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
259 if (this.jsrData == null) {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
260 return false;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
261 } else {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
262 return jsrData.endsWithRet;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
263 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
264 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
265
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
266 void setRetSuccessor(BciBlock bciBlock) {
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
267 this.getOrCreateJSRData().retSuccessor = bciBlock;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
268 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
269
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
270 public BciBlock getRetSuccessor() {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
271 if (this.jsrData == null) {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
272 return null;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
273 } else {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
274 return jsrData.retSuccessor;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
275 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
276 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
277
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
278 public BciBlock getJsrSuccessor() {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
279 if (this.jsrData == null) {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
280 return null;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
281 } else {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
282 return jsrData.jsrSuccessor;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
283 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
284 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
285
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
286 public int getJsrReturnBci() {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
287 if (this.jsrData == null) {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
288 return -1;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
289 } else {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
290 return jsrData.jsrReturnBci;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
291 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
292 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
293
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
294 public HashMap<JsrScope, BciBlock> getJsrAlternatives() {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
295 if (this.jsrData == null) {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
296 return null;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
297 } else {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
298 return jsrData.jsrAlternatives;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
299 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
300 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
301
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
302 public void initJsrAlternatives() {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
303 JSRData data = this.getOrCreateJSRData();
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
304 if (data.jsrAlternatives == null) {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
305 data.jsrAlternatives = new HashMap<>();
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
306 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
307 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
308
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
309 void setJsrScope(JsrScope nextScope) {
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
310 this.getOrCreateJSRData().jsrScope = nextScope;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
311 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
312
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
313 void setJsrSuccessor(BciBlock clone) {
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
314 this.getOrCreateJSRData().jsrSuccessor = clone;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
315 }
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
316
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
317 void setJsrReturnBci(int bci) {
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
318 this.getOrCreateJSRData().jsrReturnBci = bci;
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
319 }
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
320
19333
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
321 public int getSuccessorCount() {
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
322 return successors.size();
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
323 }
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
324
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
325 public List<BciBlock> getSuccessors() {
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
326 return successors;
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
327 }
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
328
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
329 void setId(int i) {
19333
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
330 this.id = i;
ae87324c37d6 Do not extend AbstractBlockBase with BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
331 }
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
332
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
333 public void addSuccessor(BciBlock sux) {
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
334 successors.add(sux);
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
335 sux.predecessorCount++;
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
336 }
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
337
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
338 public void clearSucccessors() {
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
339 for (BciBlock sux : successors) {
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
340 sux.predecessorCount--;
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
341 }
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
342 successors.clear();
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
343 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
344 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
345
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
346 public static class ExceptionDispatchBlock extends BciBlock {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
347
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
348 private HashMap<ExceptionHandler, ExceptionDispatchBlock> exceptionDispatch = new HashMap<>();
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
349
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
350 public ExceptionHandler handler;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
351 public int deoptBci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
352 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
353
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
354 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
355 * The blocks found in this method, in reverse postorder.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
356 */
18820
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
357 private BciBlock[] blocks;
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
358 public final ResolvedJavaMethod method;
5109
6766253384bf more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5108
diff changeset
359 public boolean hasJsrBytecodes;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
360
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
361 private final ExceptionHandler[] exceptionHandlers;
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
362 private BciBlock startBlock;
18817
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18743
diff changeset
363 private BciBlock[] loopHeaders;
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18743
diff changeset
364
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18743
diff changeset
365 private static final int LOOP_HEADER_MAX_CAPACITY = Long.SIZE;
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18743
diff changeset
366 private static final int LOOP_HEADER_INITIAL_CAPACITY = 4;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
367
18820
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
368 private int blocksNotYetAssignedId;
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
369 public int returnCount;
19493
45c90acd813e Fix startBci for returnBlock and unwindBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19485
diff changeset
370 private int returnBci;
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
371
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
372 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
373 * Creates a new BlockMap instance from bytecode of the given method .
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14857
diff changeset
374 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
375 * @param method the compiler interface method containing the code
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
376 */
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
377 private BciBlockMapping(ResolvedJavaMethod method) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
378 this.method = method;
18817
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18743
diff changeset
379 this.exceptionHandlers = method.getExceptionHandlers();
18820
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
380 }
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
381
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
382 public BciBlock[] getBlocks() {
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
383 return this.blocks;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
384 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
385
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
386 public int getReturnCount() {
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
387 return this.returnCount;
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
388 }
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
389
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
390 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391 * Builds the block map and conservative CFG and numbers blocks.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
392 */
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
393 public void build(BytecodeStream stream) {
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
394 int codeSize = method.getCodeSize();
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
395 BciBlock[] blockMap = new BciBlock[codeSize];
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
396 makeExceptionEntries(blockMap);
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
397 iterateOverBytecodes(blockMap, stream);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
398 if (hasJsrBytecodes) {
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 8485
diff changeset
399 if (!SupportJsrBytecodes.getValue()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
400 throw new JsrNotSupportedBailout("jsr/ret parsing disabled");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
401 }
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
402 createJsrAlternatives(blockMap, blockMap[0]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
403 }
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
404 if (Debug.isLogEnabled()) {
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
405 this.log(blockMap, "Before BlockOrder");
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
406 }
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
407 computeBlockOrder(blockMap);
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
408 fixLoopBits(blockMap);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
409
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
410 assert verify();
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
411
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
412 startBlock = blockMap[0];
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
413 if (Debug.isLogEnabled()) {
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
414 this.log(blockMap, "Before LivenessAnalysis");
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
415 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
416 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
417
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
418 private boolean verify() {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
419 for (BciBlock block : blocks) {
18820
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
420 assert blocks[block.getId()] == block;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
421
14829
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
422 for (int i = 0; i < block.getSuccessorCount(); i++) {
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
423 BciBlock sux = block.getSuccessor(i);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
424 if (sux instanceof ExceptionDispatchBlock) {
14829
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
425 assert i == block.getSuccessorCount() - 1 : "Only one exception handler allowed, and it must be last in successors list";
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
426 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
427 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
428 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
429
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
430 return true;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
431 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
432
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
433 private void makeExceptionEntries(BciBlock[] blockMap) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
434 // start basic blocks at all exception handler blocks and mark them as exception entries
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
435 for (ExceptionHandler h : this.exceptionHandlers) {
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
436 BciBlock xhandler = makeBlock(blockMap, h.getHandlerBCI());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
437 xhandler.isExceptionEntry = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
438 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
439 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
440
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
441 private void iterateOverBytecodes(BciBlock[] blockMap, BytecodeStream stream) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
442 // iterate over the bytecodes top to bottom.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
443 // mark the entrypoints of basic blocks and build lists of successors for
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
444 // all bytecodes that end basic blocks (i.e. goto, ifs, switches, throw, jsr, returns, ret)
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
445 BciBlock current = null;
5031
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
446 stream.setBCI(0);
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
447 while (stream.currentBC() != Bytecodes.END) {
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
448 int bci = stream.currentBCI();
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
449
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
450 if (current == null || blockMap[bci] != null) {
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
451 BciBlock b = makeBlock(blockMap, bci);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
452 if (current != null) {
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
453 addSuccessor(blockMap, current.endBci, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
454 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
455 current = b;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
456 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
457 blockMap[bci] = current;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
458 current.endBci = bci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
459
5031
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
460 switch (stream.currentBC()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
461 case IRETURN: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
462 case LRETURN: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
463 case FRETURN: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
464 case DRETURN: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
465 case ARETURN: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
466 case RETURN: {
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
467 returnCount++;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
468 current = null;
19493
45c90acd813e Fix startBci for returnBlock and unwindBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19485
diff changeset
469 returnBci = bci;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
470 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
471 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
472 case ATHROW: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
473 current = null;
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
474 ExceptionDispatchBlock handler = handleExceptions(blockMap, bci);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
475 if (handler != null) {
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
476 addSuccessor(blockMap, bci, handler);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
477 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
478 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
479 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
480 case IFEQ: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
481 case IFNE: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
482 case IFLT: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
483 case IFGE: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
484 case IFGT: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
485 case IFLE: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
486 case IF_ICMPEQ: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
487 case IF_ICMPNE: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
488 case IF_ICMPLT: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
489 case IF_ICMPGE: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
490 case IF_ICMPGT: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
491 case IF_ICMPLE: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
492 case IF_ACMPEQ: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
493 case IF_ACMPNE: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
494 case IFNULL: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
495 case IFNONNULL: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
496 current = null;
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
497 addSuccessor(blockMap, bci, makeBlock(blockMap, stream.readBranchDest()));
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
498 addSuccessor(blockMap, bci, makeBlock(blockMap, stream.nextBCI()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
499 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
500 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
501 case GOTO:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
502 case GOTO_W: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
503 current = null;
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
504 addSuccessor(blockMap, bci, makeBlock(blockMap, stream.readBranchDest()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
505 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
506 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
507 case TABLESWITCH: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
508 current = null;
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
509 addSwitchSuccessors(blockMap, bci, new BytecodeTableSwitch(stream, bci));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
510 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
511 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
512 case LOOKUPSWITCH: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
513 current = null;
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
514 addSwitchSuccessors(blockMap, bci, new BytecodeLookupSwitch(stream, bci));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
515 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
516 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
517 case JSR:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
518 case JSR_W: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
519 hasJsrBytecodes = true;
5031
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
520 int target = stream.readBranchDest();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
521 if (target == 0) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
522 throw new JsrNotSupportedBailout("jsr target bci 0 not allowed");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
523 }
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
524 BciBlock b1 = makeBlock(blockMap, target);
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
525 current.setJsrSuccessor(b1);
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
526 current.setJsrReturnBci(stream.nextBCI());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
527 current = null;
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
528 addSuccessor(blockMap, bci, b1);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
529 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
530 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
531 case RET: {
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
532 current.setEndsWithRet();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
533 current = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
534 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
535 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
536 case INVOKEINTERFACE:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
537 case INVOKESPECIAL:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
538 case INVOKESTATIC:
7790
2c6d04c5e60f Enable invokedynamic and make bytecode known to Graal.
Andreas Woess <andreas.woess@jku.at>
parents: 7530
diff changeset
539 case INVOKEVIRTUAL:
2c6d04c5e60f Enable invokedynamic and make bytecode known to Graal.
Andreas Woess <andreas.woess@jku.at>
parents: 7530
diff changeset
540 case INVOKEDYNAMIC: {
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
541 ExceptionDispatchBlock handler = handleExceptions(blockMap, bci);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
542 if (handler != null) {
18831
c142633a6304 Fix regression in graph builder related to removal of placeholder nodes. Do not create successor blocks for invokes without exception handler successor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18827
diff changeset
543 current = null;
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
544 addSuccessor(blockMap, bci, makeBlock(blockMap, stream.nextBCI()));
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
545 addSuccessor(blockMap, bci, handler);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
546 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
547 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
548 }
5031
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
549 case IASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
550 case LASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
551 case FASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
552 case DASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
553 case AASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
554 case BASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
555 case CASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
556 case SASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
557 case IALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
558 case LALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
559 case FALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
560 case DALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
561 case AALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
562 case BALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
563 case CALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
564 case SALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
565 case PUTFIELD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
566 case GETFIELD: {
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
567 ExceptionDispatchBlock handler = handleExceptions(blockMap, bci);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
568 if (handler != null) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
569 current = null;
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
570 addSuccessor(blockMap, bci, makeBlock(blockMap, stream.nextBCI()));
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
571 addSuccessor(blockMap, bci, handler);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
572 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
573 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
574 }
5031
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
575 stream.next();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
576 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
577 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
578
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
579 private BciBlock makeBlock(BciBlock[] blockMap, int startBci) {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
580 BciBlock oldBlock = blockMap[startBci];
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
581 if (oldBlock == null) {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
582 BciBlock newBlock = new BciBlock();
18820
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
583 blocksNotYetAssignedId++;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
584 newBlock.startBci = startBci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
585 blockMap[startBci] = newBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
586 return newBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
587
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
588 } else if (oldBlock.startBci != startBci) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
589 // Backward branch into the middle of an already processed block.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
590 // Add the correct fall-through successor.
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
591 BciBlock newBlock = new BciBlock();
18820
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
592 blocksNotYetAssignedId++;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
593 newBlock.startBci = startBci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
594 newBlock.endBci = oldBlock.endBci;
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
595 for (BciBlock oldSuccessor : oldBlock.getSuccessors()) {
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
596 newBlock.addSuccessor(oldSuccessor);
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
597 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
598
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
599 oldBlock.endBci = startBci - 1;
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
600 oldBlock.clearSucccessors();
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
601 oldBlock.addSuccessor(newBlock);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
602
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
603 for (int i = startBci; i <= newBlock.endBci; i++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
604 blockMap[i] = newBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
605 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
606 return newBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
607
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
608 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
609 return oldBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
610 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
611 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
612
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
613 private void addSwitchSuccessors(BciBlock[] blockMap, int predBci, BytecodeSwitch bswitch) {
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5568
diff changeset
614 // adds distinct targets to the successor list
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5568
diff changeset
615 Collection<Integer> targets = new TreeSet<>();
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
616 for (int i = 0; i < bswitch.numberOfCases(); i++) {
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5568
diff changeset
617 targets.add(bswitch.targetAt(i));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
618 }
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5568
diff changeset
619 targets.add(bswitch.defaultTarget());
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5568
diff changeset
620 for (int targetBci : targets) {
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
621 addSuccessor(blockMap, predBci, makeBlock(blockMap, targetBci));
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5568
diff changeset
622 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
623 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
624
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
625 private static void addSuccessor(BciBlock[] blockMap, int predBci, BciBlock sux) {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
626 BciBlock predecessor = blockMap[predBci];
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
627 if (sux.isExceptionEntry) {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
628 throw new BailoutException("Exception handler can be reached by both normal and exceptional control flow");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
629 }
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
630 predecessor.addSuccessor(sux);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
631 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
632
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
633 private final ArrayList<BciBlock> jsrVisited = new ArrayList<>();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
634
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
635 private void createJsrAlternatives(BciBlock[] blockMap, BciBlock block) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
636 jsrVisited.add(block);
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
637 JsrScope scope = block.getJsrScope();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
638
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
639 if (block.endsWithRet()) {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
640 block.setRetSuccessor(blockMap[scope.nextReturnAddress()]);
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
641 block.addSuccessor(block.getRetSuccessor());
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
642 assert block.getRetSuccessor() != block.getJsrSuccessor();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
643 }
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
644 Debug.log("JSR alternatives block %s sux %s jsrSux %s retSux %s jsrScope %s", block, block.getSuccessors(), block.getJsrSuccessor(), block.getRetSuccessor(), block.getJsrScope());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
645
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
646 if (block.getJsrSuccessor() != null || !scope.isEmpty()) {
14829
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
647 for (int i = 0; i < block.getSuccessorCount(); i++) {
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
648 BciBlock successor = block.getSuccessor(i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
649 JsrScope nextScope = scope;
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
650 if (successor == block.getJsrSuccessor()) {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
651 nextScope = scope.push(block.getJsrReturnBci());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
652 }
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
653 if (successor == block.getRetSuccessor()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
654 nextScope = scope.pop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
655 }
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
656 if (!successor.getJsrScope().isPrefixOf(nextScope)) {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
657 throw new JsrNotSupportedBailout("unstructured control flow (" + successor.getJsrScope() + " " + nextScope + ")");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
658 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
659 if (!nextScope.isEmpty()) {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
660 BciBlock clone;
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
661 if (successor.getJsrAlternatives() != null && successor.getJsrAlternatives().containsKey(nextScope)) {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
662 clone = successor.getJsrAlternatives().get(nextScope);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
663 } else {
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
664 successor.initJsrAlternatives();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
665 clone = successor.copy();
18826
00ec3ff518ce Fixed a regression in the new BciBlock order algorithm when compiling methods with JSR bytecode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18820
diff changeset
666 blocksNotYetAssignedId++;
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
667 clone.setJsrScope(nextScope);
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
668 successor.getJsrAlternatives().put(nextScope, clone);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
669 }
14829
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
670 block.getSuccessors().set(i, clone);
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
671 if (successor == block.getJsrSuccessor()) {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
672 block.setJsrSuccessor(clone);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
673 }
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
674 if (successor == block.getRetSuccessor()) {
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
675 block.setRetSuccessor(clone);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
676 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
677 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
678 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
679 }
14829
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
680 for (BciBlock successor : block.getSuccessors()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
681 if (!jsrVisited.contains(successor)) {
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
682 createJsrAlternatives(blockMap, successor);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
683 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
684 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
685 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
686
18743
220d7f242e57 use deterministic iteration-order data structures
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
687 private HashMap<ExceptionHandler, ExceptionDispatchBlock> initialExceptionDispatch = CollectionsFactory.newMap();
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
688
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
689 private ExceptionDispatchBlock handleExceptions(BciBlock[] blockMap, int bci) {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
690 ExceptionDispatchBlock lastHandler = null;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
691
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
692 for (int i = exceptionHandlers.length - 1; i >= 0; i--) {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
693 ExceptionHandler h = exceptionHandlers[i];
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
694 if (h.getStartBCI() <= bci && bci < h.getEndBCI()) {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
695 if (h.isCatchAll()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
696 // Discard all information about succeeding exception handlers, since they can
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
697 // never be reached.
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
698 lastHandler = null;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
699 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
700
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
701 HashMap<ExceptionHandler, ExceptionDispatchBlock> exceptionDispatch = lastHandler != null ? lastHandler.exceptionDispatch : initialExceptionDispatch;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
702 ExceptionDispatchBlock curHandler = exceptionDispatch.get(h);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
703 if (curHandler == null) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
704 curHandler = new ExceptionDispatchBlock();
18820
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
705 blocksNotYetAssignedId++;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
706 curHandler.startBci = -1;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
707 curHandler.endBci = -1;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
708 curHandler.deoptBci = bci;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
709 curHandler.handler = h;
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
710 curHandler.addSuccessor(blockMap[h.getHandlerBCI()]);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
711 if (lastHandler != null) {
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19333
diff changeset
712 curHandler.addSuccessor(lastHandler);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
713 }
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
714 exceptionDispatch.put(h, curHandler);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
715 }
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
716 lastHandler = curHandler;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
717 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
718 }
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
719 return lastHandler;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
720 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
721
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
722 private boolean loopChanges;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
723
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
724 private void fixLoopBits(BciBlock[] blockMap) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
725 do {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
726 loopChanges = false;
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
727 for (BciBlock b : blocks) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
728 b.visited = false;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
729 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
730
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
731 long loop = fixLoopBits(blockMap, blockMap[0]);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
732
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
733 if (loop != 0) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
734 // There is a path from a loop end to the method entry that does not pass the loop
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
735 // header.
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
736 // Therefore, the loop is non reducible (has more than one entry).
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
737 // We don't want to compile such methods because the IR only supports structured
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
738 // loops.
5767
5967805da8f5 fix bug in BciBlockMapping that leads to bailouts on methods with more than 32 loops
Lukas Stadler <lukas.stadler@jku.at>
parents: 5698
diff changeset
739 throw new BailoutException("Non-reducible loop: %016x", loop);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
740 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
741 } while (loopChanges);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
742 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
743
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
744 private void computeBlockOrder(BciBlock[] blockMap) {
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
745 int maxBlocks = blocksNotYetAssignedId;
18820
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
746 this.blocks = new BciBlock[blocksNotYetAssignedId];
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
747 long loop = computeBlockOrder(blockMap[0]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
748
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
749 if (loop != 0) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
750 // There is a path from a loop end to the method entry that does not pass the loop
18820
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
751 // header. Therefore, the loop is non reducible (has more than one entry).
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
752 // We don't want to compile such methods because the IR only supports structured loops.
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
753 throw new BailoutException("Non-reducible loop");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
754 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
755
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
756 // Purge null entries for unreached blocks and sort blocks such that loop bodies are always
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
757 // consecutively in the array.
19481
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
758 int blockCount = maxBlocks - blocksNotYetAssignedId + 2;
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
759 BciBlock[] newBlocks = new BciBlock[blockCount];
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
760 int next = 0;
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
761 for (int i = 0; i < blocks.length; ++i) {
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
762 BciBlock b = blocks[i];
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
763 if (b != null) {
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
764 b.setId(next);
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
765 newBlocks[next++] = b;
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
766 if (b.isLoopHeader) {
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
767 next = handleLoopHeader(newBlocks, next, i, b);
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
768 }
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
769 }
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
770 }
19481
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
771
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
772 // Add return block.
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
773 BciBlock returnBlock = new BciBlock();
19493
45c90acd813e Fix startBci for returnBlock and unwindBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19485
diff changeset
774 returnBlock.startBci = returnBci;
45c90acd813e Fix startBci for returnBlock and unwindBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19485
diff changeset
775 returnBlock.endBci = returnBci;
19481
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
776 returnBlock.setId(newBlocks.length - 2);
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
777 newBlocks[newBlocks.length - 2] = returnBlock;
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
778
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
779 // Add unwind block.
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
780 ExceptionDispatchBlock unwindBlock = new ExceptionDispatchBlock();
19493
45c90acd813e Fix startBci for returnBlock and unwindBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19485
diff changeset
781 unwindBlock.startBci = -1;
45c90acd813e Fix startBci for returnBlock and unwindBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19485
diff changeset
782 unwindBlock.endBci = -1;
19481
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
783 unwindBlock.deoptBci = method.isSynchronized() ? BytecodeFrame.UNWIND_BCI : BytecodeFrame.AFTER_EXCEPTION_BCI;
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
784 unwindBlock.setId(newBlocks.length - 1);
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
785 newBlocks[newBlocks.length - 1] = unwindBlock;
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
786
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
787 blocks = newBlocks;
18820
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
788 }
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
789
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
790 private int handleLoopHeader(BciBlock[] newBlocks, int nextStart, int i, BciBlock loopHeader) {
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
791 int next = nextStart;
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
792 int endOfLoop = nextStart - 1;
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
793 for (int j = i + 1; j < blocks.length; ++j) {
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
794 BciBlock other = blocks[j];
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
795 if (other != null && (other.loops & (1L << loopHeader.loopId)) != 0) {
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
796 other.setId(next);
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
797 endOfLoop = next;
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
798 newBlocks[next++] = other;
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
799 blocks[j] = null;
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
800 if (other.isLoopHeader) {
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
801 next = handleLoopHeader(newBlocks, next, j, other);
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
802 }
18820
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
803 }
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
804 }
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
805 loopHeader.loopEnd = endOfLoop;
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
806 return next;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
807 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
808
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
809 public void log(BciBlock[] blockMap, String name) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
810 if (Debug.isLogEnabled()) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
811 String n = System.lineSeparator();
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
812 StringBuilder sb = new StringBuilder(Debug.currentScope()).append("BlockMap ").append(name).append(" :");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
813 sb.append(n);
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
814 Iterable<BciBlock> it;
18820
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
815 if (blocks == null) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
816 it = new HashSet<>(Arrays.asList(blockMap));
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
817 } else {
18820
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
818 it = Arrays.asList(blocks);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
819 }
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
820 for (BciBlock b : it) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
821 if (b == null) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
822 continue;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
823 }
14832
4e784d4f5aea BciBlockMapping use AbstractBlockBase.id instead of blockID.
Josef Eisl <josef.eisl@jku.at>
parents: 14829
diff changeset
824 sb.append("B").append(b.getId()).append(" (").append(b.startBci).append(" -> ").append(b.endBci).append(")");
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
825 if (b.isLoopHeader) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
826 sb.append(" LoopHeader");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
827 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
828 if (b.isExceptionEntry) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
829 sb.append(" ExceptionEntry");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
830 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
831 sb.append(n).append(" Sux : ");
14829
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
832 for (BciBlock s : b.getSuccessors()) {
14832
4e784d4f5aea BciBlockMapping use AbstractBlockBase.id instead of blockID.
Josef Eisl <josef.eisl@jku.at>
parents: 14829
diff changeset
833 sb.append("B").append(s.getId()).append(" (").append(s.startBci).append(" -> ").append(s.endBci).append(")");
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
834 if (s.isExceptionEntry) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
835 sb.append("!");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
836 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
837 sb.append(" ");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
838 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
839 sb.append(n).append(" Loop : ");
15540
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
840 for (int pos : b.loopIdIterable()) {
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
841 sb.append("B").append(loopHeaders[pos].getId()).append(" ");
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
842 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
843 sb.append(n);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
844 }
14636
733e50d96f9b fixed usages of Debug.log()
Doug Simon <doug.simon@oracle.com>
parents: 14625
diff changeset
845 Debug.log("%s", sb);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
846 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
847 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
848
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
849 /**
15540
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
850 * Get the header block for a loop index.
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
851 */
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
852 public BciBlock getLoopHeader(int index) {
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
853 return loopHeaders[index];
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
854 }
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
855
57131f2e001c BciBlockMapping: make loop information more accessible.
Josef Eisl <josef.eisl@jku.at>
parents: 15539
diff changeset
856 /**
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
857 * The next available loop number.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
858 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
859 private int nextLoop;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
860
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
861 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
862 * Mark the block as a loop header, using the next available loop number. Also checks for corner
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
863 * cases that we don't want to compile.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
864 */
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
865 private void makeLoopHeader(BciBlock block) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
866 if (!block.isLoopHeader) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
867 block.isLoopHeader = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
868
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
869 if (block.isExceptionEntry) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
870 // Loops that are implicitly formed by an exception handler lead to all sorts of
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
871 // corner cases.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
872 // Don't compile such methods for now, until we see a concrete case that allows
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
873 // checking for correctness.
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
874 throw new BailoutException("Loop formed by an exception handler");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
875 }
18817
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18743
diff changeset
876 if (nextLoop >= LOOP_HEADER_MAX_CAPACITY) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
877 // This restriction can be removed by using a fall-back to a BitSet in case we have
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
878 // more than 64 loops
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
879 // Don't compile such methods for now, until we see a concrete case that allows
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
880 // checking for correctness.
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
881 throw new BailoutException("Too many loops in method");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
882 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
883
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
884 assert block.loops == 0;
5767
5967805da8f5 fix bug in BciBlockMapping that leads to bailouts on methods with more than 32 loops
Lukas Stadler <lukas.stadler@jku.at>
parents: 5698
diff changeset
885 block.loops = 1L << nextLoop;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
886 Debug.log("makeLoopHeader(%s) -> %x", block, block.loops);
18817
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18743
diff changeset
887 if (loopHeaders == null) {
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18743
diff changeset
888 loopHeaders = new BciBlock[LOOP_HEADER_INITIAL_CAPACITY];
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18743
diff changeset
889 } else if (nextLoop >= loopHeaders.length) {
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18743
diff changeset
890 loopHeaders = Arrays.copyOf(loopHeaders, LOOP_HEADER_MAX_CAPACITY);
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18743
diff changeset
891 }
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
892 loopHeaders[nextLoop] = block;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
893 block.loopId = nextLoop;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
894 nextLoop++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
895 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
896 assert Long.bitCount(block.loops) == 1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
897 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
898
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
899 /**
14828
2b17b6c55880 Added predecessors to BciBlock
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14827
diff changeset
900 * Depth-first traversal of the control flow graph. The flag {@linkplain BciBlock#visited} is
2b17b6c55880 Added predecessors to BciBlock
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14827
diff changeset
901 * used to visit every block only once. The flag {@linkplain BciBlock#active} is used to detect
2b17b6c55880 Added predecessors to BciBlock
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14827
diff changeset
902 * cycles (backward edges).
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
903 */
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
904 private long computeBlockOrder(BciBlock block) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
905 if (block.visited) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
906 if (block.active) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
907 // Reached block via backward branch.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
908 makeLoopHeader(block);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
909 // Return cached loop information for this block.
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
910 return block.loops;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
911 } else if (block.isLoopHeader) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
912 return block.loops & ~(1L << block.loopId);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
913 } else {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
914 return block.loops;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
915 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
916 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
917
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
918 block.visited = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
919 block.active = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
920
5767
5967805da8f5 fix bug in BciBlockMapping that leads to bailouts on methods with more than 32 loops
Lukas Stadler <lukas.stadler@jku.at>
parents: 5698
diff changeset
921 long loops = 0;
14829
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
922 for (BciBlock successor : block.getSuccessors()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
923 // Recursively process successors.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
924 loops |= computeBlockOrder(successor);
15923
d0c7bd38e700 computeBlockOrder: no need to check if block is active, since it's anyway
Bernhard Urban <bernhard.urban@jku.at>
parents: 15540
diff changeset
925 if (successor.active) {
15111
a775a766a3c8 Add more loop info to BciBlocks.
Josef Eisl <josef.eisl@jku.at>
parents: 15107
diff changeset
926 // Reached block via backward branch.
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18850
diff changeset
927 loops |= (1L << successor.loopId);
15111
a775a766a3c8 Add more loop info to BciBlocks.
Josef Eisl <josef.eisl@jku.at>
parents: 15107
diff changeset
928 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
929 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
930
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
931 block.loops = loops;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
932 Debug.log("computeBlockOrder(%s) -> %x", block, block.loops);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
933
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
934 if (block.isLoopHeader) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
935 loops &= ~(1L << block.loopId);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
936 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
937
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
938 block.active = false;
18820
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
939 blocksNotYetAssignedId--;
ade7699e160e Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18819
diff changeset
940 blocks[blocksNotYetAssignedId] = block;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
941
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
942 return loops;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
943 }
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
944
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
945 private long fixLoopBits(BciBlock[] blockMap, BciBlock block) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
946 if (block.visited) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
947 // Return cached loop information for this block.
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
948 if (block.isLoopHeader) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
949 return block.loops & ~(1L << block.loopId);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
950 } else {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
951 return block.loops;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
952 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
953 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
954
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
955 block.visited = true;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
956 long loops = block.loops;
14829
8f6f63e997ba BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14828
diff changeset
957 for (BciBlock successor : block.getSuccessors()) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
958 // Recursively process successors.
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
959 loops |= fixLoopBits(blockMap, successor);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
960 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
961 if (block.loops != loops) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
962 loopChanges = true;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
963 block.loops = loops;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
964 Debug.log("fixLoopBits0(%s) -> %x", block, block.loops);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
965 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
966
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
967 if (block.isLoopHeader) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
968 loops &= ~(1L << block.loopId);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
969 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
970
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
971 return loops;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
972 }
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
973
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
974 public static BciBlockMapping create(BytecodeStream stream, ResolvedJavaMethod method) {
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
975 BciBlockMapping map = new BciBlockMapping(method);
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
976 map.build(stream);
14066
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
977 if (Debug.isDumpEnabled()) {
16480
10c12d09a8d2 moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 15924
diff changeset
978 Debug.dump(map, method.format("After block building %f %R %H.%n(%P)"));
14066
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
979 }
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
980
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
981 return map;
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
982 }
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
983
18817
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18743
diff changeset
984 public BciBlock[] getLoopHeaders() {
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18743
diff changeset
985 return loopHeaders;
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18743
diff changeset
986 }
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
987
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
988 public BciBlock getStartBlock() {
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
989 return startBlock;
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
990 }
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
991
19481
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
992 public BciBlock getReturnBlock() {
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
993 return blocks[blocks.length - 2];
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
994 }
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
995
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
996 public ExceptionDispatchBlock getUnwindBlock() {
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
997 return (ExceptionDispatchBlock) blocks[blocks.length - 1];
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
998 }
b0ba6f39cb60 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19479
diff changeset
999
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1000 public int getLoopCount() {
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1001 return nextLoop;
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1002 }
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1003
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1004 public int getBlockCount() {
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1005 return blocks.length;
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1006 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1007 }