annotate graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java @ 14906:f3a5036cc13c

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