Mercurial > hg > truffle
annotate graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java @ 14817:80147dac0d6e
LIRFrameStateBuilder added
author | Niclas Adlertz <niclas.adlertz@oracle.com> |
---|---|
date | Tue, 18 Mar 2014 09:56:20 +0000 |
parents | c4219e527b83 |
children | 3d04915a55c6 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
9003
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8660
diff
changeset
|
2 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.java; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
8660
d47b52b0ff68
fixed discrepancy between a method's name and its semantics
Doug Simon <doug.simon@oracle.com>
parents:
8659
diff
changeset
|
25 import static com.oracle.graal.api.code.TypeCheckHints.*; |
11839
0e2cceed1caf
Temporarily move encodeDeoptActionAndReason to MetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11837
diff
changeset
|
26 import static com.oracle.graal.api.meta.DeoptimizationAction.*; |
8227
ce91d45f0b1b
uses static import to reduce noise
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
27 import static com.oracle.graal.api.meta.DeoptimizationReason.*; |
5568
fdf19fa15ce4
Split bytecode utilities into separate project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5547
diff
changeset
|
28 import static com.oracle.graal.bytecode.Bytecodes.*; |
9675
a54720257b76
replaced MonitorEnterStub and MonitorExitStub with use of RuntimeCallStub
Doug Simon <doug.simon@oracle.com>
parents:
9601
diff
changeset
|
29 import static com.oracle.graal.java.GraphBuilderPhase.RuntimeCalls.*; |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9837
diff
changeset
|
30 import static com.oracle.graal.phases.GraalOptions.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 import static java.lang.reflect.Modifier.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 import java.lang.reflect.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 import java.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
36 import com.oracle.graal.api.code.*; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5506
diff
changeset
|
37 import com.oracle.graal.api.meta.*; |
8610
5407d1dd6450
API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8461
diff
changeset
|
38 import com.oracle.graal.api.meta.ProfilingInfo.TriState; |
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:
6534
diff
changeset
|
39 import com.oracle.graal.api.meta.ResolvedJavaType.Representation; |
5568
fdf19fa15ce4
Split bytecode utilities into separate project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5547
diff
changeset
|
40 import com.oracle.graal.bytecode.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
41 import com.oracle.graal.debug.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
42 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
43 import com.oracle.graal.java.BciBlockMapping.Block; |
5256
1e153fdac9fb
Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5255
diff
changeset
|
44 import com.oracle.graal.java.BciBlockMapping.ExceptionDispatchBlock; |
14533
e5235120893c
split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14521
diff
changeset
|
45 import com.oracle.graal.java.BciBlockMapping.LocalLiveness; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
46 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
47 import com.oracle.graal.nodes.calc.*; |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
48 import com.oracle.graal.nodes.calc.FloatConvertNode.FloatConvert; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
49 import com.oracle.graal.nodes.extended.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
50 import com.oracle.graal.nodes.java.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
51 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
52 import com.oracle.graal.nodes.type.*; |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5160
diff
changeset
|
53 import com.oracle.graal.nodes.util.*; |
12683
5c5b02a165d4
moved a number of options to be declared closer to usage and cached some heavily accessed options in fields
Doug Simon <doug.simon@oracle.com>
parents:
12656
diff
changeset
|
54 import com.oracle.graal.options.*; |
6525
2c913b643422
rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents:
6521
diff
changeset
|
55 import com.oracle.graal.phases.*; |
13585 | 56 import com.oracle.graal.phases.tiers.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 * The {@code GraphBuilder} class parses the bytecode of a method and builds the IR graph. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 */ |
13585 | 61 public class GraphBuilderPhase extends BasePhase<HighTierContext> { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 |
12683
5c5b02a165d4
moved a number of options to be declared closer to usage and cached some heavily accessed options in fields
Doug Simon <doug.simon@oracle.com>
parents:
12656
diff
changeset
|
63 static class Options { |
5c5b02a165d4
moved a number of options to be declared closer to usage and cached some heavily accessed options in fields
Doug Simon <doug.simon@oracle.com>
parents:
12656
diff
changeset
|
64 // @formatter:off |
5c5b02a165d4
moved a number of options to be declared closer to usage and cached some heavily accessed options in fields
Doug Simon <doug.simon@oracle.com>
parents:
12656
diff
changeset
|
65 @Option(help = "The trace level for the bytecode parser used when building a graph from bytecode") |
5c5b02a165d4
moved a number of options to be declared closer to usage and cached some heavily accessed options in fields
Doug Simon <doug.simon@oracle.com>
parents:
12656
diff
changeset
|
66 public static final OptionValue<Integer> TraceBytecodeParserLevel = new OptionValue<>(0); |
5c5b02a165d4
moved a number of options to be declared closer to usage and cached some heavily accessed options in fields
Doug Simon <doug.simon@oracle.com>
parents:
12656
diff
changeset
|
67 // @formatter:on |
5c5b02a165d4
moved a number of options to be declared closer to usage and cached some heavily accessed options in fields
Doug Simon <doug.simon@oracle.com>
parents:
12656
diff
changeset
|
68 } |
5c5b02a165d4
moved a number of options to be declared closer to usage and cached some heavily accessed options in fields
Doug Simon <doug.simon@oracle.com>
parents:
12656
diff
changeset
|
69 |
7558
223f645acb9b
added compilation rate measurements on top of existing metric/timer facility - enabled with -Dgraal.benchmark.compilation=true
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
70 public static final class RuntimeCalls { |
223f645acb9b
added compilation rate measurements on top of existing metric/timer facility - enabled with -Dgraal.benchmark.compilation=true
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
71 |
14045
7b5269608cb3
put tighter types on some builtin operations
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14024
diff
changeset
|
72 public static final ForeignCallDescriptor CREATE_NULL_POINTER_EXCEPTION = new ForeignCallDescriptor("createNullPointerException", NullPointerException.class); |
7b5269608cb3
put tighter types on some builtin operations
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14024
diff
changeset
|
73 public static final ForeignCallDescriptor CREATE_OUT_OF_BOUNDS_EXCEPTION = new ForeignCallDescriptor("createOutOfBoundsException", IndexOutOfBoundsException.class, int.class); |
7558
223f645acb9b
added compilation rate measurements on top of existing metric/timer facility - enabled with -Dgraal.benchmark.compilation=true
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
74 } |
6521
2a0c9f20baa1
consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
6511
diff
changeset
|
75 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 /** |
12683
5c5b02a165d4
moved a number of options to be declared closer to usage and cached some heavily accessed options in fields
Doug Simon <doug.simon@oracle.com>
parents:
12656
diff
changeset
|
77 * The minimum value to which {@link Options#TraceBytecodeParserLevel} must be set to trace the |
5c5b02a165d4
moved a number of options to be declared closer to usage and cached some heavily accessed options in fields
Doug Simon <doug.simon@oracle.com>
parents:
12656
diff
changeset
|
78 * bytecode instructions as they are parsed. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 public static final int TRACELEVEL_INSTRUCTIONS = 1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 /** |
12683
5c5b02a165d4
moved a number of options to be declared closer to usage and cached some heavily accessed options in fields
Doug Simon <doug.simon@oracle.com>
parents:
12656
diff
changeset
|
83 * The minimum value to which {@link Options#TraceBytecodeParserLevel} must be set to trace the |
5c5b02a165d4
moved a number of options to be declared closer to usage and cached some heavily accessed options in fields
Doug Simon <doug.simon@oracle.com>
parents:
12656
diff
changeset
|
84 * frame state before each bytecode instruction as it is parsed. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 public static final int TRACELEVEL_STATE = 2; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 |
5109
6766253384bf
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5105
diff
changeset
|
88 private final GraphBuilderConfiguration graphBuilderConfig; |
11639
fe748819e31c
removed the IterableNodeType marker interface from BlockPlaceholderNode (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents:
11631
diff
changeset
|
89 |
13585 | 90 public GraphBuilderPhase(GraphBuilderConfiguration graphBuilderConfig) { |
5109
6766253384bf
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5105
diff
changeset
|
91 this.graphBuilderConfig = graphBuilderConfig; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
94 @Override |
13585 | 95 protected void run(StructuredGraph graph, HighTierContext context) { |
96 new Instance(context.getMetaAccess(), graphBuilderConfig, context.getOptimisticOptimizations()).run(graph); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 |
13585 | 99 public static class Instance extends Phase { |
100 | |
101 private LineNumberTable lnt; | |
102 private int previousLineNumber; | |
103 private int currentLineNumber; | |
104 | |
105 protected StructuredGraph currentGraph; | |
106 | |
107 /** | |
108 * Head of placeholder list. | |
109 */ | |
110 protected BlockPlaceholderNode placeholders; | |
111 | |
112 private final MetaAccessProvider metaAccess; | |
113 private ConstantPool constantPool; | |
114 private ResolvedJavaMethod method; | |
115 private int entryBCI; | |
116 private ProfilingInfo profilingInfo; | |
117 | |
118 private BytecodeStream stream; // the bytecode stream | |
119 | |
14792
b9805a622546
Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14068
diff
changeset
|
120 protected HIRFrameStateBuilder frameState; // the current execution state |
13585 | 121 private Block currentBlock; |
122 | |
123 private ValueNode methodSynchronizedObject; | |
124 private ExceptionDispatchBlock unwindBlock; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 |
13585 | 126 private FixedWithNextNode lastInstr; // the last instruction added |
127 | |
128 private final GraphBuilderConfiguration graphBuilderConfig; | |
129 private final OptimisticOptimizations optimisticOpts; | |
130 | |
131 /** | |
132 * Meters the number of actual bytecodes parsed. | |
133 */ | |
134 public static final DebugMetric BytecodesParsed = Debug.metric("BytecodesParsed"); | |
135 | |
136 /** | |
137 * Node that marks the begin of block during bytecode parsing. When a block is identified | |
138 * the first time as a jump target, the placeholder is created and used as the successor for | |
139 * the jump. When the block is seen the second time, a {@link MergeNode} is created to | |
140 * correctly merge the now two different predecessor states. | |
141 */ | |
142 private static class BlockPlaceholderNode extends FixedWithNextNode { | |
143 | |
144 /* | |
145 * Cannot be explicitly declared as a Node type since it is not an input; would cause | |
146 * the !NODE_CLASS.isAssignableFrom(type) guarantee in | |
147 * NodeClass.FieldScanner.scanField() to fail. | |
148 */ | |
149 private final Object nextPlaceholder; | |
150 | |
151 public BlockPlaceholderNode(Instance builder) { | |
152 super(StampFactory.forVoid()); | |
153 nextPlaceholder = builder.placeholders; | |
154 builder.placeholders = this; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
155 } |
13585 | 156 |
157 BlockPlaceholderNode nextPlaceholder() { | |
158 return (BlockPlaceholderNode) nextPlaceholder; | |
159 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 } |
13585 | 161 |
162 private Block[] loopHeaders; | |
14533
e5235120893c
split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14521
diff
changeset
|
163 private LocalLiveness liveness; |
13585 | 164 |
165 /** | |
166 * Gets the current frame state being processed by this builder. | |
167 */ | |
14792
b9805a622546
Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14068
diff
changeset
|
168 protected HIRFrameStateBuilder getCurrentFrameState() { |
13585 | 169 return frameState; |
170 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
171 |
13585 | 172 /** |
173 * Gets the graph being processed by this builder. | |
174 */ | |
175 protected StructuredGraph getGraph() { | |
176 return currentGraph; | |
177 } | |
178 | |
179 protected ResolvedJavaMethod getMethod() { | |
180 return method; | |
181 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 |
13585 | 183 public Instance(MetaAccessProvider metaAccess, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts) { |
184 this.graphBuilderConfig = graphBuilderConfig; | |
185 this.optimisticOpts = optimisticOpts; | |
186 this.metaAccess = metaAccess; | |
187 assert metaAccess != null; | |
188 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
189 |
13585 | 190 @Override |
191 protected void run(StructuredGraph graph) { | |
192 method = graph.method(); | |
193 if (graphBuilderConfig.eagerInfopointMode()) { | |
194 lnt = method.getLineNumberTable(); | |
195 previousLineNumber = -1; | |
196 } | |
197 entryBCI = graph.getEntryBCI(); | |
198 profilingInfo = method.getProfilingInfo(); | |
199 assert method.getCode() != null : "method must contain bytecodes: " + method; | |
200 this.stream = new BytecodeStream(method.getCode()); | |
201 this.constantPool = method.getConstantPool(); | |
202 unwindBlock = null; | |
203 methodSynchronizedObject = null; | |
204 this.currentGraph = graph; | |
14792
b9805a622546
Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14068
diff
changeset
|
205 this.frameState = new HIRFrameStateBuilder(method, graph, graphBuilderConfig.eagerResolving()); |
13585 | 206 TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method); |
207 try { | |
208 build(); | |
209 } finally { | |
210 filter.remove(); | |
211 } | |
212 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 |
13585 | 214 @Override |
215 protected String getDetailedName() { | |
216 return getName() + " " + MetaUtil.format("%H.%n(%p):%r", method); | |
217 } | |
218 | |
219 protected void build() { | |
220 if (PrintProfilingInformation.getValue()) { | |
221 TTY.println("Profiling info for " + MetaUtil.format("%H.%n(%p)", method)); | |
222 TTY.println(MetaUtil.indent(MetaUtil.profileToString(profilingInfo, method, CodeUtil.NEW_LINE), " ")); | |
223 } | |
224 | |
225 Indent indent = Debug.logAndIndent("build graph for %s", method); | |
226 | |
227 // compute the block map, setup exception handlers and get the entrypoint(s) | |
14066
56726a90dc71
First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14045
diff
changeset
|
228 BciBlockMapping blockMap = BciBlockMapping.create(method); |
13585 | 229 loopHeaders = blockMap.loopHeaders; |
14533
e5235120893c
split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14521
diff
changeset
|
230 liveness = blockMap.liveness; |
13585 | 231 |
232 lastInstr = currentGraph.start(); | |
233 if (isSynchronized(method.getModifiers())) { | |
234 // add a monitor enter to the start block | |
235 currentGraph.start().setStateAfter(frameState.create(FrameState.BEFORE_BCI)); | |
236 methodSynchronizedObject = synchronizedObject(frameState, method); | |
237 lastInstr = genMonitorEnter(methodSynchronizedObject); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
238 } |
14533
e5235120893c
split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14521
diff
changeset
|
239 frameState.clearNonLiveLocals(blockMap.startBlock, liveness, true); |
13585 | 240 ((StateSplit) lastInstr).setStateAfter(frameState.create(0)); |
241 | |
242 if (graphBuilderConfig.eagerInfopointMode()) { | |
243 InfopointNode ipn = currentGraph.add(new InfopointNode(InfopointReason.METHOD_START, frameState.create(0))); | |
244 lastInstr.setNext(ipn); | |
245 lastInstr = ipn; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
246 } |
13585 | 247 |
248 currentBlock = blockMap.startBlock; | |
249 blockMap.startBlock.entryState = frameState; | |
250 if (blockMap.startBlock.isLoopHeader) { | |
251 /* | |
252 * TODO(lstadler,gduboscq) createTarget might not be safe at this position, since it | |
253 * expects currentBlock, etc. to be set up correctly. A better solution to this | |
254 * problem of start blocks that are loop headers would be to create a dummy block in | |
255 * BciBlockMapping. | |
256 */ | |
257 appendGoto(createTarget(blockMap.startBlock, frameState)); | |
258 } else { | |
259 blockMap.startBlock.firstInstruction = lastInstr; | |
260 } | |
261 | |
262 for (Block block : blockMap.blocks) { | |
263 processBlock(block); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
264 } |
13585 | 265 processBlock(unwindBlock); |
266 | |
267 Debug.dump(currentGraph, "After bytecode parsing"); | |
268 | |
269 connectLoopEndToBegin(); | |
270 | |
271 // remove Placeholders | |
272 for (BlockPlaceholderNode n = placeholders; n != null; n = n.nextPlaceholder()) { | |
273 if (!n.isDeleted()) { | |
274 currentGraph.removeFixed(n); | |
275 } | |
276 } | |
277 placeholders = null; | |
278 | |
279 // remove dead FrameStates | |
280 for (Node n : currentGraph.getNodes(FrameState.class)) { | |
281 if (n.usages().isEmpty() && n.predecessor() == null) { | |
282 n.safeDelete(); | |
283 } | |
284 } | |
285 indent.outdent(); | |
286 } | |
287 | |
288 private Block unwindBlock(int bci) { | |
289 if (unwindBlock == null) { | |
290 unwindBlock = new ExceptionDispatchBlock(); | |
291 unwindBlock.startBci = -1; | |
292 unwindBlock.endBci = -1; | |
293 unwindBlock.deoptBci = bci; | |
294 unwindBlock.blockID = Integer.MAX_VALUE; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
295 } |
13585 | 296 return unwindBlock; |
297 } | |
298 | |
14066
56726a90dc71
First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14045
diff
changeset
|
299 protected BytecodeStream stream() { |
13585 | 300 return stream; |
301 } | |
302 | |
14066
56726a90dc71
First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14045
diff
changeset
|
303 protected int bci() { |
13585 | 304 return stream.currentBCI(); |
305 } | |
306 | |
307 private void loadLocal(int index, Kind kind) { | |
308 frameState.push(kind, frameState.loadLocal(index)); | |
309 } | |
310 | |
311 private void storeLocal(Kind kind, int index) { | |
312 ValueNode value; | |
313 if (kind == Kind.Object) { | |
314 value = frameState.xpop(); | |
315 // astore and astore_<n> may be used to store a returnAddress (jsr) | |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
316 assert value.getKind() == Kind.Object || value.getKind() == Kind.Int; |
13585 | 317 } else { |
318 value = frameState.pop(kind); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
319 } |
13585 | 320 frameState.storeLocal(index, value); |
321 } | |
322 | |
323 /** | |
324 * @param type the unresolved type of the constant | |
325 */ | |
326 protected void handleUnresolvedLoadConstant(JavaType type) { | |
327 assert !graphBuilderConfig.eagerResolving(); | |
328 append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); | |
329 frameState.push(Kind.Object, appendConstant(Constant.NULL_OBJECT)); | |
330 } | |
331 | |
332 /** | |
333 * @param type the unresolved type of the type check | |
334 * @param object the object value whose type is being checked against {@code type} | |
335 */ | |
336 protected void handleUnresolvedCheckCast(JavaType type, ValueNode object) { | |
337 assert !graphBuilderConfig.eagerResolving(); | |
338 append(new FixedGuardNode(currentGraph.unique(new IsNullNode(object)), Unresolved, InvalidateRecompile)); | |
339 frameState.apush(appendConstant(Constant.NULL_OBJECT)); | |
340 } | |
341 | |
342 /** | |
343 * @param type the unresolved type of the type check | |
344 * @param object the object value whose type is being checked against {@code type} | |
345 */ | |
346 protected void handleUnresolvedInstanceOf(JavaType type, ValueNode object) { | |
347 assert !graphBuilderConfig.eagerResolving(); | |
348 BlockPlaceholderNode successor = currentGraph.add(new BlockPlaceholderNode(this)); | |
349 DeoptimizeNode deopt = currentGraph.add(new DeoptimizeNode(InvalidateRecompile, Unresolved)); | |
350 append(new IfNode(currentGraph.unique(new IsNullNode(object)), successor, deopt, 1)); | |
351 lastInstr = successor; | |
352 frameState.ipush(appendConstant(Constant.INT_0)); | |
353 } | |
354 | |
355 /** | |
356 * @param type the type being instantiated | |
357 */ | |
358 protected void handleUnresolvedNewInstance(JavaType type) { | |
359 assert !graphBuilderConfig.eagerResolving(); | |
360 append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); | |
361 frameState.apush(appendConstant(Constant.NULL_OBJECT)); | |
362 } | |
363 | |
364 /** | |
365 * @param type the type of the array being instantiated | |
366 * @param length the length of the array | |
367 */ | |
368 protected void handleUnresolvedNewObjectArray(JavaType type, ValueNode length) { | |
369 assert !graphBuilderConfig.eagerResolving(); | |
370 append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); | |
371 frameState.apush(appendConstant(Constant.NULL_OBJECT)); | |
372 } | |
373 | |
374 /** | |
375 * @param type the type being instantiated | |
376 * @param dims the dimensions for the multi-array | |
377 */ | |
378 protected void handleUnresolvedNewMultiArray(JavaType type, ValueNode[] dims) { | |
379 assert !graphBuilderConfig.eagerResolving(); | |
380 append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); | |
381 frameState.apush(appendConstant(Constant.NULL_OBJECT)); | |
382 } | |
383 | |
384 /** | |
385 * @param field the unresolved field | |
386 * @param receiver the object containing the field or {@code null} if {@code field} is | |
387 * static | |
388 */ | |
389 protected void handleUnresolvedLoadField(JavaField field, ValueNode receiver) { | |
390 assert !graphBuilderConfig.eagerResolving(); | |
391 Kind kind = field.getKind(); | |
392 append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); | |
393 frameState.push(kind.getStackKind(), appendConstant(Constant.defaultForKind(kind))); | |
394 } | |
395 | |
396 /** | |
397 * @param field the unresolved field | |
398 * @param value the value being stored to the field | |
399 * @param receiver the object containing the field or {@code null} if {@code field} is | |
400 * static | |
401 */ | |
402 protected void handleUnresolvedStoreField(JavaField field, ValueNode value, ValueNode receiver) { | |
403 assert !graphBuilderConfig.eagerResolving(); | |
404 append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); | |
405 } | |
406 | |
407 /** | |
408 * @param representation | |
409 * @param type | |
410 */ | |
411 protected void handleUnresolvedExceptionType(Representation representation, JavaType type) { | |
412 assert !graphBuilderConfig.eagerResolving(); | |
413 append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); | |
414 } | |
415 | |
416 protected void handleUnresolvedInvoke(JavaMethod javaMethod, InvokeKind invokeKind) { | |
417 assert !graphBuilderConfig.eagerResolving(); | |
418 boolean withReceiver = invokeKind != InvokeKind.Static; | |
419 append(new DeoptimizeNode(InvalidateRecompile, Unresolved)); | |
420 frameState.popArguments(javaMethod.getSignature().getParameterSlots(withReceiver), javaMethod.getSignature().getParameterCount(withReceiver)); | |
421 Kind kind = javaMethod.getSignature().getReturnKind(); | |
422 if (kind != Kind.Void) { | |
423 frameState.push(kind.getStackKind(), appendConstant(Constant.defaultForKind(kind))); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
424 } |
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 |
13585 | 427 private DispatchBeginNode handleException(ValueNode exceptionObject, int bci) { |
428 assert bci == FrameState.BEFORE_BCI || bci == bci() : "invalid bci"; | |
429 Debug.log("Creating exception dispatch edges at %d, exception object=%s, exception seen=%s", bci, exceptionObject, profilingInfo.getExceptionSeen(bci)); | |
430 | |
431 Block dispatchBlock = currentBlock.exceptionDispatchBlock(); | |
432 /* | |
433 * The exception dispatch block is always for the last bytecode of a block, so if we are | |
434 * not at the endBci yet, there is no exception handler for this bci and we can unwind | |
435 * immediately. | |
436 */ | |
437 if (bci != currentBlock.endBci || dispatchBlock == null) { | |
438 dispatchBlock = unwindBlock(bci); | |
439 } | |
440 | |
14792
b9805a622546
Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14068
diff
changeset
|
441 HIRFrameStateBuilder dispatchState = frameState.copy(); |
13585 | 442 dispatchState.clearStack(); |
443 | |
444 DispatchBeginNode dispatchBegin; | |
445 if (exceptionObject == null) { | |
446 dispatchBegin = currentGraph.add(new ExceptionObjectNode(metaAccess)); | |
447 dispatchState.apush(dispatchBegin); | |
448 dispatchState.setRethrowException(true); | |
449 dispatchBegin.setStateAfter(dispatchState.create(bci)); | |
450 } else { | |
451 dispatchBegin = currentGraph.add(new DispatchBeginNode()); | |
452 dispatchBegin.setStateAfter(dispatchState.create(bci)); | |
453 dispatchState.apush(exceptionObject); | |
454 dispatchState.setRethrowException(true); | |
455 } | |
456 FixedNode target = createTarget(dispatchBlock, dispatchState); | |
457 dispatchBegin.setNext(target); | |
458 return dispatchBegin; | |
459 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
460 |
13585 | 461 private void genLoadConstant(int cpi, int opcode) { |
462 Object con = lookupConstant(cpi, opcode); | |
463 | |
464 if (con instanceof JavaType) { | |
465 // this is a load of class constant which might be unresolved | |
466 JavaType type = (JavaType) con; | |
467 if (type instanceof ResolvedJavaType) { | |
468 frameState.push(Kind.Object, appendConstant(((ResolvedJavaType) type).getEncoding(Representation.JavaClass))); | |
469 } else { | |
470 handleUnresolvedLoadConstant(type); | |
471 } | |
472 } else if (con instanceof Constant) { | |
473 Constant constant = (Constant) con; | |
474 frameState.push(constant.getKind().getStackKind(), appendConstant(constant)); | |
475 } else { | |
476 throw new Error("lookupConstant returned an object of incorrect type"); | |
477 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
478 } |
13585 | 479 |
480 private void genLoadIndexed(Kind kind) { | |
481 emitExplicitExceptions(frameState.peek(1), frameState.peek(0)); | |
482 | |
483 ValueNode index = frameState.ipop(); | |
484 ValueNode array = frameState.apop(); | |
485 frameState.push(kind.getStackKind(), append(new LoadIndexedNode(array, index, kind))); | |
486 } | |
7305
cd205ca515dd
Make integer division and remainder nodes fixed so that they can be lowered via snippets to do exception checks
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7300
diff
changeset
|
487 |
13585 | 488 private void genStoreIndexed(Kind kind) { |
489 emitExplicitExceptions(frameState.peek(2), frameState.peek(1)); | |
490 | |
491 ValueNode value = frameState.pop(kind.getStackKind()); | |
492 ValueNode index = frameState.ipop(); | |
493 ValueNode array = frameState.apop(); | |
494 append(new StoreIndexedNode(array, index, kind, value)); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
495 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
496 |
13585 | 497 private void stackOp(int opcode) { |
498 switch (opcode) { | |
499 case POP: { | |
500 frameState.xpop(); | |
501 break; | |
502 } | |
503 case POP2: { | |
504 frameState.xpop(); | |
505 frameState.xpop(); | |
506 break; | |
507 } | |
508 case DUP: { | |
509 ValueNode w = frameState.xpop(); | |
510 frameState.xpush(w); | |
511 frameState.xpush(w); | |
512 break; | |
513 } | |
514 case DUP_X1: { | |
515 ValueNode w1 = frameState.xpop(); | |
516 ValueNode w2 = frameState.xpop(); | |
517 frameState.xpush(w1); | |
518 frameState.xpush(w2); | |
519 frameState.xpush(w1); | |
520 break; | |
521 } | |
522 case DUP_X2: { | |
523 ValueNode w1 = frameState.xpop(); | |
524 ValueNode w2 = frameState.xpop(); | |
525 ValueNode w3 = frameState.xpop(); | |
526 frameState.xpush(w1); | |
527 frameState.xpush(w3); | |
528 frameState.xpush(w2); | |
529 frameState.xpush(w1); | |
530 break; | |
531 } | |
532 case DUP2: { | |
533 ValueNode w1 = frameState.xpop(); | |
534 ValueNode w2 = frameState.xpop(); | |
535 frameState.xpush(w2); | |
536 frameState.xpush(w1); | |
537 frameState.xpush(w2); | |
538 frameState.xpush(w1); | |
539 break; | |
540 } | |
541 case DUP2_X1: { | |
542 ValueNode w1 = frameState.xpop(); | |
543 ValueNode w2 = frameState.xpop(); | |
544 ValueNode w3 = frameState.xpop(); | |
545 frameState.xpush(w2); | |
546 frameState.xpush(w1); | |
547 frameState.xpush(w3); | |
548 frameState.xpush(w2); | |
549 frameState.xpush(w1); | |
550 break; | |
551 } | |
552 case DUP2_X2: { | |
553 ValueNode w1 = frameState.xpop(); | |
554 ValueNode w2 = frameState.xpop(); | |
555 ValueNode w3 = frameState.xpop(); | |
556 ValueNode w4 = frameState.xpop(); | |
557 frameState.xpush(w2); | |
558 frameState.xpush(w1); | |
559 frameState.xpush(w4); | |
560 frameState.xpush(w3); | |
561 frameState.xpush(w2); | |
562 frameState.xpush(w1); | |
563 break; | |
564 } | |
565 case SWAP: { | |
566 ValueNode w1 = frameState.xpop(); | |
567 ValueNode w2 = frameState.xpop(); | |
568 frameState.xpush(w1); | |
569 frameState.xpush(w2); | |
570 break; | |
571 } | |
572 default: | |
573 throw GraalInternalError.shouldNotReachHere(); | |
574 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
575 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
576 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
577 |
13585 | 578 private void genArithmeticOp(Kind result, int opcode) { |
579 ValueNode y = frameState.pop(result); | |
580 ValueNode x = frameState.pop(result); | |
581 boolean isStrictFP = isStrict(method.getModifiers()); | |
582 BinaryNode v; | |
583 switch (opcode) { | |
584 case IADD: | |
585 case LADD: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
586 v = new IntegerAddNode(StampFactory.forKind(result), x, y); |
13585 | 587 break; |
588 case FADD: | |
589 case DADD: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
590 v = new FloatAddNode(StampFactory.forKind(result), x, y, isStrictFP); |
13585 | 591 break; |
592 case ISUB: | |
593 case LSUB: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
594 v = new IntegerSubNode(StampFactory.forKind(result), x, y); |
13585 | 595 break; |
596 case FSUB: | |
597 case DSUB: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
598 v = new FloatSubNode(StampFactory.forKind(result), x, y, isStrictFP); |
13585 | 599 break; |
600 case IMUL: | |
601 case LMUL: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
602 v = new IntegerMulNode(StampFactory.forKind(result), x, y); |
13585 | 603 break; |
604 case FMUL: | |
605 case DMUL: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
606 v = new FloatMulNode(StampFactory.forKind(result), x, y, isStrictFP); |
13585 | 607 break; |
608 case FDIV: | |
609 case DDIV: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
610 v = new FloatDivNode(StampFactory.forKind(result), x, y, isStrictFP); |
13585 | 611 break; |
612 case FREM: | |
613 case DREM: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
614 v = new FloatRemNode(StampFactory.forKind(result), x, y, isStrictFP); |
13585 | 615 break; |
616 default: | |
617 throw new GraalInternalError("should not reach"); | |
618 } | |
619 frameState.push(result, append(v)); | |
5029
74f47ef37394
Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5026
diff
changeset
|
620 } |
74f47ef37394
Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5026
diff
changeset
|
621 |
13585 | 622 private void genIntegerDivOp(Kind result, int opcode) { |
623 ValueNode y = frameState.pop(result); | |
624 ValueNode x = frameState.pop(result); | |
625 FixedWithNextNode v; | |
626 switch (opcode) { | |
627 case IDIV: | |
628 case LDIV: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
629 v = new IntegerDivNode(StampFactory.forKind(result), x, y); |
13585 | 630 break; |
631 case IREM: | |
632 case LREM: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
633 v = new IntegerRemNode(StampFactory.forKind(result), x, y); |
13585 | 634 break; |
635 default: | |
636 throw new GraalInternalError("should not reach"); | |
637 } | |
638 frameState.push(result, append(v)); | |
639 } | |
640 | |
641 private void genNegateOp(Kind kind) { | |
642 frameState.push(kind, append(new NegateNode(frameState.pop(kind)))); | |
643 } | |
644 | |
645 private void genShiftOp(Kind kind, int opcode) { | |
646 ValueNode s = frameState.ipop(); | |
647 ValueNode x = frameState.pop(kind); | |
648 ShiftNode v; | |
649 switch (opcode) { | |
650 case ISHL: | |
651 case LSHL: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
652 v = new LeftShiftNode(StampFactory.forKind(kind), x, s); |
13585 | 653 break; |
654 case ISHR: | |
655 case LSHR: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
656 v = new RightShiftNode(StampFactory.forKind(kind), x, s); |
13585 | 657 break; |
658 case IUSHR: | |
659 case LUSHR: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
660 v = new UnsignedRightShiftNode(StampFactory.forKind(kind), x, s); |
13585 | 661 break; |
662 default: | |
663 throw new GraalInternalError("should not reach"); | |
664 } | |
665 frameState.push(kind, append(v)); | |
666 } | |
667 | |
668 private void genLogicOp(Kind kind, int opcode) { | |
669 ValueNode y = frameState.pop(kind); | |
670 ValueNode x = frameState.pop(kind); | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
671 Stamp stamp = StampFactory.forKind(kind); |
13585 | 672 BitLogicNode v; |
673 switch (opcode) { | |
674 case IAND: | |
675 case LAND: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
676 v = new AndNode(stamp, x, y); |
13585 | 677 break; |
678 case IOR: | |
679 case LOR: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
680 v = new OrNode(stamp, x, y); |
13585 | 681 break; |
682 case IXOR: | |
683 case LXOR: | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
684 v = new XorNode(stamp, x, y); |
13585 | 685 break; |
686 default: | |
687 throw new GraalInternalError("should not reach"); | |
688 } | |
689 frameState.push(kind, append(v)); | |
690 } | |
691 | |
692 private void genCompareOp(Kind kind, boolean isUnorderedLess) { | |
693 ValueNode y = frameState.pop(kind); | |
694 ValueNode x = frameState.pop(kind); | |
695 frameState.ipush(append(new NormalizeCompareNode(x, y, isUnorderedLess))); | |
696 } | |
697 | |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
698 private void genFloatConvert(FloatConvert op, Kind from, Kind to) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
699 ValueNode input = frameState.pop(from.getStackKind()); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
700 frameState.push(to.getStackKind(), append(new FloatConvertNode(op, input))); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
701 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
702 |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
703 private void genSignExtend(Kind from, Kind to) { |
13585 | 704 ValueNode input = frameState.pop(from.getStackKind()); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
705 if (from != from.getStackKind()) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
706 input = append(new NarrowNode(input, from.getBitCount())); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
707 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
708 frameState.push(to.getStackKind(), append(new SignExtendNode(input, to.getBitCount()))); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
709 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
710 |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
711 private void genZeroExtend(Kind from, Kind to) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
712 ValueNode input = frameState.pop(from.getStackKind()); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
713 if (from != from.getStackKind()) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
714 input = append(new NarrowNode(input, from.getBitCount())); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
715 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
716 frameState.push(to.getStackKind(), append(new ZeroExtendNode(input, to.getBitCount()))); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
717 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
718 |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
719 private void genNarrow(Kind from, Kind to) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
720 ValueNode input = frameState.pop(from.getStackKind()); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
721 frameState.push(to.getStackKind(), append(new NarrowNode(input, to.getBitCount()))); |
13585 | 722 } |
723 | |
724 private void genIncrement() { | |
725 int index = stream().readLocalIndex(); | |
726 int delta = stream().readIncrement(); | |
727 ValueNode x = frameState.loadLocal(index); | |
728 ValueNode y = appendConstant(Constant.forInt(delta)); | |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14016
diff
changeset
|
729 frameState.storeLocal(index, append(new IntegerAddNode(StampFactory.forKind(Kind.Int), x, y))); |
13585 | 730 } |
731 | |
732 private void genGoto() { | |
733 appendGoto(createTarget(currentBlock.successors.get(0), frameState)); | |
734 assert currentBlock.numNormalSuccessors() == 1; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
735 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
736 |
13585 | 737 private void ifNode(ValueNode x, Condition cond, ValueNode y) { |
738 assert !x.isDeleted() && !y.isDeleted(); | |
739 assert currentBlock.numNormalSuccessors() == 2; | |
740 Block trueBlock = currentBlock.successors.get(0); | |
741 Block falseBlock = currentBlock.successors.get(1); | |
742 if (trueBlock == falseBlock) { | |
743 appendGoto(createTarget(trueBlock, frameState)); | |
744 return; | |
745 } | |
746 | |
747 double probability = profilingInfo.getBranchTakenProbability(bci()); | |
748 if (probability < 0) { | |
749 assert probability == -1 : "invalid probability"; | |
750 Debug.log("missing probability in %s at bci %d", method, bci()); | |
751 probability = 0.5; | |
752 } | |
753 | |
754 if (!optimisticOpts.removeNeverExecutedCode()) { | |
755 if (probability == 0) { | |
756 probability = 0.0000001; | |
757 } else if (probability == 1) { | |
758 probability = 0.999999; | |
759 } | |
760 } | |
761 | |
762 // the mirroring and negation operations get the condition into canonical form | |
763 boolean mirror = cond.canonicalMirror(); | |
764 boolean negate = cond.canonicalNegate(); | |
765 | |
766 ValueNode a = mirror ? y : x; | |
767 ValueNode b = mirror ? x : y; | |
768 | |
769 CompareNode condition; | |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
770 assert !a.getKind().isNumericFloat(); |
13585 | 771 if (cond == Condition.EQ || cond == Condition.NE) { |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
772 if (a.getKind() == Kind.Object) { |
13585 | 773 condition = new ObjectEqualsNode(a, b); |
774 } else { | |
775 condition = new IntegerEqualsNode(a, b); | |
776 } | |
777 } else { | |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
778 assert a.getKind() != Kind.Object && !cond.isUnsigned(); |
13585 | 779 condition = new IntegerLessThanNode(a, b); |
780 } | |
781 condition = currentGraph.unique(condition); | |
782 | |
783 AbstractBeginNode trueSuccessor = createBlockTarget(probability, trueBlock, frameState); | |
784 AbstractBeginNode falseSuccessor = createBlockTarget(1 - probability, falseBlock, frameState); | |
785 | |
786 IfNode ifNode = negate ? new IfNode(condition, falseSuccessor, trueSuccessor, 1 - probability) : new IfNode(condition, trueSuccessor, falseSuccessor, probability); | |
787 append(ifNode); | |
788 } | |
789 | |
790 private void genIfZero(Condition cond) { | |
791 ValueNode y = appendConstant(Constant.INT_0); | |
792 ValueNode x = frameState.ipop(); | |
793 ifNode(x, cond, y); | |
794 } | |
795 | |
796 private void genIfNull(Condition cond) { | |
797 ValueNode y = appendConstant(Constant.NULL_OBJECT); | |
798 ValueNode x = frameState.apop(); | |
799 ifNode(x, cond, y); | |
800 } | |
801 | |
802 private void genIfSame(Kind kind, Condition cond) { | |
803 ValueNode y = frameState.pop(kind); | |
804 ValueNode x = frameState.pop(kind); | |
805 assert !x.isDeleted() && !y.isDeleted(); | |
806 ifNode(x, cond, y); | |
807 } | |
808 | |
809 private void genThrow() { | |
810 ValueNode exception = frameState.apop(); | |
811 append(new FixedGuardNode(currentGraph.unique(new IsNullNode(exception)), NullCheckException, InvalidateReprofile, true)); | |
812 lastInstr.setNext(handleException(exception, bci())); | |
813 } | |
814 | |
815 private JavaType lookupType(int cpi, int bytecode) { | |
816 eagerResolvingForSnippets(cpi, bytecode); | |
817 JavaType result = constantPool.lookupType(cpi, bytecode); | |
818 assert !graphBuilderConfig.unresolvedIsError() || result instanceof ResolvedJavaType; | |
819 return result; | |
820 } | |
821 | |
822 private JavaMethod lookupMethod(int cpi, int opcode) { | |
823 eagerResolvingForSnippets(cpi, opcode); | |
824 JavaMethod result = constantPool.lookupMethod(cpi, opcode); | |
825 /* | |
14068
73f5ddd8414d
clean up snippet-related assertion in GraphBuilderPhase
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14066
diff
changeset
|
826 * In general, one cannot assume that the declaring class being initialized is useful, |
73f5ddd8414d
clean up snippet-related assertion in GraphBuilderPhase
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14066
diff
changeset
|
827 * since the actual concrete receiver may be a different class (except for static |
73f5ddd8414d
clean up snippet-related assertion in GraphBuilderPhase
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14066
diff
changeset
|
828 * calls). Also, interfaces are initialized only under special circumstances, so that |
73f5ddd8414d
clean up snippet-related assertion in GraphBuilderPhase
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14066
diff
changeset
|
829 * this assertion would often fail for interface calls. |
13585 | 830 */ |
14518
d8041d695d19
Merged with jdk9/dev/hotspot changeset 3812c088b945
twisti
parents:
14068
diff
changeset
|
831 assert !graphBuilderConfig.unresolvedIsError() || (result instanceof ResolvedJavaMethod && (opcode != INVOKESTATIC || ((ResolvedJavaMethod) result).getDeclaringClass().isInitialized())) : result; |
13585 | 832 return result; |
833 } | |
834 | |
835 private JavaField lookupField(int cpi, int opcode) { | |
836 eagerResolvingForSnippets(cpi, opcode); | |
837 JavaField result = constantPool.lookupField(cpi, opcode); | |
838 assert !graphBuilderConfig.unresolvedIsError() || (result instanceof ResolvedJavaField && ((ResolvedJavaField) result).getDeclaringClass().isInitialized()) : result; | |
839 return result; | |
840 } | |
841 | |
842 private Object lookupConstant(int cpi, int opcode) { | |
843 eagerResolvingForSnippets(cpi, opcode); | |
844 Object result = constantPool.lookupConstant(cpi); | |
14518
d8041d695d19
Merged with jdk9/dev/hotspot changeset 3812c088b945
twisti
parents:
14068
diff
changeset
|
845 assert !graphBuilderConfig.eagerResolving() || !(result instanceof JavaType) || (result instanceof ResolvedJavaType) : result; |
13585 | 846 return result; |
847 } | |
848 | |
849 private void eagerResolvingForSnippets(int cpi, int bytecode) { | |
850 if (graphBuilderConfig.eagerResolving()) { | |
851 constantPool.loadReferencedType(cpi, bytecode); | |
852 } | |
853 } | |
854 | |
855 private JavaTypeProfile getProfileForTypeCheck(ResolvedJavaType type) { | |
856 if (!optimisticOpts.useTypeCheckHints() || !canHaveSubtype(type)) { | |
857 return null; | |
858 } else { | |
859 return profilingInfo.getTypeProfile(bci()); | |
11336
e99a5d7c3deb
Adjust profiling information in case it is 0.0 or 1.0 for a branch.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11319
diff
changeset
|
860 } |
e99a5d7c3deb
Adjust profiling information in case it is 0.0 or 1.0 for a branch.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11319
diff
changeset
|
861 } |
e99a5d7c3deb
Adjust profiling information in case it is 0.0 or 1.0 for a branch.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11319
diff
changeset
|
862 |
13585 | 863 private void genCheckCast() { |
864 int cpi = stream().readCPI(); | |
865 JavaType type = lookupType(cpi, CHECKCAST); | |
866 ValueNode object = frameState.apop(); | |
867 if (type instanceof ResolvedJavaType) { | |
868 JavaTypeProfile profileForTypeCheck = getProfileForTypeCheck((ResolvedJavaType) type); | |
869 CheckCastNode checkCastNode = append(new CheckCastNode((ResolvedJavaType) type, object, profileForTypeCheck, false)); | |
870 frameState.apush(checkCastNode); | |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5401
diff
changeset
|
871 } else { |
13585 | 872 handleUnresolvedCheckCast(type, object); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5401
diff
changeset
|
873 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5401
diff
changeset
|
874 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
875 |
13585 | 876 private void genInstanceOf() { |
877 int cpi = stream().readCPI(); | |
878 JavaType type = lookupType(cpi, INSTANCEOF); | |
879 ValueNode object = frameState.apop(); | |
880 if (type instanceof ResolvedJavaType) { | |
881 ResolvedJavaType resolvedType = (ResolvedJavaType) type; | |
882 InstanceOfNode instanceOfNode = new InstanceOfNode((ResolvedJavaType) type, object, getProfileForTypeCheck(resolvedType)); | |
883 frameState.ipush(append(new ConditionalNode(currentGraph.unique(instanceOfNode)))); | |
884 } else { | |
885 handleUnresolvedInstanceOf(type, object); | |
886 } | |
887 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
888 |
13585 | 889 void genNewInstance(int cpi) { |
890 JavaType type = lookupType(cpi, NEW); | |
891 if (type instanceof ResolvedJavaType && ((ResolvedJavaType) type).isInitialized()) { | |
892 frameState.apush(append(createNewInstance((ResolvedJavaType) type, true))); | |
893 } else { | |
894 handleUnresolvedNewInstance(type); | |
895 } | |
896 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
897 |
13585 | 898 protected NewInstanceNode createNewInstance(ResolvedJavaType type, boolean fillContents) { |
899 return new NewInstanceNode(type, fillContents); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
900 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
901 |
13585 | 902 /** |
903 * Gets the kind of array elements for the array type code that appears in a | |
904 * {@link Bytecodes#NEWARRAY} bytecode. | |
905 * | |
906 * @param code the array type code | |
907 * @return the kind from the array type code | |
908 */ | |
909 public static Class<?> arrayTypeCodeToClass(int code) { | |
910 // Checkstyle: stop | |
911 switch (code) { | |
912 case 4: | |
913 return boolean.class; | |
914 case 5: | |
915 return char.class; | |
916 case 6: | |
917 return float.class; | |
918 case 7: | |
919 return double.class; | |
920 case 8: | |
921 return byte.class; | |
922 case 9: | |
923 return short.class; | |
924 case 10: | |
925 return int.class; | |
926 case 11: | |
927 return long.class; | |
928 default: | |
929 throw new IllegalArgumentException("unknown array type code: " + code); | |
930 } | |
931 // Checkstyle: resume | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
932 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
933 |
13585 | 934 private void genNewPrimitiveArray(int typeCode) { |
935 Class<?> clazz = arrayTypeCodeToClass(typeCode); | |
936 ResolvedJavaType elementType = metaAccess.lookupJavaType(clazz); | |
937 frameState.apush(append(createNewArray(elementType, frameState.ipop(), true))); | |
938 } | |
13133
dfb8de11d1bf
Make graph builder more extensible by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
939 |
13585 | 940 private void genNewObjectArray(int cpi) { |
941 JavaType type = lookupType(cpi, ANEWARRAY); | |
942 ValueNode length = frameState.ipop(); | |
943 if (type instanceof ResolvedJavaType) { | |
944 frameState.apush(append(createNewArray((ResolvedJavaType) type, length, true))); | |
945 } else { | |
946 handleUnresolvedNewObjectArray(type, length); | |
947 } | |
948 | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
949 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
950 |
13585 | 951 protected NewArrayNode createNewArray(ResolvedJavaType elementType, ValueNode length, boolean fillContents) { |
952 return new NewArrayNode(elementType, length, fillContents); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
953 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
954 |
13585 | 955 private void genNewMultiArray(int cpi) { |
956 JavaType type = lookupType(cpi, MULTIANEWARRAY); | |
957 int rank = stream().readUByte(bci() + 3); | |
958 ValueNode[] dims = new ValueNode[rank]; | |
959 for (int i = rank - 1; i >= 0; i--) { | |
960 dims[i] = frameState.ipop(); | |
961 } | |
962 if (type instanceof ResolvedJavaType) { | |
13938
aa8fb1cb16d1
Make graph builder more extensible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13798
diff
changeset
|
963 frameState.apush(append(createNewMultiArray((ResolvedJavaType) type, dims))); |
13585 | 964 } else { |
965 handleUnresolvedNewMultiArray(type, dims); | |
966 } | |
967 } | |
13133
dfb8de11d1bf
Make graph builder more extensible by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
968 |
13938
aa8fb1cb16d1
Make graph builder more extensible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13798
diff
changeset
|
969 protected NewMultiArrayNode createNewMultiArray(ResolvedJavaType type, ValueNode[] dimensions) { |
aa8fb1cb16d1
Make graph builder more extensible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13798
diff
changeset
|
970 return new NewMultiArrayNode(type, dimensions); |
aa8fb1cb16d1
Make graph builder more extensible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13798
diff
changeset
|
971 } |
aa8fb1cb16d1
Make graph builder more extensible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13798
diff
changeset
|
972 |
13585 | 973 private void genGetField(JavaField field) { |
974 emitExplicitExceptions(frameState.peek(0), null); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
975 |
13585 | 976 Kind kind = field.getKind(); |
977 ValueNode receiver = frameState.apop(); | |
978 if ((field instanceof ResolvedJavaField) && ((ResolvedJavaField) field).getDeclaringClass().isInitialized()) { | |
979 appendOptimizedLoadField(kind, new LoadFieldNode(receiver, (ResolvedJavaField) field)); | |
980 } else { | |
981 handleUnresolvedLoadField(field, receiver); | |
982 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
983 } |
13585 | 984 |
985 public static class ExceptionInfo { | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
986 |
13585 | 987 public final FixedWithNextNode exceptionEdge; |
988 public final ValueNode exception; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
989 |
13585 | 990 public ExceptionInfo(FixedWithNextNode exceptionEdge, ValueNode exception) { |
991 this.exceptionEdge = exceptionEdge; | |
992 this.exception = exception; | |
993 } | |
994 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
995 |
13585 | 996 private void emitNullCheck(ValueNode receiver) { |
997 if (ObjectStamp.isObjectNonNull(receiver.stamp())) { | |
998 return; | |
999 } | |
1000 BlockPlaceholderNode trueSucc = currentGraph.add(new BlockPlaceholderNode(this)); | |
1001 BlockPlaceholderNode falseSucc = currentGraph.add(new BlockPlaceholderNode(this)); | |
1002 append(new IfNode(currentGraph.unique(new IsNullNode(receiver)), trueSucc, falseSucc, 0.01)); | |
1003 lastInstr = falseSucc; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1004 |
13585 | 1005 if (OmitHotExceptionStacktrace.getValue()) { |
1006 ValueNode exception = ConstantNode.forObject(cachedNullPointerException, metaAccess, currentGraph); | |
1007 trueSucc.setNext(handleException(exception, bci())); | |
1008 } else { | |
1009 DeferredForeignCallNode call = currentGraph.add(new DeferredForeignCallNode(CREATE_NULL_POINTER_EXCEPTION)); | |
14045
7b5269608cb3
put tighter types on some builtin operations
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14024
diff
changeset
|
1010 call.setStamp(StampFactory.exactNonNull(metaAccess.lookupJavaType(CREATE_NULL_POINTER_EXCEPTION.getResultType()))); |
13585 | 1011 call.setStateAfter(frameState.create(bci())); |
1012 trueSucc.setNext(call); | |
1013 call.setNext(handleException(call, bci())); | |
1014 } | |
6552
3cd6c6743a6a
Do not generate null check for values already proven to be non-null.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
1015 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1016 |
13585 | 1017 private static final ArrayIndexOutOfBoundsException cachedArrayIndexOutOfBoundsException = new ArrayIndexOutOfBoundsException(); |
1018 private static final NullPointerException cachedNullPointerException = new NullPointerException(); | |
1019 static { | |
1020 cachedArrayIndexOutOfBoundsException.setStackTrace(new StackTraceElement[0]); | |
1021 cachedNullPointerException.setStackTrace(new StackTraceElement[0]); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1022 } |
13585 | 1023 |
1024 private void emitBoundsCheck(ValueNode index, ValueNode length) { | |
1025 BlockPlaceholderNode trueSucc = currentGraph.add(new BlockPlaceholderNode(this)); | |
1026 BlockPlaceholderNode falseSucc = currentGraph.add(new BlockPlaceholderNode(this)); | |
1027 append(new IfNode(currentGraph.unique(new IntegerBelowThanNode(index, length)), trueSucc, falseSucc, 0.99)); | |
1028 lastInstr = trueSucc; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1029 |
13585 | 1030 if (OmitHotExceptionStacktrace.getValue()) { |
1031 ValueNode exception = ConstantNode.forObject(cachedArrayIndexOutOfBoundsException, metaAccess, currentGraph); | |
1032 falseSucc.setNext(handleException(exception, bci())); | |
1033 } else { | |
1034 DeferredForeignCallNode call = currentGraph.add(new DeferredForeignCallNode(CREATE_OUT_OF_BOUNDS_EXCEPTION, index)); | |
14045
7b5269608cb3
put tighter types on some builtin operations
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14024
diff
changeset
|
1035 call.setStamp(StampFactory.exactNonNull(metaAccess.lookupJavaType(CREATE_OUT_OF_BOUNDS_EXCEPTION.getResultType()))); |
13585 | 1036 call.setStateAfter(frameState.create(bci())); |
1037 falseSucc.setNext(call); | |
1038 call.setNext(handleException(call, bci())); | |
1039 } | |
1040 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1041 |
14016
555867401850
Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14000
diff
changeset
|
1042 private static final DebugMetric EXPLICIT_EXCEPTIONS = Debug.metric("ExplicitExceptions"); |
555867401850
Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14000
diff
changeset
|
1043 |
13585 | 1044 protected void emitExplicitExceptions(ValueNode receiver, ValueNode outOfBoundsIndex) { |
1045 assert receiver != null; | |
1046 if (graphBuilderConfig.omitAllExceptionEdges() || (optimisticOpts.useExceptionProbabilityForOperations() && profilingInfo.getExceptionSeen(bci()) == TriState.FALSE)) { | |
1047 return; | |
1048 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1049 |
13585 | 1050 emitNullCheck(receiver); |
1051 if (outOfBoundsIndex != null) { | |
1052 ValueNode length = append(new ArrayLengthNode(receiver)); | |
1053 emitBoundsCheck(outOfBoundsIndex, length); | |
1054 } | |
14016
555867401850
Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14000
diff
changeset
|
1055 EXPLICIT_EXCEPTIONS.increment(); |
5256
1e153fdac9fb
Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5255
diff
changeset
|
1056 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1057 |
13585 | 1058 private void genPutField(JavaField field) { |
1059 emitExplicitExceptions(frameState.peek(1), null); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1060 |
13585 | 1061 ValueNode value = frameState.pop(field.getKind().getStackKind()); |
1062 ValueNode receiver = frameState.apop(); | |
1063 if (field instanceof ResolvedJavaField && ((ResolvedJavaField) field).getDeclaringClass().isInitialized()) { | |
1064 appendOptimizedStoreField(new StoreFieldNode(receiver, (ResolvedJavaField) field, value)); | |
1065 } else { | |
1066 handleUnresolvedStoreField(field, value, receiver); | |
1067 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1068 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1069 |
13585 | 1070 private void genGetStatic(JavaField field) { |
1071 Kind kind = field.getKind(); | |
1072 if (field instanceof ResolvedJavaField && ((ResolvedJavaType) field.getDeclaringClass()).isInitialized()) { | |
1073 appendOptimizedLoadField(kind, new LoadFieldNode(null, (ResolvedJavaField) field)); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1074 } else { |
13585 | 1075 handleUnresolvedLoadField(field, null); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1076 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1077 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1078 |
13585 | 1079 private void genPutStatic(JavaField field) { |
1080 ValueNode value = frameState.pop(field.getKind().getStackKind()); | |
1081 if (field instanceof ResolvedJavaField && ((ResolvedJavaType) field.getDeclaringClass()).isInitialized()) { | |
1082 appendOptimizedStoreField(new StoreFieldNode(null, (ResolvedJavaField) field, value)); | |
1083 } else { | |
1084 handleUnresolvedStoreField(field, value, null); | |
8945
7ef66078d837
add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents:
8660
diff
changeset
|
1085 } |
7ef66078d837
add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents:
8660
diff
changeset
|
1086 } |
7ef66078d837
add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents:
8660
diff
changeset
|
1087 |
13585 | 1088 private void appendOptimizedStoreField(StoreFieldNode store) { |
1089 append(store); | |
1090 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1091 |
13585 | 1092 private void appendOptimizedLoadField(Kind kind, LoadFieldNode load) { |
1093 // append the load to the instruction | |
1094 ValueNode optimized = append(load); | |
1095 frameState.push(kind.getStackKind(), optimized); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1096 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1097 |
13585 | 1098 private void genInvokeStatic(JavaMethod target) { |
1099 if (target instanceof ResolvedJavaMethod) { | |
1100 ResolvedJavaMethod resolvedTarget = (ResolvedJavaMethod) target; | |
1101 ResolvedJavaType holder = resolvedTarget.getDeclaringClass(); | |
1102 if (!holder.isInitialized() && ResolveClassBeforeStaticInvoke.getValue()) { | |
1103 handleUnresolvedInvoke(target, InvokeKind.Static); | |
1104 } else { | |
1105 ValueNode[] args = frameState.popArguments(resolvedTarget.getSignature().getParameterSlots(false), resolvedTarget.getSignature().getParameterCount(false)); | |
1106 appendInvoke(InvokeKind.Static, resolvedTarget, args); | |
1107 } | |
1108 } else { | |
1109 handleUnresolvedInvoke(target, InvokeKind.Static); | |
11265 | 1110 } |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5425
diff
changeset
|
1111 } |
13585 | 1112 |
1113 private void genInvokeInterface(JavaMethod target) { | |
1114 if (target instanceof ResolvedJavaMethod) { | |
1115 ValueNode[] args = frameState.popArguments(target.getSignature().getParameterSlots(true), target.getSignature().getParameterCount(true)); | |
1116 genInvokeIndirect(InvokeKind.Interface, (ResolvedJavaMethod) target, args); | |
1117 } else { | |
1118 handleUnresolvedInvoke(target, InvokeKind.Interface); | |
1119 } | |
1120 } | |
1121 | |
1122 private void genInvokeDynamic(JavaMethod target) { | |
1123 if (target instanceof ResolvedJavaMethod) { | |
1124 Object appendix = constantPool.lookupAppendix(stream.readCPI4(), Bytecodes.INVOKEDYNAMIC); | |
1125 if (appendix != null) { | |
1126 frameState.apush(ConstantNode.forObject(appendix, metaAccess, currentGraph)); | |
1127 } | |
1128 ValueNode[] args = frameState.popArguments(target.getSignature().getParameterSlots(false), target.getSignature().getParameterCount(false)); | |
1129 appendInvoke(InvokeKind.Static, (ResolvedJavaMethod) target, args); | |
1130 } else { | |
1131 handleUnresolvedInvoke(target, InvokeKind.Static); | |
9837
59d799c965c9
Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9793
diff
changeset
|
1132 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1133 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1134 |
13585 | 1135 private void genInvokeVirtual(JavaMethod target) { |
1136 if (target instanceof ResolvedJavaMethod) { | |
1137 /* | |
1138 * Special handling for runtimes that rewrite an invocation of | |
1139 * MethodHandle.invoke(...) or MethodHandle.invokeExact(...) to a static adapter. | |
1140 * HotSpot does this - see | |
1141 * https://wikis.oracle.com/display/HotSpotInternals/Method+handles | |
1142 * +and+invokedynamic | |
1143 */ | |
1144 boolean hasReceiver = !isStatic(((ResolvedJavaMethod) target).getModifiers()); | |
1145 Object appendix = constantPool.lookupAppendix(stream.readCPI(), Bytecodes.INVOKEVIRTUAL); | |
1146 if (appendix != null) { | |
1147 frameState.apush(ConstantNode.forObject(appendix, metaAccess, currentGraph)); | |
1148 } | |
1149 ValueNode[] args = frameState.popArguments(target.getSignature().getParameterSlots(hasReceiver), target.getSignature().getParameterCount(hasReceiver)); | |
1150 if (hasReceiver) { | |
1151 genInvokeIndirect(InvokeKind.Virtual, (ResolvedJavaMethod) target, args); | |
1152 } else { | |
1153 appendInvoke(InvokeKind.Static, (ResolvedJavaMethod) target, args); | |
1154 } | |
1155 } else { | |
1156 handleUnresolvedInvoke(target, InvokeKind.Virtual); | |
1157 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1158 |
5256
1e153fdac9fb
Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5255
diff
changeset
|
1159 } |
1e153fdac9fb
Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5255
diff
changeset
|
1160 |
13585 | 1161 private void genInvokeSpecial(JavaMethod target) { |
1162 if (target instanceof ResolvedJavaMethod) { | |
1163 assert target != null; | |
1164 assert target.getSignature() != null; | |
1165 ValueNode[] args = frameState.popArguments(target.getSignature().getParameterSlots(true), target.getSignature().getParameterCount(true)); | |
1166 invokeDirect((ResolvedJavaMethod) target, args); | |
1167 } else { | |
1168 handleUnresolvedInvoke(target, InvokeKind.Special); | |
11319
602a25aade24
GraphBuilderPhase: Insert explicit null checks for invokes if an exception has been seen
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11314
diff
changeset
|
1169 } |
9389
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9322
diff
changeset
|
1170 } |
13496
a245e3585ad4
Make invoke node creation overrideable by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13342
diff
changeset
|
1171 |
13585 | 1172 private void genInvokeIndirect(InvokeKind invokeKind, ResolvedJavaMethod target, ValueNode[] args) { |
1173 ValueNode receiver = args[0]; | |
1174 // attempt to devirtualize the call | |
1175 ResolvedJavaType klass = target.getDeclaringClass(); | |
13221
d5c6d9beebe3
graph builder: fixed wrong liveness of locals in ExceptionObject?s frame state
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13148
diff
changeset
|
1176 |
13585 | 1177 // 0. check for trivial cases |
1178 if (target.canBeStaticallyBound()) { | |
1179 // check for trivial cases (e.g. final methods, nonvirtual methods) | |
1180 invokeDirect(target, args); | |
1181 return; | |
1182 } | |
1183 // 1. check if the exact type of the receiver can be determined | |
1184 ResolvedJavaType exact = klass.asExactType(); | |
1185 if (exact == null && receiver.stamp() instanceof ObjectStamp) { | |
1186 ObjectStamp receiverStamp = (ObjectStamp) receiver.stamp(); | |
1187 if (receiverStamp.isExactType()) { | |
1188 exact = receiverStamp.type(); | |
1189 } | |
1190 } | |
1191 if (exact != null) { | |
1192 // either the holder class is exact, or the receiver object has an exact type | |
1193 ResolvedJavaMethod exactMethod = exact.resolveMethod(target); | |
1194 if (exactMethod != null) { | |
1195 invokeDirect(exactMethod, args); | |
1196 return; | |
1197 } | |
1198 } | |
1199 // devirtualization failed, produce an actual invokevirtual | |
1200 appendInvoke(invokeKind, target, args); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1201 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1202 |
13585 | 1203 private void invokeDirect(ResolvedJavaMethod target, ValueNode[] args) { |
1204 appendInvoke(InvokeKind.Special, target, args); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1205 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1206 |
13585 | 1207 private void appendInvoke(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] args) { |
1208 Kind resultType = targetMethod.getSignature().getReturnKind(); | |
1209 if (DeoptALot.getValue()) { | |
1210 append(new DeoptimizeNode(DeoptimizationAction.None, RuntimeConstraint)); | |
1211 frameState.pushReturn(resultType, ConstantNode.defaultForKind(resultType, currentGraph)); | |
1212 return; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1213 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1214 |
13585 | 1215 JavaType returnType = targetMethod.getSignature().getReturnType(method.getDeclaringClass()); |
1216 if (graphBuilderConfig.eagerResolving()) { | |
1217 returnType = returnType.resolve(targetMethod.getDeclaringClass()); | |
5146
25903e52af48
Add assertion around probabilities, and fix potential problem in ComputeProbabilityPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5130
diff
changeset
|
1218 } |
13585 | 1219 if (invokeKind != InvokeKind.Static) { |
1220 emitExplicitExceptions(args[0], null); | |
1221 if (invokeKind != InvokeKind.Special && this.optimisticOpts.useTypeCheckHints()) { | |
1222 JavaTypeProfile profile = profilingInfo.getTypeProfile(bci()); | |
1223 args[0] = TypeProfileProxyNode.create(args[0], profile); | |
1224 } | |
1225 } | |
1226 MethodCallTargetNode callTarget = currentGraph.add(createMethodCallTarget(invokeKind, targetMethod, args, returnType)); | |
5146
25903e52af48
Add assertion around probabilities, and fix potential problem in ComputeProbabilityPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5130
diff
changeset
|
1227 |
13585 | 1228 // be conservative if information was not recorded (could result in endless recompiles |
1229 // otherwise) | |
1230 if (graphBuilderConfig.omitAllExceptionEdges() || (optimisticOpts.useExceptionProbability() && profilingInfo.getExceptionSeen(bci()) == TriState.FALSE)) { | |
1231 createInvoke(callTarget, resultType); | |
1232 } else { | |
1233 assert bci() == currentBlock.endBci; | |
14533
e5235120893c
split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14521
diff
changeset
|
1234 frameState.clearNonLiveLocals(currentBlock, liveness, false); |
7705
96a596d751ab
remove successorProbabilities from SwitchNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7661
diff
changeset
|
1235 |
13585 | 1236 InvokeWithExceptionNode invoke = createInvokeWithException(callTarget, resultType); |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5695
diff
changeset
|
1237 |
13585 | 1238 Block nextBlock = currentBlock.successors.get(0); |
1239 invoke.setNext(createTarget(nextBlock, frameState)); | |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5695
diff
changeset
|
1240 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5695
diff
changeset
|
1241 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1242 |
13585 | 1243 protected MethodCallTargetNode createMethodCallTarget(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] args, JavaType returnType) { |
1244 return new MethodCallTargetNode(invokeKind, targetMethod, args, returnType); | |
1245 } | |
1246 | |
1247 protected InvokeNode createInvoke(CallTargetNode callTarget, Kind resultType) { | |
1248 InvokeNode invoke = append(new InvokeNode(callTarget, bci())); | |
1249 frameState.pushReturn(resultType, invoke); | |
1250 return invoke; | |
1251 } | |
1252 | |
1253 protected InvokeWithExceptionNode createInvokeWithException(CallTargetNode callTarget, Kind resultType) { | |
1254 DispatchBeginNode exceptionEdge = handleException(null, bci()); | |
1255 InvokeWithExceptionNode invoke = append(new InvokeWithExceptionNode(callTarget, exceptionEdge, bci())); | |
1256 frameState.pushReturn(resultType, invoke); | |
1257 Block nextBlock = currentBlock.successors.get(0); | |
1258 invoke.setStateAfter(frameState.create(nextBlock.startBci)); | |
1259 return invoke; | |
1260 } | |
1261 | |
1262 private void genReturn(ValueNode x) { | |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13585
diff
changeset
|
1263 frameState.setRethrowException(false); |
13585 | 1264 frameState.clearStack(); |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13585
diff
changeset
|
1265 if (graphBuilderConfig.eagerInfopointMode()) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13585
diff
changeset
|
1266 append(new InfopointNode(InfopointReason.METHOD_END, frameState.create(bci()))); |
13585 | 1267 } |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13585
diff
changeset
|
1268 |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13585
diff
changeset
|
1269 synchronizedEpilogue(FrameState.AFTER_BCI, x); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13585
diff
changeset
|
1270 if (frameState.lockDepth() != 0) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13585
diff
changeset
|
1271 throw new BailoutException("unbalanced monitors"); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13585
diff
changeset
|
1272 } |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13585
diff
changeset
|
1273 |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13585
diff
changeset
|
1274 append(new ReturnNode(x)); |
13585 | 1275 } |
1276 | |
1277 private MonitorEnterNode genMonitorEnter(ValueNode x) { | |
1278 MonitorIdNode monitorId = currentGraph.add(new MonitorIdNode(frameState.lockDepth())); | |
1279 MonitorEnterNode monitorEnter = append(new MonitorEnterNode(x, monitorId)); | |
1280 frameState.pushLock(x, monitorId); | |
1281 return monitorEnter; | |
1282 } | |
1283 | |
1284 private MonitorExitNode genMonitorExit(ValueNode x, ValueNode returnValue) { | |
1285 MonitorIdNode monitorId = frameState.peekMonitorId(); | |
1286 ValueNode lockedObject = frameState.popLock(); | |
1287 if (GraphUtil.originalValue(lockedObject) != GraphUtil.originalValue(x)) { | |
1288 throw new BailoutException("unbalanced monitors: mismatch at monitorexit, %s != %s", GraphUtil.originalValue(x), GraphUtil.originalValue(lockedObject)); | |
1289 } | |
1290 MonitorExitNode monitorExit = append(new MonitorExitNode(x, monitorId, returnValue)); | |
1291 return monitorExit; | |
1292 } | |
1293 | |
1294 private void genJsr(int dest) { | |
1295 Block successor = currentBlock.jsrSuccessor; | |
1296 assert successor.startBci == dest : successor.startBci + " != " + dest + " @" + bci(); | |
1297 JsrScope scope = currentBlock.jsrScope; | |
1298 if (!successor.jsrScope.pop().equals(scope)) { | |
1299 throw new JsrNotSupportedBailout("unstructured control flow (internal limitation)"); | |
1300 } | |
1301 if (successor.jsrScope.nextReturnAddress() != stream().nextBCI()) { | |
1302 throw new JsrNotSupportedBailout("unstructured control flow (internal limitation)"); | |
1303 } | |
1304 frameState.push(Kind.Int, ConstantNode.forInt(stream().nextBCI(), currentGraph)); | |
1305 appendGoto(createTarget(successor, frameState)); | |
1306 } | |
1307 | |
1308 private void genRet(int localIndex) { | |
1309 Block successor = currentBlock.retSuccessor; | |
1310 ValueNode local = frameState.loadLocal(localIndex); | |
1311 JsrScope scope = currentBlock.jsrScope; | |
1312 int retAddress = scope.nextReturnAddress(); | |
1313 append(new FixedGuardNode(currentGraph.unique(new IntegerEqualsNode(local, ConstantNode.forInt(retAddress, currentGraph))), JavaSubroutineMismatch, InvalidateReprofile)); | |
1314 if (!successor.jsrScope.equals(scope.pop())) { | |
1315 throw new JsrNotSupportedBailout("unstructured control flow (ret leaves more than one scope)"); | |
1316 } | |
1317 appendGoto(createTarget(successor, frameState)); | |
1318 } | |
1319 | |
1320 private double[] switchProbability(int numberOfCases, int bci) { | |
1321 double[] prob = profilingInfo.getSwitchProbabilities(bci); | |
1322 if (prob != null) { | |
1323 assert prob.length == numberOfCases; | |
1324 } else { | |
1325 Debug.log("Missing probability (switch) in %s at bci %d", method, bci); | |
1326 prob = new double[numberOfCases]; | |
1327 for (int i = 0; i < numberOfCases; i++) { | |
1328 prob[i] = 1.0d / numberOfCases; | |
1329 } | |
1330 } | |
1331 assert allPositive(prob); | |
1332 return prob; | |
1333 } | |
1334 | |
1335 private static boolean allPositive(double[] a) { | |
1336 for (double d : a) { | |
1337 if (d < 0) { | |
1338 return false; | |
1339 } | |
1340 } | |
1341 return true; | |
1342 } | |
1343 | |
1344 /** | |
1345 * Helper function that sums up the probabilities of all keys that lead to a specific | |
1346 * successor. | |
1347 * | |
1348 * @return an array of size successorCount with the accumulated probability for each | |
1349 * successor. | |
1350 */ | |
1351 private static double[] successorProbabilites(int successorCount, int[] keySuccessors, double[] keyProbabilities) { | |
1352 double[] probability = new double[successorCount]; | |
1353 for (int i = 0; i < keySuccessors.length; i++) { | |
1354 probability[keySuccessors[i]] += keyProbabilities[i]; | |
1355 } | |
1356 return probability; | |
1357 } | |
1358 | |
1359 private void genSwitch(BytecodeSwitch bs) { | |
1360 int bci = bci(); | |
1361 ValueNode value = frameState.ipop(); | |
1362 | |
1363 int nofCases = bs.numberOfCases(); | |
1364 double[] keyProbabilities = switchProbability(nofCases + 1, bci); | |
1365 | |
1366 Map<Integer, SuccessorInfo> bciToBlockSuccessorIndex = new HashMap<>(); | |
1367 for (int i = 0; i < currentBlock.successors.size(); i++) { | |
1368 assert !bciToBlockSuccessorIndex.containsKey(currentBlock.successors.get(i).startBci); | |
1369 if (!bciToBlockSuccessorIndex.containsKey(currentBlock.successors.get(i).startBci)) { | |
1370 bciToBlockSuccessorIndex.put(currentBlock.successors.get(i).startBci, new SuccessorInfo(i)); | |
1371 } | |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6699
diff
changeset
|
1372 } |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5695
diff
changeset
|
1373 |
13585 | 1374 ArrayList<Block> actualSuccessors = new ArrayList<>(); |
1375 int[] keys = new int[nofCases]; | |
1376 int[] keySuccessors = new int[nofCases + 1]; | |
1377 int deoptSuccessorIndex = -1; | |
1378 int nextSuccessorIndex = 0; | |
1379 for (int i = 0; i < nofCases + 1; i++) { | |
1380 if (i < nofCases) { | |
1381 keys[i] = bs.keyAt(i); | |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6699
diff
changeset
|
1382 } |
13585 | 1383 |
1384 if (isNeverExecutedCode(keyProbabilities[i])) { | |
1385 if (deoptSuccessorIndex < 0) { | |
1386 deoptSuccessorIndex = nextSuccessorIndex++; | |
1387 actualSuccessors.add(null); | |
1388 } | |
1389 keySuccessors[i] = deoptSuccessorIndex; | |
1390 } else { | |
1391 int targetBci = i >= nofCases ? bs.defaultTarget() : bs.targetAt(i); | |
1392 SuccessorInfo info = bciToBlockSuccessorIndex.get(targetBci); | |
1393 if (info.actualIndex < 0) { | |
1394 info.actualIndex = nextSuccessorIndex++; | |
1395 actualSuccessors.add(currentBlock.successors.get(info.blockIndex)); | |
1396 } | |
1397 keySuccessors[i] = info.actualIndex; | |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6699
diff
changeset
|
1398 } |
13585 | 1399 } |
1400 | |
1401 double[] successorProbabilities = successorProbabilites(actualSuccessors.size(), keySuccessors, keyProbabilities); | |
1402 IntegerSwitchNode switchNode = append(new IntegerSwitchNode(value, actualSuccessors.size(), keys, keyProbabilities, keySuccessors)); | |
1403 for (int i = 0; i < actualSuccessors.size(); i++) { | |
1404 switchNode.setBlockSuccessor(i, createBlockTarget(successorProbabilities[i], actualSuccessors.get(i), frameState)); | |
1405 } | |
1406 | |
1407 } | |
1408 | |
1409 private static class SuccessorInfo { | |
1410 | |
1411 int blockIndex; | |
1412 int actualIndex; | |
1413 | |
1414 public SuccessorInfo(int blockSuccessorIndex) { | |
1415 this.blockIndex = blockSuccessorIndex; | |
1416 actualIndex = -1; | |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6699
diff
changeset
|
1417 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1418 } |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6699
diff
changeset
|
1419 |
13585 | 1420 protected ConstantNode appendConstant(Constant constant) { |
1421 assert constant != null; | |
1422 return ConstantNode.forConstant(constant, metaAccess, currentGraph); | |
1423 } | |
1424 | |
1425 private <T extends ControlSinkNode> T append(T fixed) { | |
1426 assert !fixed.isAlive() && !fixed.isDeleted() : "instruction should not have been appended yet"; | |
1427 assert lastInstr.next() == null : "cannot append instruction to instruction which isn't end (" + lastInstr + "->" + lastInstr.next() + ")"; | |
1428 T added = currentGraph.add(fixed); | |
1429 lastInstr.setNext(added); | |
1430 lastInstr = null; | |
1431 return added; | |
1432 } | |
1433 | |
1434 private <T extends ControlSplitNode> T append(T fixed) { | |
1435 assert !fixed.isAlive() && !fixed.isDeleted() : "instruction should not have been appended yet"; | |
1436 assert lastInstr.next() == null : "cannot append instruction to instruction which isn't end (" + lastInstr + "->" + lastInstr.next() + ")"; | |
1437 T added = currentGraph.add(fixed); | |
1438 lastInstr.setNext(added); | |
1439 lastInstr = null; | |
1440 return added; | |
1441 } | |
1442 | |
1443 protected <T extends FixedWithNextNode> T append(T fixed) { | |
1444 assert !fixed.isAlive() && !fixed.isDeleted() : "instruction should not have been appended yet"; | |
1445 assert lastInstr.next() == null : "cannot append instruction to instruction which isn't end (" + lastInstr + "->" + lastInstr.next() + ")"; | |
1446 T added = currentGraph.add(fixed); | |
1447 lastInstr.setNext(added); | |
1448 lastInstr = added; | |
1449 return added; | |
1450 } | |
1451 | |
1452 private <T extends FloatingNode> T append(T v) { | |
1453 assert !(v instanceof ConstantNode); | |
1454 T added = currentGraph.unique(v); | |
1455 return added; | |
1456 } | |
1457 | |
1458 private static class Target { | |
1459 | |
1460 FixedNode fixed; | |
14792
b9805a622546
Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14068
diff
changeset
|
1461 HIRFrameStateBuilder state; |
13585 | 1462 |
14792
b9805a622546
Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14068
diff
changeset
|
1463 public Target(FixedNode fixed, HIRFrameStateBuilder state) { |
13585 | 1464 this.fixed = fixed; |
1465 this.state = state; | |
1466 } | |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6699
diff
changeset
|
1467 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6699
diff
changeset
|
1468 |
14792
b9805a622546
Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14068
diff
changeset
|
1469 private Target checkLoopExit(FixedNode target, Block targetBlock, HIRFrameStateBuilder state) { |
13585 | 1470 if (currentBlock != null) { |
1471 long exits = currentBlock.loops & ~targetBlock.loops; | |
1472 if (exits != 0) { | |
1473 LoopExitNode firstLoopExit = null; | |
1474 LoopExitNode lastLoopExit = null; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1475 |
13585 | 1476 int pos = 0; |
1477 ArrayList<Block> exitLoops = new ArrayList<>(Long.bitCount(exits)); | |
1478 do { | |
1479 long lMask = 1L << pos; | |
1480 if ((exits & lMask) != 0) { | |
1481 exitLoops.add(loopHeaders[pos]); | |
1482 exits &= ~lMask; | |
1483 } | |
1484 pos++; | |
1485 } while (exits != 0); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1486 |
13585 | 1487 Collections.sort(exitLoops, new Comparator<Block>() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1488 |
13585 | 1489 @Override |
1490 public int compare(Block o1, Block o2) { | |
1491 return Long.bitCount(o2.loops) - Long.bitCount(o1.loops); | |
1492 } | |
1493 }); | |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
1494 |
13585 | 1495 int bci = targetBlock.startBci; |
1496 if (targetBlock instanceof ExceptionDispatchBlock) { | |
1497 bci = ((ExceptionDispatchBlock) targetBlock).deoptBci; | |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5160
diff
changeset
|
1498 } |
14792
b9805a622546
Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14068
diff
changeset
|
1499 HIRFrameStateBuilder newState = state.copy(); |
13585 | 1500 for (Block loop : exitLoops) { |
1501 LoopBeginNode loopBegin = (LoopBeginNode) loop.firstInstruction; | |
1502 LoopExitNode loopExit = currentGraph.add(new LoopExitNode(loopBegin)); | |
1503 if (lastLoopExit != null) { | |
1504 lastLoopExit.setNext(loopExit); | |
1505 } | |
1506 if (firstLoopExit == null) { | |
1507 firstLoopExit = loopExit; | |
1508 } | |
1509 lastLoopExit = loopExit; | |
1510 Debug.log("Target %s (%s) Exits %s, scanning framestates...", targetBlock, target, loop); | |
1511 newState.insertLoopProxies(loopExit, loop.entryState); | |
1512 loopExit.setStateAfter(newState.create(bci)); | |
1513 } | |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
1514 |
13585 | 1515 lastLoopExit.setNext(target); |
1516 return new Target(firstLoopExit, newState); | |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5160
diff
changeset
|
1517 } |
13585 | 1518 } |
1519 return new Target(target, state); | |
1520 } | |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5160
diff
changeset
|
1521 |
14792
b9805a622546
Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14068
diff
changeset
|
1522 private FixedNode createTarget(double probability, Block block, HIRFrameStateBuilder stateAfter) { |
13585 | 1523 assert probability >= 0 && probability <= 1.01 : probability; |
1524 if (isNeverExecutedCode(probability)) { | |
1525 return currentGraph.add(new DeoptimizeNode(InvalidateReprofile, UnreachedCode)); | |
1526 } else { | |
1527 assert block != null; | |
1528 return createTarget(block, stateAfter); | |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5160
diff
changeset
|
1529 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5160
diff
changeset
|
1530 } |
13585 | 1531 |
1532 private boolean isNeverExecutedCode(double probability) { | |
1533 return probability == 0 && optimisticOpts.removeNeverExecutedCode() && entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI; | |
1534 } | |
1535 | |
14792
b9805a622546
Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14068
diff
changeset
|
1536 private FixedNode createTarget(Block block, HIRFrameStateBuilder state) { |
13585 | 1537 assert block != null && state != null; |
1538 assert !block.isExceptionEntry || state.stackSize() == 1; | |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5160
diff
changeset
|
1539 |
13585 | 1540 if (block.firstInstruction == null) { |
1541 /* | |
1542 * This is the first time we see this block as a branch target. Create and return a | |
1543 * placeholder that later can be replaced with a MergeNode when we see this block | |
1544 * again. | |
1545 */ | |
1546 block.firstInstruction = currentGraph.add(new BlockPlaceholderNode(this)); | |
1547 Target target = checkLoopExit(block.firstInstruction, block, state); | |
1548 FixedNode result = target.fixed; | |
1549 block.entryState = target.state == state ? state.copy() : target.state; | |
14533
e5235120893c
split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14521
diff
changeset
|
1550 block.entryState.clearNonLiveLocals(block, liveness, true); |
13585 | 1551 |
1552 Debug.log("createTarget %s: first visit, result: %s", block, block.firstInstruction); | |
1553 return result; | |
1554 } | |
1555 | |
1556 // We already saw this block before, so we have to merge states. | |
1557 if (!block.entryState.isCompatibleWith(state)) { | |
1558 throw new BailoutException("stacks do not match; bytecodes would not verify"); | |
1559 } | |
5051
2ab527c53dba
another fix for goto's deopt case
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5050
diff
changeset
|
1560 |
13585 | 1561 if (block.firstInstruction instanceof LoopBeginNode) { |
1562 assert block.isLoopHeader && currentBlock.blockID >= block.blockID : "must be backward branch"; | |
1563 /* | |
1564 * Backward loop edge. We need to create a special LoopEndNode and merge with the | |
1565 * loop begin node created before. | |
1566 */ | |
1567 LoopBeginNode loopBegin = (LoopBeginNode) block.firstInstruction; | |
1568 Target target = checkLoopExit(currentGraph.add(new LoopEndNode(loopBegin)), block, state); | |
1569 FixedNode result = target.fixed; | |
1570 block.entryState.merge(loopBegin, target.state); | |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6699
diff
changeset
|
1571 |
13585 | 1572 Debug.log("createTarget %s: merging backward branch to loop header %s, result: %s", block, loopBegin, result); |
1573 return result; | |
1574 } | |
1575 assert currentBlock == null || currentBlock.blockID < block.blockID : "must not be backward branch"; | |
1576 assert block.firstInstruction.next() == null : "bytecodes already parsed for block"; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1577 |
13585 | 1578 if (block.firstInstruction instanceof BlockPlaceholderNode) { |
1579 /* | |
1580 * This is the second time we see this block. Create the actual MergeNode and the | |
1581 * End Node for the already existing edge. For simplicity, we leave the placeholder | |
1582 * in the graph and just append the new nodes after the placeholder. | |
1583 */ | |
1584 BlockPlaceholderNode placeholder = (BlockPlaceholderNode) block.firstInstruction; | |
1585 | |
1586 // The EndNode for the already existing edge. | |
1587 AbstractEndNode end = currentGraph.add(new EndNode()); | |
1588 // The MergeNode that replaces the placeholder. | |
1589 MergeNode mergeNode = currentGraph.add(new MergeNode()); | |
1590 FixedNode next = placeholder.next(); | |
1591 | |
1592 placeholder.setNext(end); | |
1593 mergeNode.addForwardEnd(end); | |
1594 mergeNode.setNext(next); | |
1595 | |
1596 block.firstInstruction = mergeNode; | |
1597 } | |
1598 | |
1599 MergeNode mergeNode = (MergeNode) block.firstInstruction; | |
1600 | |
1601 // The EndNode for the newly merged edge. | |
1602 AbstractEndNode newEnd = currentGraph.add(new EndNode()); | |
1603 Target target = checkLoopExit(newEnd, block, state); | |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5160
diff
changeset
|
1604 FixedNode result = target.fixed; |
13585 | 1605 block.entryState.merge(mergeNode, target.state); |
1606 mergeNode.addForwardEnd(newEnd); | |
5026
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4997
diff
changeset
|
1607 |
13585 | 1608 Debug.log("createTarget %s: merging state, result: %s", block, result); |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5160
diff
changeset
|
1609 return result; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1610 } |
5026
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4997
diff
changeset
|
1611 |
13585 | 1612 /** |
1613 * Returns a block begin node with the specified state. If the specified probability is 0, | |
1614 * the block deoptimizes immediately. | |
1615 */ | |
14792
b9805a622546
Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14068
diff
changeset
|
1616 private AbstractBeginNode createBlockTarget(double probability, Block block, HIRFrameStateBuilder stateAfter) { |
13585 | 1617 FixedNode target = createTarget(probability, block, stateAfter); |
1618 AbstractBeginNode begin = AbstractBeginNode.begin(target); | |
1619 | |
1620 assert !(target instanceof DeoptimizeNode && begin.stateAfter() != null) : "We are not allowed to set the stateAfter of the begin node, because we have to deoptimize " | |
1621 + "to a bci _before_ the actual if, so that the interpreter can update the profiling information."; | |
1622 return begin; | |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4554
diff
changeset
|
1623 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4554
diff
changeset
|
1624 |
14792
b9805a622546
Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14068
diff
changeset
|
1625 private ValueNode synchronizedObject(HIRFrameStateBuilder state, ResolvedJavaMethod target) { |
13585 | 1626 if (isStatic(target.getModifiers())) { |
1627 return appendConstant(target.getDeclaringClass().getEncoding(Representation.JavaClass)); | |
1628 } else { | |
1629 return state.loadLocal(0); | |
1630 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1631 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1632 |
13585 | 1633 private void processBlock(Block block) { |
1634 // Ignore blocks that have no predecessors by the time their bytecodes are parsed | |
1635 if (block == null || block.firstInstruction == null) { | |
1636 Debug.log("Ignoring block %s", block); | |
1637 return; | |
1638 } | |
1639 Indent indent = Debug.logAndIndent("Parsing block %s firstInstruction: %s loopHeader: %b", block, block.firstInstruction, block.isLoopHeader); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1640 |
13585 | 1641 lastInstr = block.firstInstruction; |
1642 frameState = block.entryState; | |
1643 currentBlock = block; | |
5029
74f47ef37394
Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5026
diff
changeset
|
1644 |
13585 | 1645 frameState.cleanupDeletedPhis(); |
1646 if (lastInstr instanceof MergeNode) { | |
1647 int bci = block.startBci; | |
1648 if (block instanceof ExceptionDispatchBlock) { | |
1649 bci = ((ExceptionDispatchBlock) block).deoptBci; | |
1650 } | |
1651 ((MergeNode) lastInstr).setStateAfter(frameState.create(bci)); | |
1652 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1653 |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13585
diff
changeset
|
1654 if (block == unwindBlock) { |
13585 | 1655 frameState.setRethrowException(false); |
1656 createUnwind(); | |
1657 } else if (block instanceof ExceptionDispatchBlock) { | |
1658 createExceptionDispatch((ExceptionDispatchBlock) block); | |
1659 } else { | |
1660 frameState.setRethrowException(false); | |
1661 iterateBytecodesForBlock(block); | |
5026
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4997
diff
changeset
|
1662 } |
13585 | 1663 indent.outdent(); |
5026
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4997
diff
changeset
|
1664 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1665 |
13585 | 1666 private void connectLoopEndToBegin() { |
1667 for (LoopBeginNode begin : currentGraph.getNodes(LoopBeginNode.class)) { | |
1668 if (begin.loopEnds().isEmpty()) { | |
1669 // @formatter:off | |
5026
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4997
diff
changeset
|
1670 // Remove loop header without loop ends. |
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4997
diff
changeset
|
1671 // This can happen with degenerated loops like this one: |
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4997
diff
changeset
|
1672 // for (;;) { |
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4997
diff
changeset
|
1673 // try { |
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4997
diff
changeset
|
1674 // break; |
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4997
diff
changeset
|
1675 // } catch (UnresolvedException iioe) { |
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4997
diff
changeset
|
1676 // } |
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4997
diff
changeset
|
1677 // } |
7522
4cc0efe5cffe
disabled auto-formatting of manually formatted code
Doug Simon <doug.simon@oracle.com>
parents:
7305
diff
changeset
|
1678 // @formatter:on |
13585 | 1679 assert begin.forwardEndCount() == 1; |
1680 currentGraph.reduceDegenerateLoopBegin(begin); | |
1681 } else { | |
1682 GraphUtil.normalizeLoopBegin(begin); | |
4548
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4541
diff
changeset
|
1683 } |
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4541
diff
changeset
|
1684 } |
5256
1e153fdac9fb
Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5255
diff
changeset
|
1685 } |
4548
f55914bc1d67
Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4541
diff
changeset
|
1686 |
13585 | 1687 private void createUnwind() { |
1688 assert frameState.stackSize() == 1 : frameState; | |
1689 ValueNode exception = frameState.apop(); | |
1690 append(new FixedGuardNode(currentGraph.unique(new IsNullNode(exception)), NullCheckException, InvalidateReprofile, true)); | |
1691 synchronizedEpilogue(FrameState.AFTER_EXCEPTION_BCI, null); | |
1692 append(new UnwindNode(exception)); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1693 } |
13585 | 1694 |
1695 private void synchronizedEpilogue(int bci, ValueNode returnValue) { | |
1696 if (Modifier.isSynchronized(method.getModifiers())) { | |
1697 MonitorExitNode monitorExit = genMonitorExit(methodSynchronizedObject, returnValue); | |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13585
diff
changeset
|
1698 if (returnValue != null) { |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
1699 frameState.push(returnValue.getKind(), returnValue); |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13585
diff
changeset
|
1700 } |
13585 | 1701 monitorExit.setStateAfter(frameState.create(bci)); |
1702 assert !frameState.rethrowException(); | |
1703 } | |
1704 } | |
5026
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4997
diff
changeset
|
1705 |
13585 | 1706 private void createExceptionDispatch(ExceptionDispatchBlock block) { |
1707 assert frameState.stackSize() == 1 : frameState; | |
1708 if (block.handler.isCatchAll()) { | |
1709 assert block.successors.size() == 1; | |
1710 appendGoto(createTarget(block.successors.get(0), frameState)); | |
1711 return; | |
1712 } | |
5026
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4997
diff
changeset
|
1713 |
13585 | 1714 JavaType catchType = block.handler.getCatchType(); |
1715 if (graphBuilderConfig.eagerResolving()) { | |
1716 catchType = lookupType(block.handler.catchTypeCPI(), INSTANCEOF); | |
1717 } | |
1718 boolean initialized = (catchType instanceof ResolvedJavaType); | |
1719 if (initialized && graphBuilderConfig.getSkippedExceptionTypes() != null) { | |
1720 ResolvedJavaType resolvedCatchType = (ResolvedJavaType) catchType; | |
1721 for (ResolvedJavaType skippedType : graphBuilderConfig.getSkippedExceptionTypes()) { | |
1722 if (skippedType.isAssignableFrom(resolvedCatchType)) { | |
13791
2a43fba3d039
fix handling of skipped exceptions (must not cut off other exception types or unwind)
Andreas Woess <andreas.woess@jku.at>
parents:
13692
diff
changeset
|
1723 Block nextBlock = block.successors.size() == 1 ? unwindBlock(block.deoptBci) : block.successors.get(1); |
2a43fba3d039
fix handling of skipped exceptions (must not cut off other exception types or unwind)
Andreas Woess <andreas.woess@jku.at>
parents:
13692
diff
changeset
|
1724 ValueNode exception = frameState.stackAt(0); |
2a43fba3d039
fix handling of skipped exceptions (must not cut off other exception types or unwind)
Andreas Woess <andreas.woess@jku.at>
parents:
13692
diff
changeset
|
1725 FixedNode trueSuccessor = currentGraph.add(new DeoptimizeNode(InvalidateReprofile, UnreachedCode)); |
2a43fba3d039
fix handling of skipped exceptions (must not cut off other exception types or unwind)
Andreas Woess <andreas.woess@jku.at>
parents:
13692
diff
changeset
|
1726 FixedNode nextDispatch = createTarget(nextBlock, frameState); |
2a43fba3d039
fix handling of skipped exceptions (must not cut off other exception types or unwind)
Andreas Woess <andreas.woess@jku.at>
parents:
13692
diff
changeset
|
1727 append(new IfNode(currentGraph.unique(new InstanceOfNode((ResolvedJavaType) catchType, exception, null)), trueSuccessor, nextDispatch, 0)); |
13585 | 1728 return; |
1729 } | |
9003
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8660
diff
changeset
|
1730 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8660
diff
changeset
|
1731 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8660
diff
changeset
|
1732 |
13798
5318db77ec76
GraphBuilderPhase: remove unused constant added by createExceptionDispatch
Andreas Woess <andreas.woess@jku.at>
parents:
13791
diff
changeset
|
1733 if (initialized) { |
13585 | 1734 Block nextBlock = block.successors.size() == 1 ? unwindBlock(block.deoptBci) : block.successors.get(1); |
1735 ValueNode exception = frameState.stackAt(0); | |
1736 CheckCastNode checkCast = currentGraph.add(new CheckCastNode((ResolvedJavaType) catchType, exception, null, false)); | |
1737 frameState.apop(); | |
1738 frameState.push(Kind.Object, checkCast); | |
1739 FixedNode catchSuccessor = createTarget(block.successors.get(0), frameState); | |
1740 frameState.apop(); | |
1741 frameState.push(Kind.Object, exception); | |
1742 FixedNode nextDispatch = createTarget(nextBlock, frameState); | |
1743 checkCast.setNext(catchSuccessor); | |
1744 append(new IfNode(currentGraph.unique(new InstanceOfNode((ResolvedJavaType) catchType, exception, null)), checkCast, nextDispatch, 0.5)); | |
13798
5318db77ec76
GraphBuilderPhase: remove unused constant added by createExceptionDispatch
Andreas Woess <andreas.woess@jku.at>
parents:
13791
diff
changeset
|
1745 } else { |
5318db77ec76
GraphBuilderPhase: remove unused constant added by createExceptionDispatch
Andreas Woess <andreas.woess@jku.at>
parents:
13791
diff
changeset
|
1746 handleUnresolvedExceptionType(Representation.ObjectHub, catchType); |
13585 | 1747 } |
1748 } | |
1749 | |
1750 private void appendGoto(FixedNode target) { | |
1751 if (lastInstr != null) { | |
1752 lastInstr.setNext(target); | |
6676
090868cbcda6
Graal infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents:
6648
diff
changeset
|
1753 } |
13585 | 1754 } |
1755 | |
1756 private static boolean isBlockEnd(Node n) { | |
1757 return n instanceof ControlSplitNode || n instanceof ControlSinkNode; | |
1758 } | |
1759 | |
1760 private void iterateBytecodesForBlock(Block block) { | |
1761 if (block.isLoopHeader) { | |
1762 // Create the loop header block, which later will merge the backward branches of the | |
1763 // loop. | |
1764 AbstractEndNode preLoopEnd = currentGraph.add(new EndNode()); | |
1765 LoopBeginNode loopBegin = currentGraph.add(new LoopBeginNode()); | |
1766 lastInstr.setNext(preLoopEnd); | |
1767 // Add the single non-loop predecessor of the loop header. | |
1768 loopBegin.addForwardEnd(preLoopEnd); | |
1769 lastInstr = loopBegin; | |
1770 | |
1771 // Create phi functions for all local variables and operand stack slots. | |
1772 frameState.insertLoopPhis(loopBegin); | |
1773 loopBegin.setStateAfter(frameState.create(block.startBci)); | |
1774 | |
1775 /* | |
1776 * We have seen all forward branches. All subsequent backward branches will merge to | |
1777 * the loop header. This ensures that the loop header has exactly one non-loop | |
1778 * predecessor. | |
1779 */ | |
1780 block.firstInstruction = loopBegin; | |
1781 /* | |
1782 * We need to preserve the frame state builder of the loop header so that we can | |
1783 * merge values for phi functions, so make a copy of it. | |
1784 */ | |
1785 block.entryState = frameState.copy(); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1786 |
13585 | 1787 Debug.log(" created loop header %s", loopBegin); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1788 } |
13585 | 1789 assert lastInstr.next() == null : "instructions already appended at block " + block; |
1790 Debug.log(" frameState: %s", frameState); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1791 |
13585 | 1792 int endBCI = stream.endBCI(); |
1793 | |
1794 stream.setBCI(block.startBci); | |
1795 int bci = block.startBci; | |
1796 BytecodesParsed.add(block.endBci - bci); | |
1797 | |
1798 while (bci < endBCI) { | |
1799 if (graphBuilderConfig.eagerInfopointMode() && lnt != null) { | |
1800 currentLineNumber = lnt.getLineNumber(bci); | |
1801 if (currentLineNumber != previousLineNumber) { | |
1802 append(new InfopointNode(InfopointReason.LINE_NUMBER, frameState.create(bci))); | |
1803 previousLineNumber = currentLineNumber; | |
1804 } | |
1805 } | |
5256
1e153fdac9fb
Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5255
diff
changeset
|
1806 |
13585 | 1807 // read the opcode |
1808 int opcode = stream.currentBC(); | |
1809 traceState(); | |
1810 traceInstruction(bci, opcode, bci == block.startBci); | |
1811 if (bci == entryBCI) { | |
1812 if (block.jsrScope != JsrScope.EMPTY_SCOPE) { | |
1813 throw new BailoutException("OSR into a JSR scope is not supported"); | |
1814 } | |
1815 EntryMarkerNode x = append(new EntryMarkerNode()); | |
1816 frameState.insertProxies(x); | |
1817 x.setStateAfter(frameState.create(bci)); | |
1818 } | |
1819 processBytecode(bci, opcode); | |
1820 | |
1821 if (lastInstr == null || isBlockEnd(lastInstr) || lastInstr.next() != null) { | |
1822 break; | |
1823 } | |
1824 | |
1825 stream.next(); | |
1826 bci = stream.currentBCI(); | |
1827 | |
1828 if (bci > block.endBci) { | |
14533
e5235120893c
split BciBlockMapping liveness calculation into fast and slow path
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14521
diff
changeset
|
1829 frameState.clearNonLiveLocals(currentBlock, liveness, false); |
13585 | 1830 } |
1831 if (lastInstr instanceof StateSplit) { | |
1832 if (lastInstr.getClass() == AbstractBeginNode.class) { | |
1833 // BeginNodes do not need a frame state | |
1834 } else { | |
1835 StateSplit stateSplit = (StateSplit) lastInstr; | |
1836 if (stateSplit.stateAfter() == null) { | |
1837 stateSplit.setStateAfter(frameState.create(bci)); | |
1838 } | |
1839 } | |
1840 } | |
1841 if (bci < endBCI) { | |
1842 if (bci > block.endBci) { | |
1843 assert !block.successors.get(0).isExceptionEntry; | |
1844 assert block.numNormalSuccessors() == 1; | |
1845 // we fell through to the next block, add a goto and break | |
1846 appendGoto(createTarget(block.successors.get(0), frameState)); | |
1847 break; | |
5375
3035b6b881d9
removed stateAfter field from FixedWithNextNode - now only StateSplit implementations have this field
Doug Simon <doug.simon@oracle.com>
parents:
5373
diff
changeset
|
1848 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1849 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1850 } |
13585 | 1851 } |
1852 | |
1853 private final int traceLevel = Options.TraceBytecodeParserLevel.getValue(); | |
1854 | |
1855 private void traceState() { | |
1856 if (traceLevel >= TRACELEVEL_STATE && Debug.isLogEnabled()) { | |
1857 Debug.log(String.format("| state [nr locals = %d, stack depth = %d, method = %s]", frameState.localsSize(), frameState.stackSize(), method)); | |
1858 for (int i = 0; i < frameState.localsSize(); ++i) { | |
1859 ValueNode value = frameState.localAt(i); | |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
1860 Debug.log(String.format("| local[%d] = %-8s : %s", i, value == null ? "bogus" : value.getKind().getJavaName(), value)); |
13585 | 1861 } |
1862 for (int i = 0; i < frameState.stackSize(); ++i) { | |
1863 ValueNode value = frameState.stackAt(i); | |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
1864 Debug.log(String.format("| stack[%d] = %-8s : %s", i, value == null ? "bogus" : value.getKind().getJavaName(), value)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1865 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1866 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1867 } |
12683
5c5b02a165d4
moved a number of options to be declared closer to usage and cached some heavily accessed options in fields
Doug Simon <doug.simon@oracle.com>
parents:
12656
diff
changeset
|
1868 |
13585 | 1869 private void processBytecode(int bci, int opcode) { |
1870 int cpi; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1871 |
13585 | 1872 // Checkstyle: stop |
1873 // @formatter:off | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1874 switch (opcode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1875 case NOP : /* nothing to do */ break; |
5538
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1876 case ACONST_NULL : frameState.apush(appendConstant(Constant.NULL_OBJECT)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1877 case ICONST_M1 : frameState.ipush(appendConstant(Constant.INT_MINUS_1)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1878 case ICONST_0 : frameState.ipush(appendConstant(Constant.INT_0)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1879 case ICONST_1 : frameState.ipush(appendConstant(Constant.INT_1)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1880 case ICONST_2 : frameState.ipush(appendConstant(Constant.INT_2)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1881 case ICONST_3 : frameState.ipush(appendConstant(Constant.INT_3)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1882 case ICONST_4 : frameState.ipush(appendConstant(Constant.INT_4)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1883 case ICONST_5 : frameState.ipush(appendConstant(Constant.INT_5)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1884 case LCONST_0 : frameState.lpush(appendConstant(Constant.LONG_0)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1885 case LCONST_1 : frameState.lpush(appendConstant(Constant.LONG_1)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1886 case FCONST_0 : frameState.fpush(appendConstant(Constant.FLOAT_0)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1887 case FCONST_1 : frameState.fpush(appendConstant(Constant.FLOAT_1)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1888 case FCONST_2 : frameState.fpush(appendConstant(Constant.FLOAT_2)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1889 case DCONST_0 : frameState.dpush(appendConstant(Constant.DOUBLE_0)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1890 case DCONST_1 : frameState.dpush(appendConstant(Constant.DOUBLE_1)); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1891 case BIPUSH : frameState.ipush(appendConstant(Constant.forInt(stream.readByte()))); break; |
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
1892 case SIPUSH : frameState.ipush(appendConstant(Constant.forInt(stream.readShort()))); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1893 case LDC : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1894 case LDC_W : // fall through |
4315
4c223446c28e
Replace the eagerResolving option of GraphBuilderConfiguration with three resolve policies: Default, EagerForSnippets (previously eagerResolving), and Eager (resolves exceptions and types of constants as well)
Peter Hofer <peter.hofer@jku.at>
parents:
4310
diff
changeset
|
1895 case LDC2_W : genLoadConstant(stream.readCPI(), opcode); break; |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1896 case ILOAD : loadLocal(stream.readLocalIndex(), Kind.Int); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1897 case LLOAD : loadLocal(stream.readLocalIndex(), Kind.Long); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1898 case FLOAD : loadLocal(stream.readLocalIndex(), Kind.Float); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1899 case DLOAD : loadLocal(stream.readLocalIndex(), Kind.Double); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1900 case ALOAD : loadLocal(stream.readLocalIndex(), Kind.Object); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1901 case ILOAD_0 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1902 case ILOAD_1 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1903 case ILOAD_2 : // fall through |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1904 case ILOAD_3 : loadLocal(opcode - ILOAD_0, Kind.Int); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1905 case LLOAD_0 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1906 case LLOAD_1 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1907 case LLOAD_2 : // fall through |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1908 case LLOAD_3 : loadLocal(opcode - LLOAD_0, Kind.Long); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1909 case FLOAD_0 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1910 case FLOAD_1 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1911 case FLOAD_2 : // fall through |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1912 case FLOAD_3 : loadLocal(opcode - FLOAD_0, Kind.Float); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1913 case DLOAD_0 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1914 case DLOAD_1 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1915 case DLOAD_2 : // fall through |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1916 case DLOAD_3 : loadLocal(opcode - DLOAD_0, Kind.Double); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1917 case ALOAD_0 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1918 case ALOAD_1 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1919 case ALOAD_2 : // fall through |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1920 case ALOAD_3 : loadLocal(opcode - ALOAD_0, Kind.Object); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1921 case IALOAD : genLoadIndexed(Kind.Int ); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1922 case LALOAD : genLoadIndexed(Kind.Long ); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1923 case FALOAD : genLoadIndexed(Kind.Float ); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1924 case DALOAD : genLoadIndexed(Kind.Double); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1925 case AALOAD : genLoadIndexed(Kind.Object); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1926 case BALOAD : genLoadIndexed(Kind.Byte ); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1927 case CALOAD : genLoadIndexed(Kind.Char ); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1928 case SALOAD : genLoadIndexed(Kind.Short ); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1929 case ISTORE : storeLocal(Kind.Int, stream.readLocalIndex()); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1930 case LSTORE : storeLocal(Kind.Long, stream.readLocalIndex()); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1931 case FSTORE : storeLocal(Kind.Float, stream.readLocalIndex()); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1932 case DSTORE : storeLocal(Kind.Double, stream.readLocalIndex()); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1933 case ASTORE : storeLocal(Kind.Object, stream.readLocalIndex()); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1934 case ISTORE_0 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1935 case ISTORE_1 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1936 case ISTORE_2 : // fall through |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1937 case ISTORE_3 : storeLocal(Kind.Int, opcode - ISTORE_0); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1938 case LSTORE_0 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1939 case LSTORE_1 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1940 case LSTORE_2 : // fall through |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1941 case LSTORE_3 : storeLocal(Kind.Long, opcode - LSTORE_0); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1942 case FSTORE_0 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1943 case FSTORE_1 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1944 case FSTORE_2 : // fall through |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1945 case FSTORE_3 : storeLocal(Kind.Float, opcode - FSTORE_0); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1946 case DSTORE_0 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1947 case DSTORE_1 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1948 case DSTORE_2 : // fall through |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1949 case DSTORE_3 : storeLocal(Kind.Double, opcode - DSTORE_0); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1950 case ASTORE_0 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1951 case ASTORE_1 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1952 case ASTORE_2 : // fall through |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1953 case ASTORE_3 : storeLocal(Kind.Object, opcode - ASTORE_0); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1954 case IASTORE : genStoreIndexed(Kind.Int ); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1955 case LASTORE : genStoreIndexed(Kind.Long ); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1956 case FASTORE : genStoreIndexed(Kind.Float ); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1957 case DASTORE : genStoreIndexed(Kind.Double); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1958 case AASTORE : genStoreIndexed(Kind.Object); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1959 case BASTORE : genStoreIndexed(Kind.Byte ); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1960 case CASTORE : genStoreIndexed(Kind.Char ); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1961 case SASTORE : genStoreIndexed(Kind.Short ); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1962 case POP : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1963 case POP2 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1964 case DUP : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1965 case DUP_X1 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1966 case DUP_X2 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1967 case DUP2 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1968 case DUP2_X1 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1969 case DUP2_X2 : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1970 case SWAP : stackOp(opcode); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1971 case IADD : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1972 case ISUB : // fall through |
7305
cd205ca515dd
Make integer division and remainder nodes fixed so that they can be lowered via snippets to do exception checks
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7300
diff
changeset
|
1973 case IMUL : genArithmeticOp(Kind.Int, opcode); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1974 case IDIV : // fall through |
7305
cd205ca515dd
Make integer division and remainder nodes fixed so that they can be lowered via snippets to do exception checks
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7300
diff
changeset
|
1975 case IREM : genIntegerDivOp(Kind.Int, opcode); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1976 case LADD : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1977 case LSUB : // fall through |
7305
cd205ca515dd
Make integer division and remainder nodes fixed so that they can be lowered via snippets to do exception checks
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7300
diff
changeset
|
1978 case LMUL : genArithmeticOp(Kind.Long, opcode); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1979 case LDIV : // fall through |
7305
cd205ca515dd
Make integer division and remainder nodes fixed so that they can be lowered via snippets to do exception checks
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7300
diff
changeset
|
1980 case LREM : genIntegerDivOp(Kind.Long, opcode); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1981 case FADD : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1982 case FSUB : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1983 case FMUL : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1984 case FDIV : // fall through |
7305
cd205ca515dd
Make integer division and remainder nodes fixed so that they can be lowered via snippets to do exception checks
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7300
diff
changeset
|
1985 case FREM : genArithmeticOp(Kind.Float, opcode); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1986 case DADD : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1987 case DSUB : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1988 case DMUL : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1989 case DDIV : // fall through |
7305
cd205ca515dd
Make integer division and remainder nodes fixed so that they can be lowered via snippets to do exception checks
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7300
diff
changeset
|
1990 case DREM : genArithmeticOp(Kind.Double, opcode); break; |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1991 case INEG : genNegateOp(Kind.Int); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1992 case LNEG : genNegateOp(Kind.Long); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1993 case FNEG : genNegateOp(Kind.Float); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1994 case DNEG : genNegateOp(Kind.Double); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1995 case ISHL : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1996 case ISHR : // fall through |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
1997 case IUSHR : genShiftOp(Kind.Int, opcode); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1998 case IAND : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1999 case IOR : // fall through |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2000 case IXOR : genLogicOp(Kind.Int, opcode); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2001 case LSHL : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2002 case LSHR : // fall through |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2003 case LUSHR : genShiftOp(Kind.Long, opcode); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2004 case LAND : // fall through |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2005 case LOR : // fall through |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2006 case LXOR : genLogicOp(Kind.Long, opcode); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2007 case IINC : genIncrement(); break; |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2008 case I2F : genFloatConvert(FloatConvert.I2F, Kind.Int, Kind.Float); break; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2009 case I2D : genFloatConvert(FloatConvert.I2D, Kind.Int, Kind.Double); break; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2010 case L2F : genFloatConvert(FloatConvert.L2F, Kind.Long, Kind.Float); break; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2011 case L2D : genFloatConvert(FloatConvert.L2D, Kind.Long, Kind.Double); break; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2012 case F2I : genFloatConvert(FloatConvert.F2I, Kind.Float, Kind.Int); break; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2013 case F2L : genFloatConvert(FloatConvert.F2L, Kind.Float, Kind.Long); break; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2014 case F2D : genFloatConvert(FloatConvert.F2D, Kind.Float, Kind.Double); break; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2015 case D2I : genFloatConvert(FloatConvert.D2I, Kind.Double, Kind.Int); break; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2016 case D2L : genFloatConvert(FloatConvert.D2L, Kind.Double, Kind.Long); break; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2017 case D2F : genFloatConvert(FloatConvert.D2F, Kind.Double, Kind.Float); break; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2018 case L2I : genNarrow(Kind.Long, Kind.Int); break; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2019 case I2L : genSignExtend(Kind.Int, Kind.Long); break; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2020 case I2B : genSignExtend(Kind.Byte, Kind.Int); break; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2021 case I2S : genSignExtend(Kind.Short, Kind.Int); break; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13938
diff
changeset
|
2022 case I2C : genZeroExtend(Kind.Char, Kind.Int); break; |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2023 case LCMP : genCompareOp(Kind.Long, false); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2024 case FCMPL : genCompareOp(Kind.Float, true); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2025 case FCMPG : genCompareOp(Kind.Float, false); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2026 case DCMPL : genCompareOp(Kind.Double, true); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2027 case DCMPG : genCompareOp(Kind.Double, false); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2028 case IFEQ : genIfZero(Condition.EQ); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2029 case IFNE : genIfZero(Condition.NE); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2030 case IFLT : genIfZero(Condition.LT); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2031 case IFGE : genIfZero(Condition.GE); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2032 case IFGT : genIfZero(Condition.GT); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2033 case IFLE : genIfZero(Condition.LE); break; |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2034 case IF_ICMPEQ : genIfSame(Kind.Int, Condition.EQ); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2035 case IF_ICMPNE : genIfSame(Kind.Int, Condition.NE); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2036 case IF_ICMPLT : genIfSame(Kind.Int, Condition.LT); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2037 case IF_ICMPGE : genIfSame(Kind.Int, Condition.GE); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2038 case IF_ICMPGT : genIfSame(Kind.Int, Condition.GT); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2039 case IF_ICMPLE : genIfSame(Kind.Int, Condition.LE); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2040 case IF_ACMPEQ : genIfSame(Kind.Object, Condition.EQ); break; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
2041 case IF_ACMPNE : genIfSame(Kind.Object, Condition.NE); break; |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
2042 case GOTO : genGoto(); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2043 case JSR : genJsr(stream.readBranchDest()); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2044 case RET : genRet(stream.readLocalIndex()); break; |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5695
diff
changeset
|
2045 case TABLESWITCH : genSwitch(new BytecodeTableSwitch(stream(), bci())); break; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5695
diff
changeset
|
2046 case LOOKUPSWITCH : genSwitch(new BytecodeLookupSwitch(stream(), bci())); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2047 case IRETURN : genReturn(frameState.ipop()); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2048 case LRETURN : genReturn(frameState.lpop()); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2049 case FRETURN : genReturn(frameState.fpop()); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2050 case DRETURN : genReturn(frameState.dpop()); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2051 case ARETURN : genReturn(frameState.apop()); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2052 case RETURN : genReturn(null); break; |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
2053 case GETSTATIC : cpi = stream.readCPI(); genGetStatic(lookupField(cpi, opcode)); break; |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
2054 case PUTSTATIC : cpi = stream.readCPI(); genPutStatic(lookupField(cpi, opcode)); break; |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
2055 case GETFIELD : cpi = stream.readCPI(); genGetField(lookupField(cpi, opcode)); break; |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
2056 case PUTFIELD : cpi = stream.readCPI(); genPutField(lookupField(cpi, opcode)); break; |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
2057 case INVOKEVIRTUAL : cpi = stream.readCPI(); genInvokeVirtual(lookupMethod(cpi, opcode)); break; |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
2058 case INVOKESPECIAL : cpi = stream.readCPI(); genInvokeSpecial(lookupMethod(cpi, opcode)); break; |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
2059 case INVOKESTATIC : cpi = stream.readCPI(); genInvokeStatic(lookupMethod(cpi, opcode)); break; |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
2060 case INVOKEINTERFACE: cpi = stream.readCPI(); genInvokeInterface(lookupMethod(cpi, opcode)); break; |
8945
7ef66078d837
add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents:
8660
diff
changeset
|
2061 case INVOKEDYNAMIC : cpi = stream.readCPI4(); genInvokeDynamic(lookupMethod(cpi, opcode)); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2062 case NEW : genNewInstance(stream.readCPI()); break; |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
2063 case NEWARRAY : genNewPrimitiveArray(stream.readLocalIndex()); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2064 case ANEWARRAY : genNewObjectArray(stream.readCPI()); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2065 case ARRAYLENGTH : genArrayLength(); break; |
5256
1e153fdac9fb
Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5255
diff
changeset
|
2066 case ATHROW : genThrow(); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2067 case CHECKCAST : genCheckCast(); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2068 case INSTANCEOF : genInstanceOf(); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2069 case MONITORENTER : genMonitorEnter(frameState.apop()); break; |
12417
0b71e8b6418c
preliminary fix for MonitorExitNodes with AFTER_BCI
Lukas Stadler <lukas.stadler@jku.at>
parents:
12362
diff
changeset
|
2070 case MONITOREXIT : genMonitorExit(frameState.apop(), null); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2071 case MULTIANEWARRAY : genNewMultiArray(stream.readCPI()); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2072 case IFNULL : genIfNull(Condition.EQ); break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2073 case IFNONNULL : genIfNull(Condition.NE); break; |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
2074 case GOTO_W : genGoto(); break; |
5031
4d152e5e34ba
Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5030
diff
changeset
|
2075 case JSR_W : genJsr(stream.readBranchDest()); break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2076 case BREAKPOINT: |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
2077 throw new BailoutException("concurrent setting of breakpoint"); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2078 default: |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
2079 throw new BailoutException("Unsupported opcode " + opcode + " (" + nameOf(opcode) + ") [bci=" + bci + "]"); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2080 } |
7522
4cc0efe5cffe
disabled auto-formatting of manually formatted code
Doug Simon <doug.simon@oracle.com>
parents:
7305
diff
changeset
|
2081 // @formatter:on |
13585 | 2082 // Checkstyle: resume |
2083 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2084 |
13585 | 2085 private void traceInstruction(int bci, int opcode, boolean blockStart) { |
2086 if (traceLevel >= TRACELEVEL_INSTRUCTIONS && Debug.isLogEnabled()) { | |
2087 StringBuilder sb = new StringBuilder(40); | |
2088 sb.append(blockStart ? '+' : '|'); | |
2089 if (bci < 10) { | |
2090 sb.append(" "); | |
2091 } else if (bci < 100) { | |
2092 sb.append(' '); | |
2093 } | |
2094 sb.append(bci).append(": ").append(Bytecodes.nameOf(opcode)); | |
2095 for (int i = bci + 1; i < stream.nextBCI(); ++i) { | |
2096 sb.append(' ').append(stream.readUByte(i)); | |
2097 } | |
2098 if (!currentBlock.jsrScope.isEmpty()) { | |
2099 sb.append(' ').append(currentBlock.jsrScope); | |
2100 } | |
2101 Debug.log(sb.toString()); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2102 } |
13585 | 2103 } |
2104 | |
2105 private void genArrayLength() { | |
2106 frameState.ipush(append(new ArrayLengthNode(frameState.apop()))); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2107 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2108 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2109 } |