annotate graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java @ 14827:2ed3233503b8

Starting point of the baseline bytecode parser
author Niclas Adlertz <niclas.adlertz@oracle.com>
date Thu, 20 Mar 2014 18:09:41 +0000
parents 17a735726670
children 2b17b6c55880
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 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
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.*;
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 8485
diff changeset
26 import static com.oracle.graal.phases.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.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
33 import com.oracle.graal.debug.*;
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
34 import com.oracle.graal.debug.Debug.Scope;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
35 import com.oracle.graal.nodes.*;
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
36 import com.oracle.graal.nodes.cfg.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
39 * 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
40 * (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
41 * headers and connects them.
7521
d4bc143c575a replaced use of <br> in javadoc with <p>
Doug Simon <doug.simon@oracle.com>
parents: 7096
diff changeset
42 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
43 * 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
44 * 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
45 * 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
46 * 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
47 * 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
48 * 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
49 * list).
7521
d4bc143c575a replaced use of <br> in javadoc with <p>
Doug Simon <doug.simon@oracle.com>
parents: 7096
diff changeset
50 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
51 * 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
52 * 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
53 * 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
54 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
55 * 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
56 * 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
57 * 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
58 * matter.
7521
d4bc143c575a replaced use of <br> in javadoc with <p>
Doug Simon <doug.simon@oracle.com>
parents: 7096
diff changeset
59 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
60 * 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
61 * 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
62 * 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
63 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
64 * 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
65 * 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
66 * 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
67 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
68 * 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
69 * 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
70 * 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
71 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
72 * 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
73 * profiling information.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74 */
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4423
diff changeset
75 public final class BciBlockMapping {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
77 public static class BciBlock implements Cloneable, AbstractBlock<BciBlock> {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
78
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 public int startBci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 public int endBci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81 public boolean isExceptionEntry;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 public boolean isLoopHeader;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
83 public int loopId;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84 public int blockID;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 public FixedWithNextNode firstInstruction;
14792
b9805a622546 Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14066
diff changeset
87 public HIRFrameStateBuilder entryState;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
89 public ArrayList<BciBlock> successors = new ArrayList<>(2);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
90 public long exits;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
91
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
92 private boolean visited;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93 private boolean active;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94 public long loops;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
96 public HashMap<JsrScope, BciBlock> jsrAlternatives;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 public JsrScope jsrScope = JsrScope.EMPTY_SCOPE;
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
98 public BciBlock jsrSuccessor;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
99 public int jsrReturnBci;
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
100 public BciBlock retSuccessor;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
101 public boolean endsWithRet = false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
103 public BciBlock exceptionDispatchBlock() {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
104 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
105 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
106 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
107 return null;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
108 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
109
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
110 public int numNormalSuccessors() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
111 if (exceptionDispatchBlock() != null) {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
112 return successors.size() - 1;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
113 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
114 return successors.size();
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
115 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
116
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
117 public BciBlock copy() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118 try {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
119 BciBlock block = (BciBlock) super.clone();
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
120 block.successors = new ArrayList<>(successors);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 return block;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 } catch (CloneNotSupportedException e) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 throw new RuntimeException(e);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125 }
4614
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
126
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
127 @Override
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
128 public String toString() {
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
129 StringBuilder sb = new StringBuilder("B").append(blockID);
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
130 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
131 if (isLoopHeader || isExceptionEntry) {
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
132 sb.append(' ');
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
133 if (isLoopHeader) {
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
134 sb.append('L');
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
135 }
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
136 if (isExceptionEntry) {
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
137 sb.append('!');
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
138 }
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
139 }
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
140 sb.append(']');
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
141 return sb.toString();
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4552
diff changeset
142 }
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
143
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
144 public int getId() {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
145 return blockID;
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
146 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
147
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
148 public Loop getLoop() {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
149 // TODO Auto-generated method stub
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
150 return null;
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
151 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
152
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
153 public int getLoopDepth() {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
154 // TODO Auto-generated method stub
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
155 return 0;
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
156 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
157
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
158 public boolean isLoopHeader() {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
159 return isLoopHeader;
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
160 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
161
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
162 public boolean isLoopEnd() {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
163 // TODO Auto-generated method stub
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
164 return false;
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
165 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
166
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
167 public boolean isExceptionEntry() {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
168 // TODO Auto-generated method stub
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
169 return false;
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
170 }
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 public List<BciBlock> getPredecessors() {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
173 // TODO Auto-generated method stub
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
174 return null;
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
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
177 public int getPredecessorCount() {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
178 // TODO Auto-generated method stub
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
179 return 0;
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
180 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
181
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
182 public List<BciBlock> getSuccessors() {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
183 // TODO Auto-generated method stub
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
184 return null;
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
185 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
186
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
187 public int getSuccessorCount() {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
188 // TODO Auto-generated method stub
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
189 return 0;
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
190 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
191
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
192 public int getLinearScanNumber() {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
193 // TODO Auto-generated method stub
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
194 return 0;
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
195 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
196
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
197 public void setLinearScanNumber(int linearScanNumber) {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
198 // TODO Auto-generated method stub
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
199
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
200 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
201
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
202 public boolean isAligned() {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
203 // TODO Auto-generated method stub
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
204 return false;
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
205 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
206
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
207 public void setAlign(boolean align) {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
208 // TODO Auto-generated method stub
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
209
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
210 }
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
211
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
212 public BciBlock getDominator() {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
213 // TODO Auto-generated method stub
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
214 return null;
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
215 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
217
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
218 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
219
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
220 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
221
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
222 public ExceptionHandler handler;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223 public int deoptBci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
224 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
225
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
226 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
227 * 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
228 */
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
229 public final List<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
230 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
231 public boolean hasJsrBytecodes;
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
232 public BciBlock startBlock;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
233
5109
6766253384bf more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5108
diff changeset
234 private final BytecodeStream stream;
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
235 private final ExceptionHandler[] exceptionHandlers;
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
236 private BciBlock[] blockMap;
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
237 public BciBlock[] loopHeaders;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
239 public LocalLiveness liveness;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
240
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 * Creates a new BlockMap instance from bytecode of the given method .
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
243 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
244 * @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
245 */
14066
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
246 private BciBlockMapping(ResolvedJavaMethod method) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
247 this.method = method;
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
248 exceptionHandlers = method.getExceptionHandlers();
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
249 stream = new BytecodeStream(method.getCode());
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
250 this.blockMap = new BciBlock[method.getCodeSize()];
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
251 this.blocks = new ArrayList<>();
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
252 this.loopHeaders = new BciBlock[64];
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
253 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
256 * 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
257 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
258 public void build() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
259 makeExceptionEntries();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260 iterateOverBytecodes();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
261 if (hasJsrBytecodes) {
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 8485
diff changeset
262 if (!SupportJsrBytecodes.getValue()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
263 throw new JsrNotSupportedBailout("jsr/ret parsing disabled");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
264 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
265 createJsrAlternatives(blockMap[0]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266 }
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
267 if (Debug.isLogEnabled()) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
268 this.log("Before BlockOrder");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
269 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
270 computeBlockOrder();
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
271 fixLoopBits();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
272
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
273 initializeBlockIds();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
274
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
275 startBlock = blockMap[0];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
276
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
277 assert verify();
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
278
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279 // Discard big arrays so that they can be GCed
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
280 blockMap = null;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
281 if (Debug.isLogEnabled()) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
282 this.log("Before LivenessAnalysis");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
283 }
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 8485
diff changeset
284 if (OptLivenessAnalysis.getValue()) {
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
285 try (Scope s = Debug.scope("LivenessAnalysis")) {
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
286 liveness = method.getMaxLocals() <= 64 ? new SmallLocalLiveness() : new LargeLocalLiveness();
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
287 liveness.computeLiveness();
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
288 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
289 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
290 }
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
291 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
292 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
293
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
294 private boolean verify() {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
295 for (BciBlock block : blocks) {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
296 assert blocks.get(block.blockID) == block;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
297
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
298 for (int i = 0; i < block.successors.size(); i++) {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
299 BciBlock sux = block.successors.get(i);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
300 if (sux instanceof ExceptionDispatchBlock) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
301 assert i == block.successors.size() - 1 : "Only one exception handler allowed, and it must be last in successors list";
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
302 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
303 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
304 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
305
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
306 return true;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
307 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
308
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
309 private void initializeBlockIds() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
310 for (int i = 0; i < blocks.size(); i++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
311 blocks.get(i).blockID = i;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
312 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
313 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
314
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
315 private void makeExceptionEntries() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
316 // 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
317 for (ExceptionHandler h : this.exceptionHandlers) {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
318 BciBlock xhandler = makeBlock(h.getHandlerBCI());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
319 xhandler.isExceptionEntry = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
320 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
321 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
322
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
323 private void iterateOverBytecodes() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
324 // iterate over the bytecodes top to bottom.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
325 // 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
326 // 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
327 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
328 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
329 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
330 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
331
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
332 if (current == null || blockMap[bci] != null) {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
333 BciBlock b = makeBlock(bci);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
334 if (current != null) {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
335 addSuccessor(current.endBci, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
336 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
337 current = b;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
338 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
339 blockMap[bci] = current;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
340 current.endBci = bci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
341
5031
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
342 switch (stream.currentBC()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
343 case IRETURN: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
344 case LRETURN: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
345 case FRETURN: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
346 case DRETURN: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
347 case ARETURN: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
348 case RETURN: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
349 current = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
350 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
351 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
352 case ATHROW: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
353 current = null;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
354 ExceptionDispatchBlock handler = handleExceptions(bci);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
355 if (handler != null) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
356 addSuccessor(bci, handler);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
357 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
358 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
359 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
360 case IFEQ: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
361 case IFNE: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
362 case IFLT: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
363 case IFGE: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
364 case IFGT: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
365 case IFLE: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
366 case IF_ICMPEQ: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
367 case IF_ICMPNE: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
368 case IF_ICMPLT: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
369 case IF_ICMPGE: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
370 case IF_ICMPGT: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
371 case IF_ICMPLE: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
372 case IF_ACMPEQ: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
373 case IF_ACMPNE: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
374 case IFNULL: // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
375 case IFNONNULL: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
376 current = null;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
377 addSuccessor(bci, makeBlock(stream.readBranchDest()));
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
378 addSuccessor(bci, makeBlock(stream.nextBCI()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
379 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
380 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
381 case GOTO:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
382 case GOTO_W: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
383 current = null;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
384 addSuccessor(bci, makeBlock(stream.readBranchDest()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
385 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
386 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
387 case TABLESWITCH: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
388 current = null;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
389 addSwitchSuccessors(bci, new BytecodeTableSwitch(stream, bci));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
390 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
392 case LOOKUPSWITCH: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
393 current = null;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
394 addSwitchSuccessors(bci, new BytecodeLookupSwitch(stream, bci));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
395 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
396 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
397 case JSR:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
398 case JSR_W: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399 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
400 int target = stream.readBranchDest();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
401 if (target == 0) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
402 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
403 }
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
404 BciBlock b1 = makeBlock(target);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
405 current.jsrSuccessor = b1;
5031
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
406 current.jsrReturnBci = stream.nextBCI();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
407 current = null;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
408 addSuccessor(bci, b1);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
409 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
410 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
411 case RET: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
412 current.endsWithRet = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
413 current = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
414 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
415 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
416 case INVOKEINTERFACE:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
417 case INVOKESPECIAL:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
418 case INVOKESTATIC:
7790
2c6d04c5e60f Enable invokedynamic and make bytecode known to Graal.
Andreas Woess <andreas.woess@jku.at>
parents: 7530
diff changeset
419 case INVOKEVIRTUAL:
2c6d04c5e60f Enable invokedynamic and make bytecode known to Graal.
Andreas Woess <andreas.woess@jku.at>
parents: 7530
diff changeset
420 case INVOKEDYNAMIC: {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
421 current = null;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
422 addSuccessor(bci, makeBlock(stream.nextBCI()));
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
423 ExceptionDispatchBlock handler = handleExceptions(bci);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
424 if (handler != null) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
425 addSuccessor(bci, handler);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
426 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
427 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
428 }
5031
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
429 case IASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
430 case LASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
431 case FASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
432 case DASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
433 case AASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
434 case BASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
435 case CASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
436 case SASTORE:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
437 case IALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
438 case LALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
439 case FALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
440 case DALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
441 case AALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
442 case BALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
443 case CALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
444 case SALOAD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
445 case PUTFIELD:
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
446 case GETFIELD: {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
447 ExceptionDispatchBlock handler = handleExceptions(bci);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
448 if (handler != null) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
449 current = null;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
450 addSuccessor(bci, makeBlock(stream.nextBCI()));
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
451 addSuccessor(bci, handler);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
452 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
453 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
454 }
5031
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
455 stream.next();
3733
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
458
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
459 private BciBlock makeBlock(int startBci) {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
460 BciBlock oldBlock = blockMap[startBci];
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
461 if (oldBlock == null) {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
462 BciBlock newBlock = new BciBlock();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
463 newBlock.startBci = startBci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
464 blockMap[startBci] = newBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
465 return newBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
466
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
467 } else if (oldBlock.startBci != startBci) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
468 // 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
469 // 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
470 BciBlock newBlock = new BciBlock();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
471 newBlock.startBci = startBci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
472 newBlock.endBci = oldBlock.endBci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
473 newBlock.successors.addAll(oldBlock.successors);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
474
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
475 oldBlock.endBci = startBci - 1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
476 oldBlock.successors.clear();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
477 oldBlock.successors.add(newBlock);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
478
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
479 for (int i = startBci; i <= newBlock.endBci; i++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
480 blockMap[i] = newBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
481 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
482 return newBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
483
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
484 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
485 return oldBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
486 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
487 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
488
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
489 private void addSwitchSuccessors(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
490 // 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
491 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
492 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
493 targets.add(bswitch.targetAt(i));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
494 }
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5568
diff changeset
495 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
496 for (int targetBci : targets) {
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5568
diff changeset
497 addSuccessor(predBci, makeBlock(targetBci));
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5568
diff changeset
498 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
499 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
500
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
501 private void addSuccessor(int predBci, BciBlock sux) {
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
502 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
503 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
504 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
505 }
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
506 predecessor.successors.add(sux);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
507 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
508
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
509 private final ArrayList<BciBlock> jsrVisited = new ArrayList<>();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
510
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
511 private void createJsrAlternatives(BciBlock block) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
512 jsrVisited.add(block);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
513 JsrScope scope = block.jsrScope;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
514
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
515 if (block.endsWithRet) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
516 block.retSuccessor = blockMap[scope.nextReturnAddress()];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
517 block.successors.add(block.retSuccessor);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
518 assert block.retSuccessor != block.jsrSuccessor;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
519 }
5035
44d746dc51bf Fix performance regression: remove unnecessary restriction of JSR parsing
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5031
diff changeset
520 Debug.log("JSR alternatives block %s sux %s jsrSux %s retSux %s jsrScope %s", block, block.successors, block.jsrSuccessor, block.retSuccessor, block.jsrScope);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
521
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
522 if (block.jsrSuccessor != null || !scope.isEmpty()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
523 for (int i = 0; i < block.successors.size(); i++) {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
524 BciBlock successor = block.successors.get(i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
525 JsrScope nextScope = scope;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
526 if (successor == block.jsrSuccessor) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
527 nextScope = scope.push(block.jsrReturnBci);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
528 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
529 if (successor == block.retSuccessor) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
530 nextScope = scope.pop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
531 }
5035
44d746dc51bf Fix performance regression: remove unnecessary restriction of JSR parsing
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5031
diff changeset
532 if (!successor.jsrScope.isPrefixOf(nextScope)) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
533 throw new JsrNotSupportedBailout("unstructured control flow (" + successor.jsrScope + " " + nextScope + ")");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
534 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
535 if (!nextScope.isEmpty()) {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
536 BciBlock clone;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
537 if (successor.jsrAlternatives != null && successor.jsrAlternatives.containsKey(nextScope)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
538 clone = successor.jsrAlternatives.get(nextScope);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
539 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
540 if (successor.jsrAlternatives == null) {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
541 successor.jsrAlternatives = new HashMap<>();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
542 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
543 clone = successor.copy();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
544 clone.jsrScope = nextScope;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
545 successor.jsrAlternatives.put(nextScope, clone);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
546 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
547 block.successors.set(i, clone);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
548 if (successor == block.jsrSuccessor) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
549 block.jsrSuccessor = clone;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
550 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
551 if (successor == block.retSuccessor) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
552 block.retSuccessor = clone;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
553 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
554 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
555 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
556 }
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
557 for (BciBlock successor : block.successors) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
558 if (!jsrVisited.contains(successor)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
559 createJsrAlternatives(successor);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
560 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
561 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
562 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
563
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
564 private HashMap<ExceptionHandler, ExceptionDispatchBlock> initialExceptionDispatch = new HashMap<>();
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
565
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
566 private ExceptionDispatchBlock handleExceptions(int bci) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
567 ExceptionDispatchBlock lastHandler = null;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
568
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
569 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
570 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
571 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
572 if (h.isCatchAll()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
573 // 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
574 // never be reached.
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
575 lastHandler = null;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
576 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
577
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
578 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
579 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
580 if (curHandler == null) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
581 curHandler = new ExceptionDispatchBlock();
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
582 curHandler.startBci = -1;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
583 curHandler.endBci = -1;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
584 curHandler.deoptBci = bci;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
585 curHandler.handler = h;
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
586 curHandler.successors.add(blockMap[h.getHandlerBCI()]);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
587 if (lastHandler != null) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
588 curHandler.successors.add(lastHandler);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
589 }
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
590 exceptionDispatch.put(h, curHandler);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
591 }
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
592 lastHandler = curHandler;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
593 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
594 }
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
595 return lastHandler;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
596 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
597
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
598 private boolean loopChanges;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
599
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
600 private void fixLoopBits() {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
601 do {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
602 loopChanges = false;
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
603 for (BciBlock b : blocks) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
604 b.visited = false;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
605 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
606
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
607 long loop = fixLoopBits(blockMap[0]);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
608
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
609 if (loop != 0) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
610 // 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
611 // header.
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
612 // 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
613 // 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
614 // 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
615 throw new BailoutException("Non-reducible loop: %016x", loop);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
616 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
617 } while (loopChanges);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
618 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
619
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
620 private void computeBlockOrder() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
621 long loop = computeBlockOrder(blockMap[0]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
622
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
623 if (loop != 0) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
624 // 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
625 // header.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
626 // Therefore, the loop is non reducible (has more than one entry).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
627 // 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
628 throw new BailoutException("Non-reducible loop");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
629 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
630
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
631 // Convert postorder to the desired reverse postorder.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
632 Collections.reverse(blocks);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
633 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
634
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
635 public void log(String name) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
636 if (Debug.isLogEnabled()) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
637 String n = System.lineSeparator();
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
638 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
639 sb.append(n);
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
640 Iterable<BciBlock> it;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
641 if (blocks.isEmpty()) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
642 it = new HashSet<>(Arrays.asList(blockMap));
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
643 } else {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
644 it = blocks;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
645 }
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
646 for (BciBlock b : it) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
647 if (b == null) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
648 continue;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
649 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
650 sb.append("B").append(b.blockID).append(" (").append(b.startBci).append(" -> ").append(b.endBci).append(")");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
651 if (b.isLoopHeader) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
652 sb.append(" LoopHeader");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
653 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
654 if (b.isExceptionEntry) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
655 sb.append(" ExceptionEntry");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
656 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
657 sb.append(n).append(" Sux : ");
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
658 for (BciBlock s : b.successors) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
659 sb.append("B").append(s.blockID).append(" (").append(s.startBci).append(" -> ").append(s.endBci).append(")");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
660 if (s.isExceptionEntry) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
661 sb.append("!");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
662 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
663 sb.append(" ");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
664 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
665 sb.append(n).append(" Loop : ");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
666 long l = b.loops;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
667 int pos = 0;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
668 while (l != 0) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
669 int lMask = 1 << pos;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
670 if ((l & lMask) != 0) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
671 sb.append("B").append(loopHeaders[pos].blockID).append(" ");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
672 l &= ~lMask;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
673 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
674 pos++;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
675 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
676 sb.append(n).append(" Exits : ");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
677 l = b.exits;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
678 pos = 0;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
679 while (l != 0) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
680 int lMask = 1 << pos;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
681 if ((l & lMask) != 0) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
682 sb.append("B").append(loopHeaders[pos].blockID).append(" ");
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
683 l &= ~lMask;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
684 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
685 pos++;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
686 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
687 sb.append(n);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
688 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
689 Debug.log(sb.toString());
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
690 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
691 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
692
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
693 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
694 * The next available loop number.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
695 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
696 private int nextLoop;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
697
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
698 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
699 * 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
700 * 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
701 */
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
702 private void makeLoopHeader(BciBlock block) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
703 if (!block.isLoopHeader) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
704 block.isLoopHeader = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
705
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
706 if (block.isExceptionEntry) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
707 // 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
708 // corner cases.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
709 // 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
710 // 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
711 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
712 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
713 if (nextLoop >= Long.SIZE) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
714 // 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
715 // more than 64 loops
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
716 // 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
717 // 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
718 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
719 }
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 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
722 block.loops = 1L << nextLoop;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
723 Debug.log("makeLoopHeader(%s) -> %x", block, block.loops);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
724 loopHeaders[nextLoop] = block;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
725 block.loopId = nextLoop;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
726 nextLoop++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
727 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
728 assert Long.bitCount(block.loops) == 1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
729 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
730
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
731 /**
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
732 * Depth-first traversal of the control flow graph. The flag {@linkplain BciBlock#visited} is used
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
733 * to visit every block only once. The flag {@linkplain BciBlock#active} is used to detect cycles
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
734 * (backward edges).
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
735 */
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
736 private long computeBlockOrder(BciBlock block) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
737 if (block.visited) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
738 if (block.active) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
739 // Reached block via backward branch.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
740 makeLoopHeader(block);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
741 // Return cached loop information for this block.
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
742 return block.loops;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
743 } else if (block.isLoopHeader) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
744 return block.loops & ~(1L << block.loopId);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
745 } else {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
746 return block.loops;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
747 }
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
750 block.visited = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
751 block.active = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
752
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
753 long loops = 0;
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
754 for (BciBlock successor : block.successors) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
755 // Recursively process successors.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
756 loops |= computeBlockOrder(successor);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
757 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
758
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
759 block.loops = loops;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
760 Debug.log("computeBlockOrder(%s) -> %x", block, block.loops);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
761
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
762 if (block.isLoopHeader) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
763 loops &= ~(1L << block.loopId);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
764 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
765
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
766 block.active = false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
767 blocks.add(block);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
768
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
769 return loops;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
770 }
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
771
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
772 private long fixLoopBits(BciBlock block) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
773 if (block.visited) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
774 // Return cached loop information for this block.
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
775 if (block.isLoopHeader) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
776 return block.loops & ~(1L << block.loopId);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
777 } else {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
778 return block.loops;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
779 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
780 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
781
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
782 block.visited = true;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
783 long loops = block.loops;
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
784 for (BciBlock successor : block.successors) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
785 // Recursively process successors.
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
786 loops |= fixLoopBits(successor);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
787 }
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
788 for (BciBlock successor : block.successors) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
789 successor.exits = loops & ~successor.loops;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
790 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
791 if (block.loops != loops) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
792 loopChanges = true;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
793 block.loops = loops;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
794 Debug.log("fixLoopBits0(%s) -> %x", block, block.loops);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
795 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
796
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
797 if (block.isLoopHeader) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
798 loops &= ~(1L << block.loopId);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
799 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
800
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
801 return loops;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5114
diff changeset
802 }
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
803
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
804 /**
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
805 * Encapsulates the liveness calculation, so that subclasses for locals <= 64 and locals > 64
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
806 * can be implemented.
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
807 */
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
808 public abstract class LocalLiveness {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
809
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
810 private void computeLiveness() {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
811 for (BciBlock block : blocks) {
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
812 computeLocalLiveness(block);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
813 }
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
814
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
815 boolean changed;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
816 int iteration = 0;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
817 do {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
818 Debug.log("Iteration %d", iteration);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
819 changed = false;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
820 for (int i = blocks.size() - 1; i >= 0; i--) {
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
821 BciBlock block = blocks.get(i);
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
822 int blockID = block.blockID;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
823 // log statements in IFs because debugLiveX creates a new String
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
824 if (Debug.isLogEnabled()) {
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14533
diff changeset
825 Debug.logv(" start B%d [%d, %d] in: %s out: %s gen: %s kill: %s", block.blockID, block.startBci, block.endBci, debugLiveIn(blockID), debugLiveOut(blockID),
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
826 debugLiveGen(blockID), debugLiveKill(blockID));
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
827 }
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
828
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
829 boolean blockChanged = (iteration == 0);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
830 if (block.successors.size() > 0) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
831 int oldCardinality = liveOutCardinality(blockID);
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
832 for (BciBlock sux : block.successors) {
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
833 if (Debug.isLogEnabled()) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
834 Debug.log(" Successor B%d: %s", sux.blockID, debugLiveIn(sux.blockID));
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
835 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
836 propagateLiveness(blockID, sux.blockID);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
837 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
838 blockChanged |= (oldCardinality != liveOutCardinality(blockID));
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
839 }
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
840
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
841 if (blockChanged) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
842 updateLiveness(blockID);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
843 if (Debug.isLogEnabled()) {
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14533
diff changeset
844 Debug.logv(" end B%d [%d, %d] in: %s out: %s gen: %s kill: %s", block.blockID, block.startBci, block.endBci, debugLiveIn(blockID), debugLiveOut(blockID),
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
845 debugLiveGen(blockID), debugLiveKill(blockID));
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
846 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
847 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
848 changed |= blockChanged;
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
849 }
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
850 iteration++;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
851 } while (changed);
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
852 }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
853
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
854 /**
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
855 * Returns whether the local is live at the beginning of the given block.
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
856 */
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
857 public abstract boolean localIsLiveIn(BciBlock block, int local);
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
858
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
859 /**
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
860 * Returns whether the local is live at the end of the given block.
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
861 */
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
862 public abstract boolean localIsLiveOut(BciBlock block, int local);
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
863
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
864 /**
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
865 * Returns a string representation of the liveIn values of the given block.
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
866 */
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
867 protected abstract String debugLiveIn(int blockID);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
868
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
869 /**
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
870 * Returns a string representation of the liveOut values of the given block.
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
871 */
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
872 protected abstract String debugLiveOut(int blockID);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
873
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
874 /**
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
875 * Returns a string representation of the liveGen values of the given block.
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
876 */
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
877 protected abstract String debugLiveGen(int blockID);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
878
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
879 /**
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
880 * Returns a string representation of the liveKill values of the given block.
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
881 */
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
882 protected abstract String debugLiveKill(int blockID);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
883
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
884 /**
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
885 * Returns the number of live locals at the end of the given block.
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
886 */
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
887 protected abstract int liveOutCardinality(int blockID);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
888
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
889 /**
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
890 * Adds all locals the are in the liveIn of the successor to the liveOut of the block.
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
891 */
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
892 protected abstract void propagateLiveness(int blockID, int successorID);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
893
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
894 /**
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
895 * Calculates a new liveIn for the given block from liveOut, liveKill and liveGen.
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
896 */
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
897 protected abstract void updateLiveness(int blockID);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
898
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
899 /**
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
900 * Adds the local to liveGen if it wasn't already killed in this block.
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
901 */
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
902 protected abstract void loadOne(int blockID, int local);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
903
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
904 /**
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
905 * Add this local to liveKill if it wasn't already generated in this block.
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
906 */
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
907 protected abstract void storeOne(int blockID, int local);
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
908
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
909 private void computeLocalLiveness(BciBlock block) {
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
910 if (block.startBci < 0 || block.endBci < 0) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
911 return;
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
912 }
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
913 int blockID = block.blockID;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
914 stream.setBCI(block.startBci);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
915 while (stream.currentBCI() <= block.endBci) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
916 switch (stream.currentBC()) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
917 case LLOAD:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
918 case DLOAD:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
919 loadTwo(blockID, stream.readLocalIndex());
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
920 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
921 case LLOAD_0:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
922 case DLOAD_0:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
923 loadTwo(blockID, 0);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
924 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
925 case LLOAD_1:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
926 case DLOAD_1:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
927 loadTwo(blockID, 1);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
928 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
929 case LLOAD_2:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
930 case DLOAD_2:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
931 loadTwo(blockID, 2);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
932 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
933 case LLOAD_3:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
934 case DLOAD_3:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
935 loadTwo(blockID, 3);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
936 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
937 case ILOAD:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
938 case IINC:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
939 case FLOAD:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
940 case ALOAD:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
941 case RET:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
942 loadOne(blockID, stream.readLocalIndex());
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
943 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
944 case ILOAD_0:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
945 case FLOAD_0:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
946 case ALOAD_0:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
947 loadOne(blockID, 0);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
948 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
949 case ILOAD_1:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
950 case FLOAD_1:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
951 case ALOAD_1:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
952 loadOne(blockID, 1);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
953 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
954 case ILOAD_2:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
955 case FLOAD_2:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
956 case ALOAD_2:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
957 loadOne(blockID, 2);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
958 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
959 case ILOAD_3:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
960 case FLOAD_3:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
961 case ALOAD_3:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
962 loadOne(blockID, 3);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
963 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
964
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
965 case LSTORE:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
966 case DSTORE:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
967 storeTwo(blockID, stream.readLocalIndex());
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
968 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
969 case LSTORE_0:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
970 case DSTORE_0:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
971 storeTwo(blockID, 0);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
972 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
973 case LSTORE_1:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
974 case DSTORE_1:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
975 storeTwo(blockID, 1);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
976 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
977 case LSTORE_2:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
978 case DSTORE_2:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
979 storeTwo(blockID, 2);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
980 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
981 case LSTORE_3:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
982 case DSTORE_3:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
983 storeTwo(blockID, 3);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
984 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
985 case ISTORE:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
986 case FSTORE:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
987 case ASTORE:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
988 storeOne(blockID, stream.readLocalIndex());
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
989 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
990 case ISTORE_0:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
991 case FSTORE_0:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
992 case ASTORE_0:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
993 storeOne(blockID, 0);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
994 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
995 case ISTORE_1:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
996 case FSTORE_1:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
997 case ASTORE_1:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
998 storeOne(blockID, 1);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
999 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1000 case ISTORE_2:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1001 case FSTORE_2:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1002 case ASTORE_2:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1003 storeOne(blockID, 2);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1004 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1005 case ISTORE_3:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1006 case FSTORE_3:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1007 case ASTORE_3:
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1008 storeOne(blockID, 3);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1009 break;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1010 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1011 stream.next();
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1012 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1013 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1014
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1015 private void loadTwo(int blockID, int local) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1016 loadOne(blockID, local);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1017 loadOne(blockID, local + 1);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1018 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1019
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1020 private void storeTwo(int blockID, int local) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1021 storeOne(blockID, local);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1022 storeOne(blockID, local + 1);
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
1023 }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
1024 }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
1025
14066
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
1026 public static BciBlockMapping create(ResolvedJavaMethod method) {
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
1027 BciBlockMapping map = new BciBlockMapping(method);
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
1028 map.build();
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
1029 if (Debug.isDumpEnabled()) {
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
1030 Debug.dump(map, MetaUtil.format("After block building %f %R %H.%n(%P)", method));
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
1031 }
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
1032
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
1033 return map;
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
1034 }
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13367
diff changeset
1035
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1036 public final class SmallLocalLiveness extends LocalLiveness {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1037 /*
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1038 * local n is represented by the bit accessible as (1 << n)
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1039 */
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1040
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1041 private final long[] localsLiveIn;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1042 private final long[] localsLiveOut;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1043 private final long[] localsLiveGen;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1044 private final long[] localsLiveKill;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1045
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1046 public SmallLocalLiveness() {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1047 localsLiveIn = new long[blocks.size()];
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1048 localsLiveOut = new long[blocks.size()];
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1049 localsLiveGen = new long[blocks.size()];
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1050 localsLiveKill = new long[blocks.size()];
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1051 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1052
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1053 private String debugString(long value) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1054 StringBuilder str = new StringBuilder("{");
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1055 long current = value;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1056 for (int i = 0; i < method.getMaxLocals(); i++) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1057 if ((current & 1L) == 1L) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1058 if (str.length() > 1) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1059 str.append(", ");
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1060 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1061 str.append(i);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1062 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1063 current >>= 1;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1064 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1065 return str.append('}').toString();
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1066 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1067
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1068 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1069 protected String debugLiveIn(int blockID) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1070 return debugString(localsLiveIn[blockID]);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1071 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1072
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1073 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1074 protected String debugLiveOut(int blockID) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1075 return debugString(localsLiveOut[blockID]);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1076 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1077
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1078 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1079 protected String debugLiveGen(int blockID) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1080 return debugString(localsLiveGen[blockID]);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1081 }
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
1082
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1083 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1084 protected String debugLiveKill(int blockID) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1085 return debugString(localsLiveKill[blockID]);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1086 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1087
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1088 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1089 protected int liveOutCardinality(int blockID) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1090 return Long.bitCount(localsLiveOut[blockID]);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1091 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1092
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1093 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1094 protected void propagateLiveness(int blockID, int successorID) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1095 localsLiveOut[blockID] |= localsLiveIn[successorID];
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1096 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1097
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1098 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1099 protected void updateLiveness(int blockID) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1100 localsLiveIn[blockID] = (localsLiveOut[blockID] & ~localsLiveKill[blockID]) | localsLiveGen[blockID];
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1101 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1102
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1103 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1104 protected void loadOne(int blockID, int local) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1105 long bit = 1L << local;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1106 if ((localsLiveKill[blockID] & bit) == 0L) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1107 localsLiveGen[blockID] |= bit;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1108 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1109 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1110
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1111 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1112 protected void storeOne(int blockID, int local) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1113 long bit = 1L << local;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1114 if ((localsLiveGen[blockID] & bit) == 0L) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1115 localsLiveKill[blockID] |= bit;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1116 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1117 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1118
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1119 @Override
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
1120 public boolean localIsLiveIn(BciBlock block, int local) {
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1121 int blockID = block.blockID;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1122 return blockID >= Integer.MAX_VALUE ? false : (localsLiveIn[blockID] & (1L << local)) != 0L;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1123 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1124
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1125 @Override
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
1126 public boolean localIsLiveOut(BciBlock block, int local) {
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1127 int blockID = block.blockID;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1128 return blockID >= Integer.MAX_VALUE ? false : (localsLiveOut[blockID] & (1L << local)) != 0L;
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
1129 }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
1130 }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
1131
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1132 public final class LargeLocalLiveness extends LocalLiveness {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1133 private BitSet[] localsLiveIn;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1134 private BitSet[] localsLiveOut;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1135 private BitSet[] localsLiveGen;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1136 private BitSet[] localsLiveKill;
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1137
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1138 public LargeLocalLiveness() {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1139 localsLiveIn = new BitSet[blocks.size()];
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1140 localsLiveOut = new BitSet[blocks.size()];
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1141 localsLiveGen = new BitSet[blocks.size()];
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1142 localsLiveKill = new BitSet[blocks.size()];
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1143 for (int i = 0; i < blocks.size(); i++) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1144 localsLiveIn[i] = new BitSet(method.getMaxLocals());
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1145 localsLiveOut[i] = new BitSet(method.getMaxLocals());
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1146 localsLiveGen[i] = new BitSet(method.getMaxLocals());
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1147 localsLiveKill[i] = new BitSet(method.getMaxLocals());
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1148 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1149 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1150
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1151 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1152 protected String debugLiveIn(int blockID) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1153 return localsLiveIn[blockID].toString();
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1154 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1155
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1156 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1157 protected String debugLiveOut(int blockID) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1158 return localsLiveOut[blockID].toString();
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1159 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1160
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1161 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1162 protected String debugLiveGen(int blockID) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1163 return localsLiveGen[blockID].toString();
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1164 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1165
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1166 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1167 protected String debugLiveKill(int blockID) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1168 return localsLiveKill[blockID].toString();
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1169 }
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
1170
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1171 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1172 protected int liveOutCardinality(int blockID) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1173 return localsLiveOut[blockID].cardinality();
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1174 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1175
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1176 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1177 protected void propagateLiveness(int blockID, int successorID) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1178 localsLiveOut[blockID].or(localsLiveIn[successorID]);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1179 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1180
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1181 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1182 protected void updateLiveness(int blockID) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1183 BitSet liveIn = localsLiveIn[blockID];
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1184 liveIn.clear();
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1185 liveIn.or(localsLiveOut[blockID]);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1186 liveIn.andNot(localsLiveKill[blockID]);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1187 liveIn.or(localsLiveGen[blockID]);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1188 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1189
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1190 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1191 protected void loadOne(int blockID, int local) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1192 if (!localsLiveKill[blockID].get(local)) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1193 localsLiveGen[blockID].set(local);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1194 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1195 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1196
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1197 @Override
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1198 protected void storeOne(int blockID, int local) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1199 if (!localsLiveGen[blockID].get(local)) {
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1200 localsLiveKill[blockID].set(local);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1201 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1202 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1203
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1204 @Override
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
1205 public boolean localIsLiveIn(BciBlock block, int local) {
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1206 return block.blockID >= Integer.MAX_VALUE ? true : localsLiveIn[block.blockID].get(local);
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1207 }
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1208
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1209 @Override
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
1210 public boolean localIsLiveOut(BciBlock block, int local) {
14533
e5235120893c split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14066
diff changeset
1211 return block.blockID >= Integer.MAX_VALUE ? true : localsLiveOut[block.blockID].get(local);
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
1212 }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4614
diff changeset
1213 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1214 }