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