annotate graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java @ 19417:042f0a8ebce2

completed integration of AnnotatedInvocationPlugin
author Doug Simon <doug.simon@oracle.com>
date Mon, 16 Feb 2015 21:10:14 +0100
parents 5b93a11c535c
children 87a2901b1f42
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
2 * Copyright (c) 2009, 2014, 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
11839
0e2cceed1caf Temporarily move encodeDeoptActionAndReason to MetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11837
diff changeset
25 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
26 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
27 import static com.oracle.graal.bytecode.Bytecodes.*;
15259
d90e5c22ba55 Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15220
diff changeset
28 import static com.oracle.graal.compiler.common.GraalOptions.*;
19409
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
29 import static com.oracle.graal.nodes.StructuredGraph.*;
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
30 import static java.lang.String.*;
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15311
diff changeset
31
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
34 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
35 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
36 import com.oracle.graal.api.meta.ProfilingInfo.TriState;
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
37 import com.oracle.graal.api.replacements.*;
5568
fdf19fa15ce4 Split bytecode utilities into separate project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
38 import com.oracle.graal.bytecode.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15145
diff changeset
39 import com.oracle.graal.compiler.common.*;
15200
97eed257999b Move Condition to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
40 import com.oracle.graal.compiler.common.calc.*;
15261
882f4cb7cfcf Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15260
diff changeset
41 import com.oracle.graal.compiler.common.type.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
42 import com.oracle.graal.debug.*;
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19173
diff changeset
43 import com.oracle.graal.graph.Graph.Mark;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
44 import com.oracle.graal.graph.*;
14922
ea57ed7085cf Move options from GraphBuilderPhase to AbstractBytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents: 14906
diff changeset
45 import com.oracle.graal.graph.Node.ValueNumberable;
19155
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
46 import com.oracle.graal.graph.iterators.*;
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
47 import com.oracle.graal.java.BciBlockMapping.BciBlock;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
48 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
49 import com.oracle.graal.java.BciBlockMapping.LocalLiveness;
19417
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
50 import com.oracle.graal.java.GraphBuilderPlugin.AnnotatedInvocationPlugin;
19390
7f4201b633e7 renamed GraphBuilderPlugins to InvocationPlugins and consolidated it into GraphBuilderConfiguration; moved declaration of GraphBuilderPlugin sub-interfaces into GraphBuilderPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19387
diff changeset
51 import com.oracle.graal.java.GraphBuilderPlugin.InlineInvokePlugin;
7f4201b633e7 renamed GraphBuilderPlugins to InvocationPlugins and consolidated it into GraphBuilderConfiguration; moved declaration of GraphBuilderPlugin sub-interfaces into GraphBuilderPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19387
diff changeset
52 import com.oracle.graal.java.GraphBuilderPlugin.InvocationPlugin;
7f4201b633e7 renamed GraphBuilderPlugins to InvocationPlugins and consolidated it into GraphBuilderConfiguration; moved declaration of GraphBuilderPlugin sub-interfaces into GraphBuilderPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19387
diff changeset
53 import com.oracle.graal.java.GraphBuilderPlugin.LoopExplosionPlugin;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
54 import com.oracle.graal.nodes.*;
16563
1e63cb55f61d Move InvokeKind from MethodCallTargetNode to CallTargetNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16490
diff changeset
55 import com.oracle.graal.nodes.CallTargetNode.InvokeKind;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
56 import com.oracle.graal.nodes.calc.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
57 import com.oracle.graal.nodes.extended.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
58 import com.oracle.graal.nodes.java.*;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
59 import com.oracle.graal.nodes.spi.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
60 import com.oracle.graal.nodes.type.*;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
61 import com.oracle.graal.nodes.util.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6521
diff changeset
62 import com.oracle.graal.phases.*;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
63 import com.oracle.graal.phases.tiers.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 * 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
67 */
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
68 public class GraphBuilderPhase extends BasePhase<HighTierContext> {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69
5109
6766253384bf more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5105
diff changeset
70 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
71
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
72 public GraphBuilderPhase(GraphBuilderConfiguration config) {
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
73 this.graphBuilderConfig = config;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76 @Override
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
77 protected void run(StructuredGraph graph, HighTierContext context) {
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
78 new Instance(context.getMetaAccess(), context.getStampProvider(), null, context.getConstantReflection(), graphBuilderConfig, context.getOptimisticOptimizations()).run(graph);
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
16573
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
81 public GraphBuilderConfiguration getGraphBuilderConfig() {
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
82 return graphBuilderConfig;
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
83 }
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
84
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
85 public static class Instance extends Phase {
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
86
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
87 protected StructuredGraph currentGraph;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
88
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
89 private final MetaAccessProvider metaAccess;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
90
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18917
diff changeset
91 private ResolvedJavaMethod rootMethod;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
92
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
93 private final GraphBuilderConfiguration graphBuilderConfig;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
94 private final OptimisticOptimizations optimisticOpts;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
95 private final StampProvider stampProvider;
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
96 private final ConstantReflectionProvider constantReflection;
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
97 private final SnippetReflectionProvider snippetReflectionProvider;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
98
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
99 /**
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
100 * Gets the graph being processed by this builder.
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
101 */
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
102 protected StructuredGraph getGraph() {
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
103 return currentGraph;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
104 }
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
105
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
106 public Instance(MetaAccessProvider metaAccess, StampProvider stampProvider, SnippetReflectionProvider snippetReflectionProvider, ConstantReflectionProvider constantReflection,
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
107 GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts) {
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
108 this.graphBuilderConfig = graphBuilderConfig;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
109 this.optimisticOpts = optimisticOpts;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
110 this.metaAccess = metaAccess;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
111 this.stampProvider = stampProvider;
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
112 this.constantReflection = constantReflection;
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
113 this.snippetReflectionProvider = snippetReflectionProvider;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
114 assert metaAccess != null;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
115 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116
19253
2caf12d746a3 merge fixes
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
117 public Instance(MetaAccessProvider metaAccess, StampProvider stampProvider, ConstantReflectionProvider constantReflection, GraphBuilderConfiguration graphBuilderConfig,
2caf12d746a3 merge fixes
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
118 OptimisticOptimizations optimisticOpts) {
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
119 this(metaAccess, stampProvider, null, constantReflection, graphBuilderConfig, optimisticOpts);
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
120 }
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
121
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
122 @Override
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
123 protected void run(StructuredGraph graph) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
124 ResolvedJavaMethod method = graph.method();
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18917
diff changeset
125 this.rootMethod = method;
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
126 int entryBCI = graph.getEntryBCI();
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
127 assert method.getCode() != null : "method must contain bytecodes: " + method;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
128 this.currentGraph = graph;
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
129 HIRFrameStateBuilder frameState = new HIRFrameStateBuilder(method, graph, null);
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
130 frameState.initializeForMethodStart(graphBuilderConfig.eagerResolving(), this.graphBuilderConfig.getParameterPlugin());
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
131 TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method);
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
132 try {
19409
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
133 BytecodeParser parser = new BytecodeParser(metaAccess, method, graphBuilderConfig, optimisticOpts, entryBCI, false);
18920
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
134 parser.build(0, graph.start(), frameState);
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
135
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
136 parser.connectLoopEndToBegin();
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
137
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
138 // remove dead parameters
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
139 for (ParameterNode param : currentGraph.getNodes(ParameterNode.class)) {
18937
ff232ff8d028 Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18925
diff changeset
140 if (param.hasNoUsages()) {
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
141 assert param.inputs().isEmpty();
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
142 param.safeDelete();
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
143 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
144 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
145 } finally {
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
146 filter.remove();
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
147 }
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15311
diff changeset
148
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15311
diff changeset
149 ComputeLoopFrequenciesClosure.compute(graph);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
150 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
151
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
152 @Override
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
153 protected String getDetailedName() {
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18917
diff changeset
154 return getName() + " " + rootMethod.format("%H.%n(%p):%r");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
156
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
157 private static class Target {
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
158
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
159 FixedNode fixed;
14792
b9805a622546 Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14068
diff changeset
160 HIRFrameStateBuilder state;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
161
14792
b9805a622546 Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14068
diff changeset
162 public Target(FixedNode fixed, HIRFrameStateBuilder state) {
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
163 this.fixed = fixed;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
164 this.state = state;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
165 }
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6699
diff changeset
166 }
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6699
diff changeset
167
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
168 private static class ExplodedLoopContext {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
169 private BciBlock header;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
170 private int targetPeelIteration;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
171 private int peelIteration;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
172 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
173
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
174 public class BytecodeParser extends AbstractBytecodeParser<ValueNode, HIRFrameStateBuilder> implements GraphBuilderContext {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
175
15032
c9bf91560c82 BciBlock: make entryState abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 15030
diff changeset
176 private BciBlock[] loopHeaders;
c9bf91560c82 BciBlock: make entryState abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 15030
diff changeset
177 private LocalLiveness liveness;
18920
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
178 protected final int entryBCI;
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
179 private int currentDepth;
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
180
18920
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
181 private LineNumberTable lnt;
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
182 private int previousLineNumber;
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
183 private int currentLineNumber;
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
184
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
185 private ValueNode methodSynchronizedObject;
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
186 private ExceptionDispatchBlock unwindBlock;
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
187 private BciBlock returnBlock;
18925
14599c77560a Do not always allocate monitorId NodeInputList. Allow null NodeInputList.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18923
diff changeset
188
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
189 private ValueNode returnValue;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
190 private FixedWithNextNode beforeReturnNode;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
191 private ValueNode unwindValue;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
192 private FixedWithNextNode beforeUnwindNode;
18920
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
193
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
194 private FixedWithNextNode lastInstr; // the last instruction added
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19136
diff changeset
195 private final boolean explodeLoops;
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
196 private Stack<ExplodedLoopContext> explodeLoopsContext;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
197 private int nextPeelIteration = 1;
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
198 private int returnCount;
19367
f9ccdf258dd4 Further reduction of begin node creation when inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19366
diff changeset
199 private boolean controlFlowSplit;
18920
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
200
19409
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
201 /**
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
202 * @param isReplacement specifies if this object is being used to parse a method that
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
203 * implements the semantics of another method (i.e., an intrinsic) or
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
204 * bytecode instruction (i.e., a snippet)
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
205 */
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
206 public BytecodeParser(MetaAccessProvider metaAccess, ResolvedJavaMethod method, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, int entryBCI,
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
207 boolean isReplacement) {
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
208 super(metaAccess, method, graphBuilderConfig, optimisticOpts, isReplacement);
18920
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
209 this.entryBCI = entryBCI;
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
210
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
211 if (graphBuilderConfig.insertNonSafepointDebugInfo()) {
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
212 lnt = method.getLineNumberTable();
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
213 previousLineNumber = -1;
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
214 }
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19136
diff changeset
215
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19136
diff changeset
216 LoopExplosionPlugin loopExplosionPlugin = graphBuilderConfig.getLoopExplosionPlugin();
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19136
diff changeset
217 if (loopExplosionPlugin != null) {
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19136
diff changeset
218 explodeLoops = loopExplosionPlugin.shouldExplodeLoops(method);
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19136
diff changeset
219 } else {
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19136
diff changeset
220 explodeLoops = false;
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19136
diff changeset
221 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
222 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
224 public ValueNode getReturnValue() {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
225 return returnValue;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
226 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
227
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
228 public FixedWithNextNode getBeforeReturnNode() {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
229 return this.beforeReturnNode;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
230 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
231
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
232 public ValueNode getUnwindValue() {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
233 return unwindValue;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
234 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
235
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
236 public FixedWithNextNode getBeforeUnwindNode() {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
237 return this.beforeUnwindNode;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
238 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
239
18920
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
240 protected void build(int depth, FixedWithNextNode startInstruction, HIRFrameStateBuilder startFrameState) {
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
241 this.currentDepth = depth;
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
242 if (PrintProfilingInformation.getValue()) {
16480
10c12d09a8d2 moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 16385
diff changeset
243 TTY.println("Profiling info for " + method.format("%H.%n(%p)"));
16490
cac0a7d1c325 moved profileToString(ProfilingInfo info, ResolvedJavaMethod method, String sep) from MetaUtil to be a default method in ProfilingInfo
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
244 TTY.println(MetaUtil.indent(profilingInfo.toString(method, CodeUtil.NEW_LINE), " "));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
245 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
247 try (Indent indent = Debug.logAndIndent("build graph for %s", method)) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
248
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
249 // compute the block map, setup exception handlers and get the entrypoint(s)
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19136
diff changeset
250 BciBlockMapping blockMap = BciBlockMapping.create(method, graphBuilderConfig.doLivenessAnalysis(), explodeLoops);
18817
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
251 loopHeaders = blockMap.getLoopHeaders();
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
252 liveness = blockMap.liveness;
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
253 returnCount = blockMap.getReturnCount();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254
18919
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
255 lastInstr = startInstruction;
18920
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
256 this.setCurrentFrameState(startFrameState);
18919
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
257
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
258 if (startInstruction == currentGraph.start()) {
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
259 StartNode startNode = currentGraph.start();
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
260 if (method.isSynchronized()) {
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
261 startNode.setStateAfter(frameState.create(BytecodeFrame.BEFORE_BCI));
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
262 } else {
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
263 frameState.clearNonLiveLocals(blockMap.startBlock, liveness, true);
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
264 assert bci() == 0;
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
265 startNode.setStateAfter(frameState.create(bci()));
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
266 }
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
267 }
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18917
diff changeset
268
15267
98d45600222c Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15266
diff changeset
269 if (method.isSynchronized()) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
270 // add a monitor enter to the start block
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
271 methodSynchronizedObject = synchronizedObject(frameState, method);
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
272 MonitorEnterNode monitorEnter = genMonitorEnter(methodSynchronizedObject);
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
273 frameState.clearNonLiveLocals(blockMap.startBlock, liveness, true);
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
274 assert bci() == 0;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
275 monitorEnter.setStateAfter(frameState.create(bci()));
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
276 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
277
16573
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
278 if (graphBuilderConfig.insertNonSafepointDebugInfo()) {
18916
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
279 append(createInfoPointNode(InfopointReason.METHOD_START));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
280 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
281
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
282 currentBlock = blockMap.startBlock;
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
283 blockMap.startBlock.setEntryState(0, frameState);
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
284 if (blockMap.startBlock.isLoopHeader && !explodeLoops) {
19366
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
285 appendGoto(blockMap.startBlock);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
286 } else {
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
287 blockMap.startBlock.setFirstInstruction(0, lastInstr);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
288 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7522
diff changeset
289
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
290 int index = 0;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
291 BciBlock[] blocks = blockMap.getBlocks();
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
292 while (index < blocks.length) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
293 BciBlock block = blocks[index];
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
294 index = iterateBlock(blocks, block);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
295 }
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
296 processBlock(this, returnBlock);
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18917
diff changeset
297 processBlock(this, unwindBlock);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
298
19380
9220566922ab Parse time constant folding for div and float convert.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19379
diff changeset
299 if (Debug.isDumpEnabled() && this.beforeReturnNode != startInstruction) {
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
300 Debug.dump(currentGraph, "Bytecodes parsed: " + method.getDeclaringClass().getUnqualifiedName() + "." + method.getName());
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
301 }
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
302 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
303 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
304
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
305 private int iterateBlock(BciBlock[] blocks, BciBlock block) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
306 if (block.isLoopHeader && this.explodeLoops) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
307 return iterateExplodedLoopHeader(blocks, block);
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
308 } else {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
309 processBlock(this, block);
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
310 return block.getId() + 1;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
311 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
312 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
313
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
314 private int iterateExplodedLoopHeader(BciBlock[] blocks, BciBlock header) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
315 if (explodeLoopsContext == null) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
316 explodeLoopsContext = new Stack<>();
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
317 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
318
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
319 ExplodedLoopContext context = new ExplodedLoopContext();
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
320 context.header = header;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
321 context.peelIteration = this.getCurrentDimension();
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
322 context.targetPeelIteration = -1;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
323 explodeLoopsContext.push(context);
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
324 Debug.dump(currentGraph, "before loop explosion " + context.peelIteration);
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
325
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
326 while (true) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
327
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
328 processBlock(this, header);
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
329 for (int j = header.getId() + 1; j <= header.loopEnd; ++j) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
330 BciBlock block = blocks[j];
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
331 iterateBlock(blocks, block);
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
332 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
333
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
334 if (context.targetPeelIteration != -1) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
335 // We were reaching the backedge during explosion. Explode further.
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
336 Debug.dump(currentGraph, "Before loop explosion " + context.targetPeelIteration);
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
337 context.peelIteration = context.targetPeelIteration;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
338 context.targetPeelIteration = -1;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
339 } else {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
340 // We did not reach the backedge. Exit.
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
341 Debug.dump(currentGraph, "after loop explosion " + context.peelIteration);
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
342 break;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
343 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
344 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
345 explodeLoopsContext.pop();
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
346 return header.loopEnd + 1;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
347 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
348
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
349 private BciBlock returnBlock(int bci) {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
350 if (returnBlock == null) {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
351 returnBlock = new BciBlock();
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
352 returnBlock.startBci = bci;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
353 returnBlock.endBci = bci;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
354 returnBlock.setId(Integer.MAX_VALUE);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
355 }
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
356 return returnBlock;
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
357 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
358
15220
ccf0c5a1edf1 Use a synthetic BCI instead of a random BCI (the first parsed bytecode that could throw an exception) for the exception unwind block
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15200
diff changeset
359 private BciBlock unwindBlock() {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
360 if (unwindBlock == null) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
361 unwindBlock = new ExceptionDispatchBlock();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
362 unwindBlock.startBci = -1;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
363 unwindBlock.endBci = -1;
15267
98d45600222c Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15266
diff changeset
364 unwindBlock.deoptBci = method.isSynchronized() ? BytecodeFrame.UNWIND_BCI : BytecodeFrame.AFTER_EXCEPTION_BCI;
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
365 unwindBlock.setId(Integer.MAX_VALUE);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
366 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
367 return unwindBlock;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
368 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
369
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
370 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
371 * @param type the unresolved type of the constant
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
372 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
373 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
374 protected void handleUnresolvedLoadConstant(JavaType type) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
375 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
376 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
377 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
378
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
379 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
380 * @param type the unresolved type of the type check
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
381 * @param object the object value whose type is being checked against {@code type}
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
382 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
383 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
384 protected void handleUnresolvedCheckCast(JavaType type, ValueNode object) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
385 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
386 append(new FixedGuardNode(currentGraph.unique(new IsNullNode(object)), Unresolved, InvalidateRecompile));
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18374
diff changeset
387 frameState.apush(appendConstant(JavaConstant.NULL_POINTER));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
388 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
389
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
390 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
391 * @param type the unresolved type of the type check
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
392 * @param object the object value whose type is being checked against {@code type}
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
393 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
394 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
395 protected void handleUnresolvedInstanceOf(JavaType type, ValueNode object) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
396 assert !graphBuilderConfig.eagerResolving();
18994
8b4ef818169c Make AbstractBeginNode an abstract class and create concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18993
diff changeset
397 AbstractBeginNode successor = currentGraph.add(new BeginNode());
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
398 DeoptimizeNode deopt = currentGraph.add(new DeoptimizeNode(InvalidateRecompile, Unresolved));
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
399 append(new IfNode(currentGraph.unique(new IsNullNode(object)), successor, deopt, 1));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
400 lastInstr = successor;
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
401 frameState.ipush(appendConstant(JavaConstant.INT_0));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
402 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
403
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
404 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
405 * @param type the type being instantiated
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
406 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
407 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
408 protected void handleUnresolvedNewInstance(JavaType type) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
409 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
410 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
411 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
412
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
413 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
414 * @param type the type of the array being instantiated
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
415 * @param length the length of the array
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
416 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
417 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
418 protected void handleUnresolvedNewObjectArray(JavaType type, ValueNode length) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
419 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
420 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
421 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
422
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
423 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
424 * @param type the type being instantiated
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
425 * @param dims the dimensions for the multi-array
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
426 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
427 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
428 protected void handleUnresolvedNewMultiArray(JavaType type, List<ValueNode> dims) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
429 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
430 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
431 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
432
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
433 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
434 * @param field the unresolved field
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
435 * @param receiver the object containing the field or {@code null} if {@code field} is
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
436 * static
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
437 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
438 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
439 protected void handleUnresolvedLoadField(JavaField field, ValueNode receiver) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
440 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
441 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
442 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
443
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
444 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
445 * @param field the unresolved field
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
446 * @param value the value being stored to the field
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
447 * @param receiver the object containing the field or {@code null} if {@code field} is
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
448 * static
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
449 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
450 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
451 protected void handleUnresolvedStoreField(JavaField field, ValueNode value, ValueNode receiver) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
452 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
453 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
454 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
455
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
456 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
457 * @param type
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
458 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
459 @Override
18361
6ac7e9c85be6 Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
460 protected void handleUnresolvedExceptionType(JavaType type) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
461 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
462 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
463 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
464
16340
e7af30d6ae5b remove frame state manipulation after a DeoptimizeNode is appended as the state will never be used; remove unused ParameterNodes from a graph
Doug Simon <doug.simon@oracle.com>
parents: 16215
diff changeset
465 /**
e7af30d6ae5b remove frame state manipulation after a DeoptimizeNode is appended as the state will never be used; remove unused ParameterNodes from a graph
Doug Simon <doug.simon@oracle.com>
parents: 16215
diff changeset
466 * @param javaMethod
e7af30d6ae5b remove frame state manipulation after a DeoptimizeNode is appended as the state will never be used; remove unused ParameterNodes from a graph
Doug Simon <doug.simon@oracle.com>
parents: 16215
diff changeset
467 * @param invokeKind
e7af30d6ae5b remove frame state manipulation after a DeoptimizeNode is appended as the state will never be used; remove unused ParameterNodes from a graph
Doug Simon <doug.simon@oracle.com>
parents: 16215
diff changeset
468 */
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
469 protected void handleUnresolvedInvoke(JavaMethod javaMethod, InvokeKind invokeKind) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
470 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
471 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
472 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
473
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
474 private DispatchBeginNode handleException(ValueNode exceptionObject, int bci) {
15263
0b25b81414c9 Move various bci constants from FrameState (gral.nodes) to BytecodeFrame (graal.api.code)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15261
diff changeset
475 assert bci == BytecodeFrame.BEFORE_BCI || bci == bci() : "invalid bci";
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
476 Debug.log("Creating exception dispatch edges at %d, exception object=%s, exception seen=%s", bci, exceptionObject, profilingInfo.getExceptionSeen(bci));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
477
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
478 BciBlock dispatchBlock = currentBlock.exceptionDispatchBlock();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
479 /*
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
480 * The exception dispatch block is always for the last bytecode of a block, so if we
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
481 * are not at the endBci yet, there is no exception handler for this bci and we can
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
482 * unwind immediately.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
483 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
484 if (bci != currentBlock.endBci || dispatchBlock == null) {
15220
ccf0c5a1edf1 Use a synthetic BCI instead of a random BCI (the first parsed bytecode that could throw an exception) for the exception unwind block
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15200
diff changeset
485 dispatchBlock = unwindBlock();
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
486 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
487
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
488 HIRFrameStateBuilder dispatchState = frameState.copy();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
489 dispatchState.clearStack();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
490
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
491 DispatchBeginNode dispatchBegin;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
492 if (exceptionObject == null) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
493 dispatchBegin = currentGraph.add(new ExceptionObjectNode(metaAccess));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
494 dispatchState.apush(dispatchBegin);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
495 dispatchState.setRethrowException(true);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
496 dispatchBegin.setStateAfter(dispatchState.create(bci));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
497 } else {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
498 dispatchBegin = currentGraph.add(new DispatchBeginNode());
15837
6fe57ff3f02c Rename methods to have consistent names, allow subclasses of bytecode parsers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15470
diff changeset
499 dispatchState.apush(exceptionObject);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
500 dispatchBegin.setStateAfter(dispatchState.create(bci));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
501 dispatchState.setRethrowException(true);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
502 }
19367
f9ccdf258dd4 Further reduction of begin node creation when inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19366
diff changeset
503 this.controlFlowSplit = true;
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
504 FixedNode target = createTarget(dispatchBlock, dispatchState);
15837
6fe57ff3f02c Rename methods to have consistent names, allow subclasses of bytecode parsers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15470
diff changeset
505 FixedWithNextNode finishedDispatch = finishInstruction(dispatchBegin, dispatchState);
6fe57ff3f02c Rename methods to have consistent names, allow subclasses of bytecode parsers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15470
diff changeset
506 finishedDispatch.setNext(target);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
507 return dispatchBegin;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
508 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
509
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
510 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
511 protected ValueNode genLoadIndexed(ValueNode array, ValueNode index, Kind kind) {
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
512 return LoadIndexedNode.create(array, index, kind, metaAccess, constantReflection);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
513 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
514
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
515 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
516 protected ValueNode genStoreIndexed(ValueNode array, ValueNode index, Kind kind, ValueNode value) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
517 return new StoreIndexedNode(array, index, kind, value);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
518 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
519
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
520 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
521 protected ValueNode genIntegerAdd(Kind kind, ValueNode x, ValueNode y) {
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
522 return AddNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
523 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
524
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
525 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
526 protected ValueNode genIntegerSub(Kind kind, ValueNode x, ValueNode y) {
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
527 return SubNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
528 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
529
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
530 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
531 protected ValueNode genIntegerMul(Kind kind, ValueNode x, ValueNode y) {
19371
1e49642dd130 More constant folding during parsing for arithmetic nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19369
diff changeset
532 return MulNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
533 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
534
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
535 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
536 protected ValueNode genFloatAdd(Kind kind, ValueNode x, ValueNode y, boolean isStrictFP) {
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
537 return AddNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
538 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
539
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
540 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
541 protected ValueNode genFloatSub(Kind kind, ValueNode x, ValueNode y, boolean isStrictFP) {
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
542 return SubNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
543 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
544
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
545 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
546 protected ValueNode genFloatMul(Kind kind, ValueNode x, ValueNode y, boolean isStrictFP) {
19371
1e49642dd130 More constant folding during parsing for arithmetic nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19369
diff changeset
547 return MulNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
548 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
549
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
550 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
551 protected ValueNode genFloatDiv(Kind kind, ValueNode x, ValueNode y, boolean isStrictFP) {
19380
9220566922ab Parse time constant folding for div and float convert.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19379
diff changeset
552 return DivNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
553 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
554
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
555 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
556 protected ValueNode genFloatRem(Kind kind, ValueNode x, ValueNode y, boolean isStrictFP) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
557 return new RemNode(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
558 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
559
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
560 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
561 protected ValueNode genIntegerDiv(Kind kind, ValueNode x, ValueNode y) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
562 return new IntegerDivNode(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
563 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
564
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
565 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
566 protected ValueNode genIntegerRem(Kind kind, ValueNode x, ValueNode y) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
567 return new IntegerRemNode(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
568 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
569
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
570 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
571 protected ValueNode genNegateOp(ValueNode x) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
572 return (new NegateNode(x));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
573 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
574
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
575 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
576 protected ValueNode genLeftShift(Kind kind, ValueNode x, ValueNode y) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
577 return new LeftShiftNode(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
578 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
579
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
580 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
581 protected ValueNode genRightShift(Kind kind, ValueNode x, ValueNode y) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
582 return new RightShiftNode(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
583 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
584
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
585 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
586 protected ValueNode genUnsignedRightShift(Kind kind, ValueNode x, ValueNode y) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
587 return new UnsignedRightShiftNode(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
588 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
589
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
590 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
591 protected ValueNode genAnd(Kind kind, ValueNode x, ValueNode y) {
19371
1e49642dd130 More constant folding during parsing for arithmetic nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19369
diff changeset
592 return AndNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
593 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
594
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
595 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
596 protected ValueNode genOr(Kind kind, ValueNode x, ValueNode y) {
19371
1e49642dd130 More constant folding during parsing for arithmetic nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19369
diff changeset
597 return OrNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
598 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
599
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
600 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
601 protected ValueNode genXor(Kind kind, ValueNode x, ValueNode y) {
19371
1e49642dd130 More constant folding during parsing for arithmetic nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19369
diff changeset
602 return XorNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
603 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
604
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
605 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
606 protected ValueNode genNormalizeCompare(ValueNode x, ValueNode y, boolean isUnorderedLess) {
19379
b720a1e02fa0 Add graph building time canonicalization for NormalizeCompareNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19375
diff changeset
607 return NormalizeCompareNode.create(x, y, isUnorderedLess, constantReflection);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
608 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
609
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
610 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
611 protected ValueNode genFloatConvert(FloatConvert op, ValueNode input) {
19380
9220566922ab Parse time constant folding for div and float convert.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19379
diff changeset
612 return FloatConvertNode.create(op, input);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
613 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
614
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
615 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
616 protected ValueNode genNarrow(ValueNode input, int bitCount) {
19364
2d6a2f18fe8c Add graph builder folding support for integer conversion nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19363
diff changeset
617 return NarrowNode.create(input, bitCount);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
618 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
619
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
620 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
621 protected ValueNode genSignExtend(ValueNode input, int bitCount) {
19364
2d6a2f18fe8c Add graph builder folding support for integer conversion nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19363
diff changeset
622 return SignExtendNode.create(input, bitCount);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
623 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
624
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
625 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
626 protected ValueNode genZeroExtend(ValueNode input, int bitCount) {
19364
2d6a2f18fe8c Add graph builder folding support for integer conversion nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19363
diff changeset
627 return ZeroExtendNode.create(input, bitCount);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
628 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
629
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
630 @Override
15030
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
631 protected void genGoto() {
19366
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
632 appendGoto(currentBlock.getSuccessor(0));
15030
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
633 assert currentBlock.numNormalSuccessors() == 1;
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
634 }
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
635
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
636 @Override
19372
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
637 protected LogicNode genObjectEquals(ValueNode x, ValueNode y) {
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
638 return ObjectEqualsNode.create(x, y, constantReflection);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
639 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
640
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
641 @Override
19372
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
642 protected LogicNode genIntegerEquals(ValueNode x, ValueNode y) {
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
643 return IntegerEqualsNode.create(x, y, constantReflection);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
644 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
645
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
646 @Override
19372
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
647 protected LogicNode genIntegerLessThan(ValueNode x, ValueNode y) {
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
648 return IntegerLessThanNode.create(x, y, constantReflection);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
649 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
650
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
651 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
652 protected ValueNode genUnique(ValueNode x) {
14904
162d8fe89017 Revert 3e9a8ef2e0e1.
Josef Eisl <josef.eisl@jku.at>
parents: 14902
diff changeset
653 return (ValueNode) currentGraph.unique((Node & ValueNumberable) x);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
654 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
655
14948
bc72e5ed9752 AbstractBytecodeParser: rename ifNode to genIf.
Josef Eisl <josef.eisl@jku.at>
parents: 14947
diff changeset
656 protected ValueNode genIfNode(ValueNode condition, ValueNode falseSuccessor, ValueNode trueSuccessor, double d) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
657 return new IfNode((LogicNode) condition, (FixedNode) falseSuccessor, (FixedNode) trueSuccessor, d);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
658 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
659
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
660 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
661 protected void genThrow() {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
662 ValueNode exception = frameState.apop();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
663 append(new FixedGuardNode(currentGraph.unique(new IsNullNode(exception)), NullCheckException, InvalidateReprofile, true));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
664 lastInstr.setNext(handleException(exception, bci()));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
665 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
666
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
667 @Override
15837
6fe57ff3f02c Rename methods to have consistent names, allow subclasses of bytecode parsers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15470
diff changeset
668 protected ValueNode createCheckCast(ResolvedJavaType type, ValueNode object, JavaTypeProfile profileForTypeCheck, boolean forStoreCheck) {
19337
dd3e15cfe5b8 Canonicalize CheckCastNode to unique concrete subtype on creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19323
diff changeset
669 return CheckCastNode.create(type, object, profileForTypeCheck, forStoreCheck, currentGraph.getAssumptions());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
670 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
671
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
672 @Override
15837
6fe57ff3f02c Rename methods to have consistent names, allow subclasses of bytecode parsers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15470
diff changeset
673 protected ValueNode createInstanceOf(ResolvedJavaType type, ValueNode object, JavaTypeProfile profileForTypeCheck) {
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
674 return InstanceOfNode.create(type, object, profileForTypeCheck);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
675 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
676
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
677 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
678 protected ValueNode genConditional(ValueNode x) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
679 return new ConditionalNode((LogicNode) x);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
680 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
681
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
682 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
683 protected NewInstanceNode createNewInstance(ResolvedJavaType type, boolean fillContents) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
684 return new NewInstanceNode(type, fillContents);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
685 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
686
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
687 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
688 protected NewArrayNode createNewArray(ResolvedJavaType elementType, ValueNode length, boolean fillContents) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
689 return new NewArrayNode(elementType, length, fillContents);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
690 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
691
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
692 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
693 protected NewMultiArrayNode createNewMultiArray(ResolvedJavaType type, List<ValueNode> dimensions) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
694 return new NewMultiArrayNode(type, dimensions.toArray(new ValueNode[0]));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
695 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
696
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
697 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
698 protected ValueNode genLoadField(ValueNode receiver, ResolvedJavaField field) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
699 return new LoadFieldNode(receiver, field);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
700 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
701
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
702 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
703 protected void emitNullCheck(ValueNode receiver) {
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18374
diff changeset
704 if (StampTool.isPointerNonNull(receiver.stamp())) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
705 return;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
706 }
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
707 BytecodeExceptionNode exception = currentGraph.add(new BytecodeExceptionNode(metaAccess, NullPointerException.class));
18994
8b4ef818169c Make AbstractBeginNode an abstract class and create concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18993
diff changeset
708 AbstractBeginNode falseSucc = currentGraph.add(new BeginNode());
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
709 append(new IfNode(currentGraph.unique(new IsNullNode(receiver)), exception, falseSucc, 0.01));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
710 lastInstr = falseSucc;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
711
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14973
diff changeset
712 exception.setStateAfter(frameState.create(bci()));
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14973
diff changeset
713 exception.setNext(handleException(exception, bci()));
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
714 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
715
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
716 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
717 protected void emitBoundsCheck(ValueNode index, ValueNode length) {
18994
8b4ef818169c Make AbstractBeginNode an abstract class and create concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18993
diff changeset
718 AbstractBeginNode trueSucc = currentGraph.add(new BeginNode());
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
719 BytecodeExceptionNode exception = currentGraph.add(new BytecodeExceptionNode(metaAccess, ArrayIndexOutOfBoundsException.class, index));
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
720 append(new IfNode(currentGraph.unique(IntegerBelowNode.create(index, length, constantReflection)), trueSucc, exception, 0.99));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
721 lastInstr = trueSucc;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
722
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14973
diff changeset
723 exception.setStateAfter(frameState.create(bci()));
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14973
diff changeset
724 exception.setNext(handleException(exception, bci()));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
725 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
726
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
727 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
728 protected ValueNode genArrayLength(ValueNode x) {
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
729 return ArrayLengthNode.create(x, constantReflection);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
730 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
731
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
732 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
733 protected ValueNode genStoreField(ValueNode receiver, ResolvedJavaField field, ValueNode value) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
734 return new StoreFieldNode(receiver, field, value);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
735 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
736
16385
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
737 /**
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
738 * Ensure that concrete classes are at least linked before generating an invoke.
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
739 * Interfaces may never be linked so simply return true for them.
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
740 *
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
741 * @param target
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
742 * @return true if the declared holder is an interface or is linked
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
743 */
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
744 private boolean callTargetIsResolved(JavaMethod target) {
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
745 if (target instanceof ResolvedJavaMethod) {
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
746 ResolvedJavaMethod resolvedTarget = (ResolvedJavaMethod) target;
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
747 ResolvedJavaType resolvedType = resolvedTarget.getDeclaringClass();
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
748 return resolvedType.isInterface() || resolvedType.isLinked();
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
749 }
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
750 return false;
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
751 }
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
752
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
753 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
754 protected void genInvokeStatic(JavaMethod target) {
16385
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
755 if (callTargetIsResolved(target)) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
756 ResolvedJavaMethod resolvedTarget = (ResolvedJavaMethod) target;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
757 ResolvedJavaType holder = resolvedTarget.getDeclaringClass();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
758 if (!holder.isInitialized() && ResolveClassBeforeStaticInvoke.getValue()) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
759 handleUnresolvedInvoke(target, InvokeKind.Static);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
760 } else {
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18361
diff changeset
761 ValueNode[] args = frameState.popArguments(resolvedTarget.getSignature().getParameterCount(false));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
762 appendInvoke(InvokeKind.Static, resolvedTarget, args);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
763 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
764 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
765 handleUnresolvedInvoke(target, InvokeKind.Static);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
766 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
767 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
768
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
769 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
770 protected void genInvokeInterface(JavaMethod target) {
16385
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
771 if (callTargetIsResolved(target)) {
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18361
diff changeset
772 ValueNode[] args = frameState.popArguments(target.getSignature().getParameterCount(true));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
773 appendInvoke(InvokeKind.Interface, (ResolvedJavaMethod) target, args);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
774 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
775 handleUnresolvedInvoke(target, InvokeKind.Interface);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
776 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
777 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
778
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
779 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
780 protected void genInvokeDynamic(JavaMethod target) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
781 if (target instanceof ResolvedJavaMethod) {
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
782 JavaConstant appendix = constantPool.lookupAppendix(stream.readCPI4(), Bytecodes.INVOKEDYNAMIC);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
783 if (appendix != null) {
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14973
diff changeset
784 frameState.apush(ConstantNode.forConstant(appendix, metaAccess, currentGraph));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
785 }
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18361
diff changeset
786 ValueNode[] args = frameState.popArguments(target.getSignature().getParameterCount(false));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
787 appendInvoke(InvokeKind.Static, (ResolvedJavaMethod) target, args);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
788 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
789 handleUnresolvedInvoke(target, InvokeKind.Static);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
790 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
791 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
792
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
793 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
794 protected void genInvokeVirtual(JavaMethod target) {
16385
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
795 if (callTargetIsResolved(target)) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
796 /*
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
797 * Special handling for runtimes that rewrite an invocation of
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
798 * MethodHandle.invoke(...) or MethodHandle.invokeExact(...) to a static
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
799 * adapter. HotSpot does this - see
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
800 * https://wikis.oracle.com/display/HotSpotInternals/Method+handles
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
801 * +and+invokedynamic
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
802 */
15311
820c6d353358 added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents: 15294
diff changeset
803 boolean hasReceiver = !((ResolvedJavaMethod) target).isStatic();
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
804 JavaConstant appendix = constantPool.lookupAppendix(stream.readCPI(), Bytecodes.INVOKEVIRTUAL);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
805 if (appendix != null) {
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14973
diff changeset
806 frameState.apush(ConstantNode.forConstant(appendix, metaAccess, currentGraph));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
807 }
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18361
diff changeset
808 ValueNode[] args = frameState.popArguments(target.getSignature().getParameterCount(hasReceiver));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
809 if (hasReceiver) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
810 appendInvoke(InvokeKind.Virtual, (ResolvedJavaMethod) target, args);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
811 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
812 appendInvoke(InvokeKind.Static, (ResolvedJavaMethod) target, args);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
813 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
814 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
815 handleUnresolvedInvoke(target, InvokeKind.Virtual);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
816 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
817
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
818 }
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
819
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
820 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
821 protected void genInvokeSpecial(JavaMethod target) {
16385
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
822 if (callTargetIsResolved(target)) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
823 assert target != null;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
824 assert target.getSignature() != null;
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18361
diff changeset
825 ValueNode[] args = frameState.popArguments(target.getSignature().getParameterCount(true));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
826 appendInvoke(InvokeKind.Special, (ResolvedJavaMethod) target, args);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
827 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
828 handleUnresolvedInvoke(target, InvokeKind.Special);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
829 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
830 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
831
19136
29f2815009d4 Resolve simple method calls to Special invoke kind before processing the invoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19132
diff changeset
832 private void appendInvoke(InvokeKind initialInvokeKind, ResolvedJavaMethod initialTargetMethod, ValueNode[] args) {
29f2815009d4 Resolve simple method calls to Special invoke kind before processing the invoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19132
diff changeset
833 ResolvedJavaMethod targetMethod = initialTargetMethod;
29f2815009d4 Resolve simple method calls to Special invoke kind before processing the invoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19132
diff changeset
834 InvokeKind invokeKind = initialInvokeKind;
29f2815009d4 Resolve simple method calls to Special invoke kind before processing the invoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19132
diff changeset
835 if (initialInvokeKind.isIndirect()) {
29f2815009d4 Resolve simple method calls to Special invoke kind before processing the invoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19132
diff changeset
836 ResolvedJavaType contextType = this.frameState.method.getDeclaringClass();
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19241
diff changeset
837 ResolvedJavaMethod specialCallTarget = MethodCallTargetNode.findSpecialCallTarget(initialInvokeKind, args[0], initialTargetMethod, contextType);
19136
29f2815009d4 Resolve simple method calls to Special invoke kind before processing the invoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19132
diff changeset
838 if (specialCallTarget != null) {
29f2815009d4 Resolve simple method calls to Special invoke kind before processing the invoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19132
diff changeset
839 invokeKind = InvokeKind.Special;
29f2815009d4 Resolve simple method calls to Special invoke kind before processing the invoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19132
diff changeset
840 targetMethod = specialCallTarget;
29f2815009d4 Resolve simple method calls to Special invoke kind before processing the invoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19132
diff changeset
841 }
29f2815009d4 Resolve simple method calls to Special invoke kind before processing the invoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19132
diff changeset
842 }
29f2815009d4 Resolve simple method calls to Special invoke kind before processing the invoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19132
diff changeset
843
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
844 Kind resultType = targetMethod.getSignature().getReturnKind();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
845 if (DeoptALot.getValue()) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
846 append(new DeoptimizeNode(DeoptimizationAction.None, RuntimeConstraint));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
847 frameState.pushReturn(resultType, ConstantNode.defaultForKind(resultType, currentGraph));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
848 return;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
849 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
850
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
851 JavaType returnType = targetMethod.getSignature().getReturnType(method.getDeclaringClass());
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
852 if (graphBuilderConfig.eagerResolving()) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
853 returnType = returnType.resolve(targetMethod.getDeclaringClass());
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
854 }
18822
fad37aaed6d2 Add utilities isDirect and isIndirect to InvokeKind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18821
diff changeset
855 if (invokeKind.hasReceiver()) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
856 emitExplicitExceptions(args[0], null);
18822
fad37aaed6d2 Add utilities isDirect and isIndirect to InvokeKind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18821
diff changeset
857 if (invokeKind.isIndirect() && this.optimisticOpts.useTypeCheckHints()) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
858 JavaTypeProfile profile = profilingInfo.getTypeProfile(bci());
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
859 args[0] = TypeProfileProxyNode.proxify(args[0], profile);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
860 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
861 }
18822
fad37aaed6d2 Add utilities isDirect and isIndirect to InvokeKind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18821
diff changeset
862
19412
a9ff83864e8c rename: tryUsingInvocationPlugin -> tryInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19411
diff changeset
863 if (tryInvocationPlugin(args, targetMethod, resultType)) {
19417
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
864 if (GraalOptions.TraceInlineDuringParsing.getValue()) {
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
865 TTY.println(format("%sUsed invocation plugin for %s", nSpaces(currentDepth), targetMethod));
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
866 }
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
867 return;
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
868 }
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
869
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
870 if (tryAnnotatedInvocationPlugin(args, targetMethod)) {
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
871 if (GraalOptions.TraceInlineDuringParsing.getValue()) {
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
872 TTY.println(format("%sUsed annotated invocation plugin for %s", nSpaces(currentDepth), targetMethod));
19390
7f4201b633e7 renamed GraphBuilderPlugins to InvocationPlugins and consolidated it into GraphBuilderConfiguration; moved declaration of GraphBuilderPlugin sub-interfaces into GraphBuilderPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19387
diff changeset
873 }
7f4201b633e7 renamed GraphBuilderPlugins to InvocationPlugins and consolidated it into GraphBuilderConfiguration; moved declaration of GraphBuilderPlugin sub-interfaces into GraphBuilderPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19387
diff changeset
874 return;
7f4201b633e7 renamed GraphBuilderPlugins to InvocationPlugins and consolidated it into GraphBuilderConfiguration; moved declaration of GraphBuilderPlugin sub-interfaces into GraphBuilderPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19387
diff changeset
875 }
7f4201b633e7 renamed GraphBuilderPlugins to InvocationPlugins and consolidated it into GraphBuilderConfiguration; moved declaration of GraphBuilderPlugin sub-interfaces into GraphBuilderPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19387
diff changeset
876
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
877 if (tryInline(args, targetMethod, invokeKind, returnType)) {
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
878 return;
18912
9536c47658a2 Introduce new option InlineDuringParsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
879 }
19132
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
880
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
881 MethodCallTargetNode callTarget = currentGraph.add(createMethodCallTarget(invokeKind, targetMethod, args, returnType));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
882
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
883 // be conservative if information was not recorded (could result in endless
18822
fad37aaed6d2 Add utilities isDirect and isIndirect to InvokeKind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18821
diff changeset
884 // recompiles otherwise)
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
885 if (graphBuilderConfig.omitAllExceptionEdges() || (optimisticOpts.useExceptionProbability() && profilingInfo.getExceptionSeen(bci()) == TriState.FALSE)) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
886 createInvoke(callTarget, resultType);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
887 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
888 InvokeWithExceptionNode invoke = createInvokeWithException(callTarget, resultType);
18993
480bd3b1adcd Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18937
diff changeset
889 AbstractBeginNode beginNode = currentGraph.add(new KillingBeginNode(LocationIdentity.ANY_LOCATION));
18831
c142633a6304 Fix regression in graph builder related to removal of placeholder nodes. Do not create successor blocks for invokes without exception handler successor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18828
diff changeset
890 invoke.setNext(beginNode);
c142633a6304 Fix regression in graph builder related to removal of placeholder nodes. Do not create successor blocks for invokes without exception handler successor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18828
diff changeset
891 lastInstr = beginNode;
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
892 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
893 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
894
19412
a9ff83864e8c rename: tryUsingInvocationPlugin -> tryInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19411
diff changeset
895 private boolean tryInvocationPlugin(ValueNode[] args, ResolvedJavaMethod targetMethod, Kind resultType) {
19390
7f4201b633e7 renamed GraphBuilderPlugins to InvocationPlugins and consolidated it into GraphBuilderConfiguration; moved declaration of GraphBuilderPlugin sub-interfaces into GraphBuilderPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19387
diff changeset
896 InvocationPlugin plugin = graphBuilderConfig.getInvocationPlugins().lookupInvocation(targetMethod);
19155
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
897 if (plugin != null) {
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
898 int beforeStackSize = frameState.stackSize;
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
899 boolean needsNullCheck = !targetMethod.isStatic() && !StampTool.isPointerNonNull(args[0].stamp());
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
900 int nodeCount = currentGraph.getNodeCount();
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
901 Mark mark = needsNullCheck ? currentGraph.getMark() : null;
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
902 if (InvocationPlugin.execute(this, plugin, args)) {
19379
b720a1e02fa0 Add graph building time canonicalization for NormalizeCompareNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19375
diff changeset
903 assert beforeStackSize + resultType.getSlotCount() == frameState.stackSize : "plugin manipulated the stack incorrectly " + targetMethod;
19155
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
904 assert !needsNullCheck || containsNullCheckOf(currentGraph.getNewNodes(mark), args[0]) : "plugin needs to null check the receiver of " + targetMethod + ": " + args[0];
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
905 return true;
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
906 }
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
907 assert nodeCount == currentGraph.getNodeCount() : "plugin that returns false must not create new nodes";
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
908 assert beforeStackSize == frameState.stackSize : "plugin that returns false must modify the stack";
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
909 }
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
910 return false;
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
911 }
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
912
19417
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
913 private boolean tryAnnotatedInvocationPlugin(ValueNode[] args, ResolvedJavaMethod targetMethod) {
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
914 AnnotatedInvocationPlugin plugin = graphBuilderConfig.getAnnotatedInvocationPlugin();
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
915 return plugin != null && plugin.apply(this, targetMethod, args);
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
916 }
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
917
19155
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
918 private boolean containsNullCheckOf(NodeIterable<Node> nodes, Node value) {
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
919 for (Node n : nodes) {
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
920 if (n instanceof GuardingPiNode) {
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
921 GuardingPiNode pi = (GuardingPiNode) n;
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
922 if (pi.condition() instanceof IsNullNode) {
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
923 return ((IsNullNode) pi.condition()).getValue() == value;
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
924 }
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
925 }
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
926 }
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
927 return false;
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
928 }
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19147
diff changeset
929
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
930 private boolean tryInline(ValueNode[] args, ResolvedJavaMethod targetMethod, InvokeKind invokeKind, JavaType returnType) {
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
931 InlineInvokePlugin plugin = graphBuilderConfig.getInlineInvokePlugin();
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
932 if (plugin == null || !invokeKind.isDirect() || !targetMethod.canBeInlined()) {
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
933 return false;
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
934 }
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
935 ResolvedJavaMethod inlinedMethod = plugin.getInlinedMethod(this, targetMethod, args, returnType, currentDepth);
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
936 if (inlinedMethod != null) {
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
937 if (inlinedMethod != null) {
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
938 assert inlinedMethod.hasBytecodes();
19414
5b93a11c535c fixed equality test to use .equals() instead of ==
Doug Simon <doug.simon@oracle.com>
parents: 19412
diff changeset
939 if (TraceInlineDuringParsing.getValue()) {
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
940 int bci = this.bci();
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
941 StackTraceElement ste = this.method.asStackTraceElement(bci);
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
942 TTY.println(format("%s%s (%s:%d) inlining call to %s", nSpaces(currentDepth), method.getName(), ste.getFileName(), ste.getLineNumber(), inlinedMethod.format("%h.%n(%p)")));
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
943 }
19414
5b93a11c535c fixed equality test to use .equals() instead of ==
Doug Simon <doug.simon@oracle.com>
parents: 19412
diff changeset
944 parseAndInlineCallee(inlinedMethod, args, parsingReplacement || !inlinedMethod.equals(targetMethod));
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
945 plugin.postInline(inlinedMethod);
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
946 }
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
947 return true;
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
948 }
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
949
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
950 return false;
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
951 }
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
952
19409
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
953 private void parseAndInlineCallee(ResolvedJavaMethod targetMethod, ValueNode[] args, boolean isReplacement) {
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
954 BytecodeParser parser = new BytecodeParser(metaAccess, targetMethod, graphBuilderConfig, optimisticOpts, INVOCATION_ENTRY_BCI, isReplacement);
19132
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
955 final FrameState[] lazyFrameState = new FrameState[1];
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
956 HIRFrameStateBuilder startFrameState = new HIRFrameStateBuilder(targetMethod, currentGraph, () -> {
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
957 if (lazyFrameState[0] == null) {
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
958 lazyFrameState[0] = frameState.create(bci());
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
959 }
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
960 return lazyFrameState[0];
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
961 });
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
962 startFrameState.initializeFromArgumentsArray(args);
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
963 parser.build(currentDepth + 1, this.lastInstr, startFrameState);
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
964
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
965 FixedWithNextNode calleeBeforeReturnNode = parser.getBeforeReturnNode();
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
966 this.lastInstr = calleeBeforeReturnNode;
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
967 if (calleeBeforeReturnNode != null) {
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
968 ValueNode calleeReturnValue = parser.getReturnValue();
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
969 if (calleeReturnValue != null) {
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
970 frameState.push(calleeReturnValue.getKind().getStackKind(), calleeReturnValue);
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
971 }
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
972 }
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
973
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
974 FixedWithNextNode calleeBeforeUnwindNode = parser.getBeforeUnwindNode();
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
975 if (calleeBeforeUnwindNode != null) {
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
976 ValueNode calleeUnwindValue = parser.getUnwindValue();
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
977 assert calleeUnwindValue != null;
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
978 if (calleeBeforeUnwindNode instanceof AbstractMergeNode) {
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
979 AbstractMergeNode mergeNode = (AbstractMergeNode) calleeBeforeUnwindNode;
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
980 HIRFrameStateBuilder dispatchState = frameState.copy();
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
981 dispatchState.clearStack();
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
982 dispatchState.apush(calleeUnwindValue);
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
983 dispatchState.setRethrowException(true);
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
984 mergeNode.setStateAfter(dispatchState.create(bci()));
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
985
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
986 }
19132
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
987 calleeBeforeUnwindNode.setNext(handleException(calleeUnwindValue, bci()));
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
988 }
19323
a23984e249d2 record method dependencies if necessary when doing inlining during graph building
Doug Simon <doug.simon@oracle.com>
parents: 19253
diff changeset
989
19346
2b392a92e27b made it explicit that a StructuredGraph only records method dependencies for inlined methods - the root method is not recorded as it is already available in the 'method' field
Doug Simon <doug.simon@oracle.com>
parents: 19337
diff changeset
990 // Record inlined method dependency in the graph
2b392a92e27b made it explicit that a StructuredGraph only records method dependencies for inlined methods - the root method is not recorded as it is already available in the 'method' field
Doug Simon <doug.simon@oracle.com>
parents: 19337
diff changeset
991 if (currentGraph.isInlinedMethodRecordingEnabled()) {
2b392a92e27b made it explicit that a StructuredGraph only records method dependencies for inlined methods - the root method is not recorded as it is already available in the 'method' field
Doug Simon <doug.simon@oracle.com>
parents: 19337
diff changeset
992 currentGraph.getInlinedMethods().add(targetMethod);
19323
a23984e249d2 record method dependencies if necessary when doing inlining during graph building
Doug Simon <doug.simon@oracle.com>
parents: 19253
diff changeset
993 }
19132
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
994 }
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
995
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
996 protected MethodCallTargetNode createMethodCallTarget(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] args, JavaType returnType) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
997 return new MethodCallTargetNode(invokeKind, targetMethod, args, returnType);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
998 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
999
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1000 protected InvokeNode createInvoke(CallTargetNode callTarget, Kind resultType) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1001 InvokeNode invoke = append(new InvokeNode(callTarget, bci()));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1002 frameState.pushReturn(resultType, invoke);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1003 return invoke;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1004 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1005
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1006 protected InvokeWithExceptionNode createInvokeWithException(CallTargetNode callTarget, Kind resultType) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1007 DispatchBeginNode exceptionEdge = handleException(null, bci());
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1008 InvokeWithExceptionNode invoke = append(new InvokeWithExceptionNode(callTarget, exceptionEdge, bci()));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1009 frameState.pushReturn(resultType, invoke);
18831
c142633a6304 Fix regression in graph builder related to removal of placeholder nodes. Do not create successor blocks for invokes without exception handler successor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18828
diff changeset
1010 invoke.setStateAfter(frameState.create(stream.nextBCI()));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1011 return invoke;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1012 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1013
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1014 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1015 protected void genReturn(ValueNode x) {
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1016
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1017 if (this.currentDepth == 0) {
19381
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1018 frameState.setRethrowException(false);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1019 frameState.clearStack();
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1020 beforeReturn(x);
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1021 append(new ReturnNode(x));
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1022 } else {
19367
f9ccdf258dd4 Further reduction of begin node creation when inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19366
diff changeset
1023 if (returnCount == 1 || !controlFlowSplit) {
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1024 // There is only a single return.
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1025 this.returnValue = x;
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1026 this.beforeReturnNode = this.lastInstr;
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1027 this.lastInstr = null;
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1028 } else {
19381
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1029 frameState.setRethrowException(false);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1030 frameState.clearStack();
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1031 if (x != null) {
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1032 frameState.push(x.getKind(), x);
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1033 }
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1034 assert returnCount > 1;
19366
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1035 appendGoto(returnBlock(bci()));
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1036 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1037 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1038 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1039
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1040 private void beforeReturn(ValueNode x) {
16573
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
1041 if (graphBuilderConfig.insertNonSafepointDebugInfo()) {
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
1042 append(createInfoPointNode(InfopointReason.METHOD_END));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1043 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1044
15263
0b25b81414c9 Move various bci constants from FrameState (gral.nodes) to BytecodeFrame (graal.api.code)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15261
diff changeset
1045 synchronizedEpilogue(BytecodeFrame.AFTER_BCI, x);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1046 if (frameState.lockDepth() != 0) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1047 throw new BailoutException("unbalanced monitors");
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1048 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1049 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1050
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1051 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1052 protected MonitorEnterNode genMonitorEnter(ValueNode x) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1053 MonitorIdNode monitorId = currentGraph.add(new MonitorIdNode(frameState.lockDepth()));
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1054 MonitorEnterNode monitorEnter = append(new MonitorEnterNode(x, monitorId));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1055 frameState.pushLock(x, monitorId);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1056 return monitorEnter;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1057 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1058
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1059 @Override
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1060 protected MonitorExitNode genMonitorExit(ValueNode x, ValueNode escapedReturnValue) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1061 MonitorIdNode monitorId = frameState.peekMonitorId();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1062 ValueNode lockedObject = frameState.popLock();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1063 if (GraphUtil.originalValue(lockedObject) != GraphUtil.originalValue(x)) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1064 throw new BailoutException("unbalanced monitors: mismatch at monitorexit, %s != %s", GraphUtil.originalValue(x), GraphUtil.originalValue(lockedObject));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1065 }
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1066 MonitorExitNode monitorExit = append(new MonitorExitNode(x, monitorId, escapedReturnValue));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1067 return monitorExit;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1068 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1069
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1070 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1071 protected void genJsr(int dest) {
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
1072 BciBlock successor = currentBlock.getJsrSuccessor();
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1073 assert successor.startBci == dest : successor.startBci + " != " + dest + " @" + bci();
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
1074 JsrScope scope = currentBlock.getJsrScope();
17084
26f5733fb645 Fix the endianess issue, when using JSR/RET instruction and deoptimization happens in this subroutine
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16982
diff changeset
1075 int nextBci = getStream().nextBCI();
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
1076 if (!successor.getJsrScope().pop().equals(scope)) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1077 throw new JsrNotSupportedBailout("unstructured control flow (internal limitation)");
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1078 }
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
1079 if (successor.getJsrScope().nextReturnAddress() != nextBci) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1080 throw new JsrNotSupportedBailout("unstructured control flow (internal limitation)");
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1081 }
17084
26f5733fb645 Fix the endianess issue, when using JSR/RET instruction and deoptimization happens in this subroutine
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16982
diff changeset
1082 ConstantNode nextBciNode = getJsrConstant(nextBci);
26f5733fb645 Fix the endianess issue, when using JSR/RET instruction and deoptimization happens in this subroutine
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16982
diff changeset
1083 frameState.push(Kind.Int, nextBciNode);
19366
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1084 appendGoto(successor);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1085 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1086
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1087 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1088 protected void genRet(int localIndex) {
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
1089 BciBlock successor = currentBlock.getRetSuccessor();
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1090 ValueNode local = frameState.loadLocal(localIndex);
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
1091 JsrScope scope = currentBlock.getJsrScope();
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1092 int retAddress = scope.nextReturnAddress();
17084
26f5733fb645 Fix the endianess issue, when using JSR/RET instruction and deoptimization happens in this subroutine
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16982
diff changeset
1093 ConstantNode returnBciNode = getJsrConstant(retAddress);
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
1094 LogicNode guard = IntegerEqualsNode.create(local, returnBciNode, constantReflection);
17084
26f5733fb645 Fix the endianess issue, when using JSR/RET instruction and deoptimization happens in this subroutine
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16982
diff changeset
1095 guard = currentGraph.unique(guard);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1096 append(new FixedGuardNode(guard, JavaSubroutineMismatch, InvalidateReprofile));
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
1097 if (!successor.getJsrScope().equals(scope.pop())) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1098 throw new JsrNotSupportedBailout("unstructured control flow (ret leaves more than one scope)");
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1099 }
19366
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1100 appendGoto(successor);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1101 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1102
17084
26f5733fb645 Fix the endianess issue, when using JSR/RET instruction and deoptimization happens in this subroutine
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16982
diff changeset
1103 private ConstantNode getJsrConstant(long bci) {
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
1104 JavaConstant nextBciConstant = new RawConstant(bci);
17084
26f5733fb645 Fix the endianess issue, when using JSR/RET instruction and deoptimization happens in this subroutine
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16982
diff changeset
1105 Stamp nextBciStamp = StampFactory.forConstant(nextBciConstant);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1106 ConstantNode nextBciNode = new ConstantNode(nextBciConstant, nextBciStamp);
17084
26f5733fb645 Fix the endianess issue, when using JSR/RET instruction and deoptimization happens in this subroutine
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16982
diff changeset
1107 return currentGraph.unique(nextBciNode);
26f5733fb645 Fix the endianess issue, when using JSR/RET instruction and deoptimization happens in this subroutine
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16982
diff changeset
1108 }
26f5733fb645 Fix the endianess issue, when using JSR/RET instruction and deoptimization happens in this subroutine
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16982
diff changeset
1109
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1110 @Override
15028
7ee9decb2784 AbstractBytecodeParser: rework genIntegerSwitch.
Josef Eisl <josef.eisl@jku.at>
parents: 15027
diff changeset
1111 protected void genIntegerSwitch(ValueNode value, ArrayList<BciBlock> actualSuccessors, int[] keys, double[] keyProbabilities, int[] keySuccessors) {
19367
f9ccdf258dd4 Further reduction of begin node creation when inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19366
diff changeset
1112 this.controlFlowSplit = true;
15028
7ee9decb2784 AbstractBytecodeParser: rework genIntegerSwitch.
Josef Eisl <josef.eisl@jku.at>
parents: 15027
diff changeset
1113 double[] successorProbabilities = successorProbabilites(actualSuccessors.size(), keySuccessors, keyProbabilities);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1114 IntegerSwitchNode switchNode = append(new IntegerSwitchNode(value, actualSuccessors.size(), keys, keyProbabilities, keySuccessors));
15028
7ee9decb2784 AbstractBytecodeParser: rework genIntegerSwitch.
Josef Eisl <josef.eisl@jku.at>
parents: 15027
diff changeset
1115 for (int i = 0; i < actualSuccessors.size(); i++) {
7ee9decb2784 AbstractBytecodeParser: rework genIntegerSwitch.
Josef Eisl <josef.eisl@jku.at>
parents: 15027
diff changeset
1116 switchNode.setBlockSuccessor(i, createBlockTarget(successorProbabilities[i], actualSuccessors.get(i), frameState));
7ee9decb2784 AbstractBytecodeParser: rework genIntegerSwitch.
Josef Eisl <josef.eisl@jku.at>
parents: 15027
diff changeset
1117 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1118 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1119
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1120 @Override
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
1121 protected ConstantNode appendConstant(JavaConstant constant) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1122 assert constant != null;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1123 return ConstantNode.forConstant(constant, metaAccess, currentGraph);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1124 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1125
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
1126 @SuppressWarnings("unchecked")
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1127 @Override
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
1128 public ValueNode append(ValueNode v) {
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
1129 if (v.graph() != null) {
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
1130 // This node was already appended to the graph.
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
1131 return v;
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
1132 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1133 if (v instanceof ControlSinkNode) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1134 return append((ControlSinkNode) v);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1135 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1136 if (v instanceof ControlSplitNode) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1137 return append((ControlSplitNode) v);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1138 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1139 if (v instanceof FixedWithNextNode) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1140 return append((FixedWithNextNode) v);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1141 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1142 if (v instanceof FloatingNode) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1143 return append((FloatingNode) v);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1144 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1145 throw GraalInternalError.shouldNotReachHere("Can not append Node of type: " + v.getClass().getName());
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1146 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1147
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1148 public <T extends ControlSinkNode> T append(T fixed) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1149 assert !fixed.isAlive() && !fixed.isDeleted() : "instruction should not have been appended yet";
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1150 assert lastInstr.next() == null : "cannot append instruction to instruction which isn't end (" + lastInstr + "->" + lastInstr.next() + ")";
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1151 T added = currentGraph.add(fixed);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1152 lastInstr.setNext(added);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1153 lastInstr = null;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1154 return added;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1155 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1156
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1157 public <T extends ControlSplitNode> T append(T fixed) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1158 assert !fixed.isAlive() && !fixed.isDeleted() : "instruction should not have been appended yet";
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1159 assert lastInstr.next() == null : "cannot append instruction to instruction which isn't end (" + lastInstr + "->" + lastInstr.next() + ")";
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1160 T added = currentGraph.add(fixed);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1161 lastInstr.setNext(added);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1162 lastInstr = null;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1163 return added;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1164 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1165
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1166 public <T extends FixedWithNextNode> T append(T fixed) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1167 assert !fixed.isAlive() && !fixed.isDeleted() : "instruction should not have been appended yet";
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1168 assert lastInstr.next() == null : "cannot append instruction to instruction which isn't end (" + lastInstr + "->" + lastInstr.next() + ")";
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1169 T added = currentGraph.add(fixed);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1170 lastInstr.setNext(added);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1171 lastInstr = added;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1172 return added;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1173 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1174
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1175 public <T extends FloatingNode> T append(T v) {
19374
2412408a4319 Fixes to the graph builder after recent changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
1176 if (v.graph() != null) {
2412408a4319 Fixes to the graph builder after recent changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
1177 return v;
2412408a4319 Fixes to the graph builder after recent changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
1178 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1179 T added = currentGraph.unique(v);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1180 return added;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1181 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1182
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1183 private Target checkLoopExit(FixedNode target, BciBlock targetBlock, HIRFrameStateBuilder state) {
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1184 if (currentBlock != null && !explodeLoops) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1185 long exits = currentBlock.loops & ~targetBlock.loops;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1186 if (exits != 0) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1187 LoopExitNode firstLoopExit = null;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1188 LoopExitNode lastLoopExit = null;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1189
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1190 int pos = 0;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1191 ArrayList<BciBlock> exitLoops = new ArrayList<>(Long.bitCount(exits));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1192 do {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1193 long lMask = 1L << pos;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1194 if ((exits & lMask) != 0) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1195 exitLoops.add(loopHeaders[pos]);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1196 exits &= ~lMask;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1197 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1198 pos++;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1199 } while (exits != 0);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1200
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1201 Collections.sort(exitLoops, new Comparator<BciBlock>() {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1202
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1203 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1204 public int compare(BciBlock o1, BciBlock o2) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1205 return Long.bitCount(o2.loops) - Long.bitCount(o1.loops);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1206 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1207 });
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1208
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1209 int bci = targetBlock.startBci;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1210 if (targetBlock instanceof ExceptionDispatchBlock) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1211 bci = ((ExceptionDispatchBlock) targetBlock).deoptBci;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1212 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1213 HIRFrameStateBuilder newState = state.copy();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1214 for (BciBlock loop : exitLoops) {
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1215 LoopBeginNode loopBegin = (LoopBeginNode) loop.getFirstInstruction(this.getCurrentDimension());
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1216 LoopExitNode loopExit = currentGraph.add(new LoopExitNode(loopBegin));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1217 if (lastLoopExit != null) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1218 lastLoopExit.setNext(loopExit);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1219 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1220 if (firstLoopExit == null) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1221 firstLoopExit = loopExit;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1222 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1223 lastLoopExit = loopExit;
19366
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1224 Debug.log("Target %s Exits %s, scanning framestates...", targetBlock, loop);
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1225 newState.insertLoopProxies(loopExit, (HIRFrameStateBuilder) loop.getEntryState(this.getCurrentDimension()));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1226 loopExit.setStateAfter(newState.create(bci));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1227 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1228
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1229 lastLoopExit.setNext(target);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1230 return new Target(firstLoopExit, newState);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1231 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1232 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1233 return new Target(target, state);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1234 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1235
15030
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1236 private FixedNode createTarget(double probability, BciBlock block, HIRFrameStateBuilder stateAfter) {
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1237 assert probability >= 0 && probability <= 1.01 : probability;
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1238 if (isNeverExecutedCode(probability)) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1239 return currentGraph.add(new DeoptimizeNode(InvalidateReprofile, UnreachedCode));
15030
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1240 } else {
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1241 assert block != null;
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1242 return createTarget(block, stateAfter);
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1243 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1244 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1245
15030
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1246 private FixedNode createTarget(BciBlock block, HIRFrameStateBuilder state) {
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1247 return createTarget(block, state, false);
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1248 }
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1249
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1250 private FixedNode createTarget(BciBlock block, HIRFrameStateBuilder state, boolean isGoto) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1251 assert block != null && state != null;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1252 assert !block.isExceptionEntry || state.stackSize() == 1;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1253
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1254 int operatingDimension = this.getCurrentDimension();
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1255 if (this.explodeLoops && this.explodeLoopsContext != null && !this.explodeLoopsContext.isEmpty()) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1256 int i;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1257 for (i = explodeLoopsContext.size() - 1; i >= 0; --i) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1258 ExplodedLoopContext context = explodeLoopsContext.elementAt(i);
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1259 if (context.header == block) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1260
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1261 // We have a hit on our current explosion context loop begin.
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1262 if (context.targetPeelIteration == -1) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1263 // This is the first hit => allocate a new dimension and at the same
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1264 // time mark the context loop begin as hit during the current
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1265 // iteration.
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1266 context.targetPeelIteration = nextPeelIteration++;
19414
5b93a11c535c fixed equality test to use .equals() instead of ==
Doug Simon <doug.simon@oracle.com>
parents: 19412
diff changeset
1267 if (nextPeelIteration > MaximumLoopExplosionCount.getValue()) {
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1268 throw new BailoutException("too many loop explosion interations - does the explosion not terminate?");
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1269 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1270 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1271
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1272 // Operate on the target dimension.
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1273 operatingDimension = context.targetPeelIteration;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1274 break;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1275 } else if (block.getId() > context.header.getId() && block.getId() <= context.header.loopEnd) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1276 // We hit the range of this context.
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1277 operatingDimension = context.peelIteration;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1278 break;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1279 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1280 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1281
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1282 if (i == -1) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1283 // I did not find a dimension.
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1284 operatingDimension = 0;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1285 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1286 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1287
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1288 if (block.getFirstInstruction(operatingDimension) == null) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1289 /*
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1290 * This is the first time we see this block as a branch target. Create and
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1291 * return a placeholder that later can be replaced with a MergeNode when we see
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1292 * this block again.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1293 */
18828
161503950494 Avoid insertion of block placeholder node. Use begin node instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18825
diff changeset
1294 FixedNode targetNode;
19369
aac293bfdced Fix an issue that could lead to scheduling problems of box nodes after recent graph builder changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19367
diff changeset
1295 if (isGoto && (block.getPredecessorCount() == 1 || !controlFlowSplit) && !block.isLoopHeader && (currentBlock.loops & ~block.loops) == 0) {
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1296 block.setFirstInstruction(operatingDimension, lastInstr);
19366
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1297 lastInstr = null;
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1298 } else {
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1299 block.setFirstInstruction(operatingDimension, currentGraph.add(new BeginNode()));
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1300 }
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1301 targetNode = block.getFirstInstruction(operatingDimension);
18828
161503950494 Avoid insertion of block placeholder node. Use begin node instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18825
diff changeset
1302 Target target = checkLoopExit(targetNode, block, state);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1303 FixedNode result = target.fixed;
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1304 AbstractFrameStateBuilder<?, ?> entryState = target.state == state ? state.copy() : target.state;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1305 block.setEntryState(operatingDimension, entryState);
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1306 entryState.clearNonLiveLocals(block, liveness, true);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1307
18828
161503950494 Avoid insertion of block placeholder node. Use begin node instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18825
diff changeset
1308 Debug.log("createTarget %s: first visit, result: %s", block, targetNode);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1309 return result;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1310 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1311
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1312 // We already saw this block before, so we have to merge states.
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1313 if (!((HIRFrameStateBuilder) block.getEntryState(operatingDimension)).isCompatibleWith(state)) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1314 throw new BailoutException("stacks do not match; bytecodes would not verify");
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1315 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1316
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1317 if (block.getFirstInstruction(operatingDimension) instanceof LoopBeginNode) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1318 assert this.explodeLoops || (block.isLoopHeader && currentBlock.getId() >= block.getId()) : "must be backward branch";
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1319 /*
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1320 * Backward loop edge. We need to create a special LoopEndNode and merge with
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1321 * the loop begin node created before.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1322 */
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1323 LoopBeginNode loopBegin = (LoopBeginNode) block.getFirstInstruction(operatingDimension);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1324 Target target = checkLoopExit(currentGraph.add(new LoopEndNode(loopBegin)), block, state);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1325 FixedNode result = target.fixed;
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1326 ((HIRFrameStateBuilder) block.getEntryState(operatingDimension)).merge(loopBegin, target.state);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1327
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1328 Debug.log("createTarget %s: merging backward branch to loop header %s, result: %s", block, loopBegin, result);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1329 return result;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1330 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1331 assert currentBlock == null || currentBlock.getId() < block.getId() : "must not be backward branch";
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1332 assert block.getFirstInstruction(operatingDimension).next() == null : "bytecodes already parsed for block";
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1333
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1334 if (block.getFirstInstruction(operatingDimension) instanceof AbstractBeginNode && !(block.getFirstInstruction(operatingDimension) instanceof AbstractMergeNode)) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1335 /*
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1336 * This is the second time we see this block. Create the actual MergeNode and
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1337 * the End Node for the already existing edge. For simplicity, we leave the
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1338 * placeholder in the graph and just append the new nodes after the placeholder.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1339 */
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1340 AbstractBeginNode placeholder = (AbstractBeginNode) block.getFirstInstruction(operatingDimension);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1341
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1342 // The EndNode for the already existing edge.
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1343 AbstractEndNode end = currentGraph.add(new EndNode());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1344 // The MergeNode that replaces the placeholder.
18996
46c2e70d54ad Make AbstractMergeNode abstract and introduce concrete subclass MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
1345 AbstractMergeNode mergeNode = currentGraph.add(new MergeNode());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1346 FixedNode next = placeholder.next();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1347
18831
c142633a6304 Fix regression in graph builder related to removal of placeholder nodes. Do not create successor blocks for invokes without exception handler successor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18828
diff changeset
1348 if (placeholder.predecessor() instanceof ControlSplitNode) {
c142633a6304 Fix regression in graph builder related to removal of placeholder nodes. Do not create successor blocks for invokes without exception handler successor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18828
diff changeset
1349 placeholder.setNext(end);
c142633a6304 Fix regression in graph builder related to removal of placeholder nodes. Do not create successor blocks for invokes without exception handler successor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18828
diff changeset
1350 } else {
c142633a6304 Fix regression in graph builder related to removal of placeholder nodes. Do not create successor blocks for invokes without exception handler successor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18828
diff changeset
1351 placeholder.replaceAtPredecessor(end);
c142633a6304 Fix regression in graph builder related to removal of placeholder nodes. Do not create successor blocks for invokes without exception handler successor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18828
diff changeset
1352 placeholder.safeDelete();
c142633a6304 Fix regression in graph builder related to removal of placeholder nodes. Do not create successor blocks for invokes without exception handler successor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18828
diff changeset
1353 }
c142633a6304 Fix regression in graph builder related to removal of placeholder nodes. Do not create successor blocks for invokes without exception handler successor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18828
diff changeset
1354
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1355 mergeNode.addForwardEnd(end);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1356 mergeNode.setNext(next);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1357
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1358 block.setFirstInstruction(operatingDimension, mergeNode);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1359 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1360
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1361 AbstractMergeNode mergeNode = (AbstractMergeNode) block.getFirstInstruction(operatingDimension);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1362
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1363 // The EndNode for the newly merged edge.
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1364 AbstractEndNode newEnd = currentGraph.add(new EndNode());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1365 Target target = checkLoopExit(newEnd, block, state);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1366 FixedNode result = target.fixed;
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1367 ((HIRFrameStateBuilder) block.getEntryState(operatingDimension)).merge(mergeNode, target.state);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1368 mergeNode.addForwardEnd(newEnd);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1369
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1370 Debug.log("createTarget %s: merging state, result: %s", block, result);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1371 return result;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1372 }
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1373
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1374 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1375 * Returns a block begin node with the specified state. If the specified probability is
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1376 * 0, the block deoptimizes immediately.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1377 */
18993
480bd3b1adcd Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18937
diff changeset
1378 private AbstractBeginNode createBlockTarget(double probability, BciBlock block, HIRFrameStateBuilder stateAfter) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1379 FixedNode target = createTarget(probability, block, stateAfter);
18994
8b4ef818169c Make AbstractBeginNode an abstract class and create concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18993
diff changeset
1380 AbstractBeginNode begin = BeginNode.begin(target);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1381
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15032
diff changeset
1382 assert !(target instanceof DeoptimizeNode && begin instanceof BeginStateSplitNode && ((BeginStateSplitNode) begin).stateAfter() != null) : "We are not allowed to set the stateAfter of the begin node, because we have to deoptimize "
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1383 + "to a bci _before_ the actual if, so that the interpreter can update the profiling information.";
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1384 return begin;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1385 }
5051
2ab527c53dba another fix for goto's deopt case
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5050
diff changeset
1386
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1387 private ValueNode synchronizedObject(HIRFrameStateBuilder state, ResolvedJavaMethod target) {
15311
820c6d353358 added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents: 15294
diff changeset
1388 if (target.isStatic()) {
18361
6ac7e9c85be6 Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1389 return appendConstant(target.getDeclaringClass().getJavaClass());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1390 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1391 return state.loadLocal(0);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1392 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1393 }
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1394
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18917
diff changeset
1395 protected void processBlock(BytecodeParser parser, BciBlock block) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1396 // Ignore blocks that have no predecessors by the time their bytecodes are parsed
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1397 if (block == null || block.getFirstInstruction(this.getCurrentDimension()) == null) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1398 Debug.log("Ignoring block %s", block);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1399 return;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1400 }
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1401 try (Indent indent = Debug.logAndIndent("Parsing block %s firstInstruction: %s loopHeader: %b", block, block.getFirstInstruction(this.getCurrentDimension()), block.isLoopHeader)) {
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1402
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1403 lastInstr = block.getFirstInstruction(this.getCurrentDimension());
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1404 frameState = (HIRFrameStateBuilder) block.getEntryState(this.getCurrentDimension());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1405 parser.setCurrentFrameState(frameState);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1406 currentBlock = block;
4614
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4554
diff changeset
1407
18995
a2cb19764970 Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18994
diff changeset
1408 if (lastInstr instanceof AbstractMergeNode) {
19369
aac293bfdced Fix an issue that could lead to scheduling problems of box nodes after recent graph builder changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19367
diff changeset
1409
aac293bfdced Fix an issue that could lead to scheduling problems of box nodes after recent graph builder changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19367
diff changeset
1410 AbstractMergeNode abstractMergeNode = (AbstractMergeNode) lastInstr;
aac293bfdced Fix an issue that could lead to scheduling problems of box nodes after recent graph builder changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19367
diff changeset
1411 if (abstractMergeNode.stateAfter() == null) {
aac293bfdced Fix an issue that could lead to scheduling problems of box nodes after recent graph builder changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19367
diff changeset
1412 int bci = block.startBci;
aac293bfdced Fix an issue that could lead to scheduling problems of box nodes after recent graph builder changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19367
diff changeset
1413 if (block instanceof ExceptionDispatchBlock) {
aac293bfdced Fix an issue that could lead to scheduling problems of box nodes after recent graph builder changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19367
diff changeset
1414 bci = ((ExceptionDispatchBlock) block).deoptBci;
aac293bfdced Fix an issue that could lead to scheduling problems of box nodes after recent graph builder changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19367
diff changeset
1415 }
aac293bfdced Fix an issue that could lead to scheduling problems of box nodes after recent graph builder changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19367
diff changeset
1416 abstractMergeNode.setStateAfter(frameState.create(bci));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1417 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1418 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14851
diff changeset
1419
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1420 if (block == returnBlock) {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1421 Kind returnKind = method.getSignature().getReturnKind().getStackKind();
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1422 ValueNode x = returnKind == Kind.Void ? null : frameState.pop(returnKind);
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1423 assert frameState.stackSize() == 0;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1424 beforeReturn(x);
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1425 this.returnValue = x;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1426 this.beforeReturnNode = this.lastInstr;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1427 } else if (block == unwindBlock) {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1428 if (currentDepth == 0) {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1429 frameState.setRethrowException(false);
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1430 createUnwind();
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1431 } else {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1432 ValueNode exception = frameState.apop();
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1433 this.unwindValue = exception;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1434 this.beforeUnwindNode = this.lastInstr;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1435 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1436 } else if (block instanceof ExceptionDispatchBlock) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1437 createExceptionDispatch((ExceptionDispatchBlock) block);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1438 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1439 frameState.setRethrowException(false);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1440 iterateBytecodesForBlock(block);
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14851
diff changeset
1441 }
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14851
diff changeset
1442 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1443 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1444
18916
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1445 /**
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1446 * Remove loop header without loop ends. This can happen with degenerated loops like
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1447 * this one:
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1448 *
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1449 * <pre>
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1450 * for (;;) {
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1451 * try {
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1452 * break;
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1453 * } catch (UnresolvedException iioe) {
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1454 * }
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1455 * }
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1456 * </pre>
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1457 */
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1458 private void connectLoopEndToBegin() {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1459 for (LoopBeginNode begin : currentGraph.getNodes(LoopBeginNode.class)) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1460 if (begin.loopEnds().isEmpty()) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1461 assert begin.forwardEndCount() == 1;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1462 currentGraph.reduceDegenerateLoopBegin(begin);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1463 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1464 GraphUtil.normalizeLoopBegin(begin);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1465 }
9003
a8fea2979e63 eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents: 8660
diff changeset
1466 }
a8fea2979e63 eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents: 8660
diff changeset
1467 }
a8fea2979e63 eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents: 8660
diff changeset
1468
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1469 private void createUnwind() {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1470 assert frameState.stackSize() == 1 : frameState;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1471 ValueNode exception = frameState.apop();
15263
0b25b81414c9 Move various bci constants from FrameState (gral.nodes) to BytecodeFrame (graal.api.code)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15261
diff changeset
1472 synchronizedEpilogue(BytecodeFrame.AFTER_EXCEPTION_BCI, null);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1473 append(new UnwindNode(exception));
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1474 }
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1475
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1476 private void synchronizedEpilogue(int bci, ValueNode currentReturnValue) {
15267
98d45600222c Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15266
diff changeset
1477 if (method.isSynchronized()) {
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1478 MonitorExitNode monitorExit = genMonitorExit(methodSynchronizedObject, currentReturnValue);
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1479 if (currentReturnValue != null) {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1480 frameState.push(currentReturnValue.getKind(), currentReturnValue);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1481 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1482 monitorExit.setStateAfter(frameState.create(bci));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1483 assert !frameState.rethrowException();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1484 }
6676
090868cbcda6 Graal infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6648
diff changeset
1485 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1486
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1487 private void createExceptionDispatch(ExceptionDispatchBlock block) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1488 assert frameState.stackSize() == 1 : frameState;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1489 if (block.handler.isCatchAll()) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1490 assert block.getSuccessorCount() == 1;
19366
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1491 appendGoto(block.getSuccessor(0));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1492 return;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1493 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1494
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1495 JavaType catchType = block.handler.getCatchType();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1496 if (graphBuilderConfig.eagerResolving()) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1497 catchType = lookupType(block.handler.catchTypeCPI(), INSTANCEOF);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1498 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1499 boolean initialized = (catchType instanceof ResolvedJavaType);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1500 if (initialized && graphBuilderConfig.getSkippedExceptionTypes() != null) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1501 ResolvedJavaType resolvedCatchType = (ResolvedJavaType) catchType;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1502 for (ResolvedJavaType skippedType : graphBuilderConfig.getSkippedExceptionTypes()) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1503 if (skippedType.isAssignableFrom(resolvedCatchType)) {
15220
ccf0c5a1edf1 Use a synthetic BCI instead of a random BCI (the first parsed bytecode that could throw an exception) for the exception unwind block
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15200
diff changeset
1504 BciBlock nextBlock = block.getSuccessorCount() == 1 ? unwindBlock() : block.getSuccessor(1);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1505 ValueNode exception = frameState.stackAt(0);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1506 FixedNode trueSuccessor = currentGraph.add(new DeoptimizeNode(InvalidateReprofile, UnreachedCode));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1507 FixedNode nextDispatch = createTarget(nextBlock, frameState);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1508 append(new IfNode(currentGraph.unique(new InstanceOfNode((ResolvedJavaType) catchType, exception, null)), trueSuccessor, nextDispatch, 0));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1509 return;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1510 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1511 }
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1512 }
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1513
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1514 if (initialized) {
15220
ccf0c5a1edf1 Use a synthetic BCI instead of a random BCI (the first parsed bytecode that could throw an exception) for the exception unwind block
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15200
diff changeset
1515 BciBlock nextBlock = block.getSuccessorCount() == 1 ? unwindBlock() : block.getSuccessor(1);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1516 ValueNode exception = frameState.stackAt(0);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1517 CheckCastNode checkCast = currentGraph.add(new CheckCastNode((ResolvedJavaType) catchType, exception, null, false));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1518 frameState.apop();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1519 frameState.push(Kind.Object, checkCast);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1520 FixedNode catchSuccessor = createTarget(block.getSuccessor(0), frameState);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1521 frameState.apop();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1522 frameState.push(Kind.Object, exception);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1523 FixedNode nextDispatch = createTarget(nextBlock, frameState);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1524 checkCast.setNext(catchSuccessor);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1525 append(new IfNode(currentGraph.unique(new InstanceOfNode((ResolvedJavaType) catchType, exception, null)), checkCast, nextDispatch, 0.5));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1526 } else {
18361
6ac7e9c85be6 Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1527 handleUnresolvedExceptionType(catchType);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1528 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1529 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1530
19366
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1531 private void appendGoto(BciBlock successor) {
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1532 FixedNode targetInstr = createTarget(successor, frameState, true);
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1533 if (lastInstr != null && lastInstr != targetInstr) {
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1534 lastInstr.setNext(targetInstr);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1535 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1536 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1537
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1538 private boolean isBlockEnd(Node n) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1539 return n instanceof ControlSplitNode || n instanceof ControlSinkNode;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1540 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1541
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1542 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1543 protected void iterateBytecodesForBlock(BciBlock block) {
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1544 if (block.isLoopHeader && !explodeLoops) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1545 // Create the loop header block, which later will merge the backward branches of
18912
9536c47658a2 Introduce new option InlineDuringParsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
1546 // the loop.
19367
f9ccdf258dd4 Further reduction of begin node creation when inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19366
diff changeset
1547 controlFlowSplit = true;
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1548 AbstractEndNode preLoopEnd = currentGraph.add(new EndNode());
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1549 LoopBeginNode loopBegin = currentGraph.add(new LoopBeginNode());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1550 lastInstr.setNext(preLoopEnd);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1551 // Add the single non-loop predecessor of the loop header.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1552 loopBegin.addForwardEnd(preLoopEnd);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1553 lastInstr = loopBegin;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1554
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1555 // Create phi functions for all local variables and operand stack slots.
19173
396ca3a22ee8 Perform analysis for locals changed in the loop and avoid creating phis for loop invariant locals.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19171
diff changeset
1556 frameState.insertLoopPhis(liveness, block.loopId, loopBegin);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1557 loopBegin.setStateAfter(frameState.create(block.startBci));
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1558
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1559 /*
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1560 * We have seen all forward branches. All subsequent backward branches will
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1561 * merge to the loop header. This ensures that the loop header has exactly one
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1562 * non-loop predecessor.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1563 */
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1564 block.setFirstInstruction(this.getCurrentDimension(), loopBegin);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1565 /*
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1566 * We need to preserve the frame state builder of the loop header so that we can
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1567 * merge values for phi functions, so make a copy of it.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1568 */
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1569 block.setEntryState(this.getCurrentDimension(), frameState.copy());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1570
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1571 Debug.log(" created loop header %s", loopBegin);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1572 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1573 assert lastInstr.next() == null : "instructions already appended at block " + block;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1574 Debug.log(" frameState: %s", frameState);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1575
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1576 lastInstr = finishInstruction(lastInstr, frameState);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1577
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1578 int endBCI = stream.endBCI();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1579
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1580 stream.setBCI(block.startBci);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1581 int bci = block.startBci;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1582 BytecodesParsed.add(block.endBci - bci);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1583
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1584 while (bci < endBCI) {
16573
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
1585 if (graphBuilderConfig.insertNonSafepointDebugInfo() && lnt != null) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1586 currentLineNumber = lnt.getLineNumber(bci);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1587 if (currentLineNumber != previousLineNumber) {
16573
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
1588 append(createInfoPointNode(InfopointReason.LINE_NUMBER));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1589 previousLineNumber = currentLineNumber;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1590 }
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1591 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1592
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1593 // read the opcode
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1594 int opcode = stream.currentBC();
19387
fc390dcb0ba5 Enable bytecode instruction level tracing only when assertions are enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19382
diff changeset
1595 assert traceState();
fc390dcb0ba5 Enable bytecode instruction level tracing only when assertions are enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19382
diff changeset
1596 assert traceInstruction(bci, opcode, bci == block.startBci);
18920
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
1597 if (currentDepth == 0 && bci == entryBCI) {
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
1598 if (block.getJsrScope() != JsrScope.EMPTY_SCOPE) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1599 throw new BailoutException("OSR into a JSR scope is not supported");
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1600 }
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1601 EntryMarkerNode x = append(new EntryMarkerNode());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1602 frameState.insertProxies(x);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1603 x.setStateAfter(frameState.create(bci));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1604 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1605 processBytecode(bci, opcode);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1606
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1607 if (lastInstr == null || isBlockEnd(lastInstr) || lastInstr.next() != null) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1608 break;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1609 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1610
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1611 stream.next();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1612 bci = stream.currentBCI();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1613
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1614 if (bci > block.endBci) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1615 frameState.clearNonLiveLocals(currentBlock, liveness, false);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1616 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1617 if (lastInstr instanceof StateSplit) {
18997
2ccaaf5a6be4 Fix class comparison statements for BeginNode and MergeNode to reflect new class hierarchy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18996
diff changeset
1618 if (lastInstr instanceof BeginNode) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1619 // BeginNodes do not need a frame state
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1620 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1621 StateSplit stateSplit = (StateSplit) lastInstr;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1622 if (stateSplit.stateAfter() == null) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1623 stateSplit.setStateAfter(frameState.create(bci));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1624 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1625 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1626 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1627 lastInstr = finishInstruction(lastInstr, frameState);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1628 if (bci < endBCI) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1629 if (bci > block.endBci) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1630 assert !block.getSuccessor(0).isExceptionEntry;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1631 assert block.numNormalSuccessors() == 1;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1632 // we fell through to the next block, add a goto and break
19366
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1633 appendGoto(block.getSuccessor(0));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1634 break;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1635 }
5375
3035b6b881d9 removed stateAfter field from FixedWithNextNode - now only StateSplit implementations have this field
Doug Simon <doug.simon@oracle.com>
parents: 5373
diff changeset
1636 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1637 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1638 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1639
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1640 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1641 * A hook for derived classes to modify the last instruction or add other instructions.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1642 *
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1643 * @param instr The last instruction (= fixed node) which was added.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1644 * @param state The current frame state.
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14904
diff changeset
1645 * @return Returns the (new) last instruction.
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1646 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1647 protected FixedWithNextNode finishInstruction(FixedWithNextNode instr, HIRFrameStateBuilder state) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1648 return instr;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1649 }
14758
c612c2742a4f extend graph builder and CompilationResult for substrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14746
diff changeset
1650
16573
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
1651 private InfopointNode createInfoPointNode(InfopointReason reason) {
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
1652 if (graphBuilderConfig.insertFullDebugInfo()) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1653 return new FullInfopointNode(reason, frameState.create(bci()));
16573
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
1654 } else {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1655 return new SimpleInfopointNode(reason, new BytecodePosition(null, method, bci()));
16573
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
1656 }
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
1657 }
a2ec1ac769e4 Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
1658
19387
fc390dcb0ba5 Enable bytecode instruction level tracing only when assertions are enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19382
diff changeset
1659 private boolean traceState() {
18817
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
1660 if (Debug.isEnabled() && Options.TraceBytecodeParserLevel.getValue() >= TRACELEVEL_STATE && Debug.isLogEnabled()) {
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
1661 traceStateHelper();
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
1662 }
19387
fc390dcb0ba5 Enable bytecode instruction level tracing only when assertions are enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19382
diff changeset
1663 return true;
18817
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
1664 }
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
1665
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
1666 private void traceStateHelper() {
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
1667 Debug.log(String.format("| state [nr locals = %d, stack depth = %d, method = %s]", frameState.localsSize(), frameState.stackSize(), method));
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
1668 for (int i = 0; i < frameState.localsSize(); ++i) {
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
1669 ValueNode value = frameState.localAt(i);
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
1670 Debug.log(String.format("| local[%d] = %-8s : %s", i, value == null ? "bogus" : value.getKind().getJavaName(), value));
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
1671 }
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
1672 for (int i = 0; i < frameState.stackSize(); ++i) {
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
1673 ValueNode value = frameState.stackAt(i);
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
1674 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
1675 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1676 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1677
14947
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1678 @Override
14948
bc72e5ed9752 AbstractBytecodeParser: rename ifNode to genIf.
Josef Eisl <josef.eisl@jku.at>
parents: 14947
diff changeset
1679 protected void genIf(ValueNode x, Condition cond, ValueNode y) {
14947
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1680 // assert !x.isDeleted() && !y.isDeleted();
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1681 // assert currentBlock.numNormalSuccessors() == 2;
19365
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1682 assert currentBlock.getSuccessorCount() == 2;
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1683 BciBlock trueBlock = currentBlock.getSuccessor(0);
bef4a591e0b3 Avoid creating the begin block for single predecessor returns when inlining during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19364
diff changeset
1684 BciBlock falseBlock = currentBlock.getSuccessor(1);
14947
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1685 if (trueBlock == falseBlock) {
19366
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1686 appendGoto(trueBlock);
14947
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1687 return;
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1688 }
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1689
16886
b61b88c9c103 Make handling of removeNeverExecutedCode more consistent
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16841
diff changeset
1690 double probability = branchProbability();
14947
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1691
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1692 // the mirroring and negation operations get the condition into canonical form
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1693 boolean mirror = cond.canonicalMirror();
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1694 boolean negate = cond.canonicalNegate();
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1695
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1696 ValueNode a = mirror ? y : x;
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1697 ValueNode b = mirror ? x : y;
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1698
19372
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1699 LogicNode condition;
14947
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1700 assert !a.getKind().isNumericFloat();
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1701 if (cond == Condition.EQ || cond == Condition.NE) {
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1702 if (a.getKind() == Kind.Object) {
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1703 condition = genObjectEquals(a, b);
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1704 } else {
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1705 condition = genIntegerEquals(a, b);
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1706 }
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1707 } else {
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1708 assert a.getKind() != Kind.Object && !cond.isUnsigned();
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1709 condition = genIntegerLessThan(a, b);
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1710 }
19373
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19372
diff changeset
1711
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19372
diff changeset
1712 if (condition instanceof LogicNegationNode) {
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19372
diff changeset
1713 LogicNegationNode logicNegationNode = (LogicNegationNode) condition;
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19372
diff changeset
1714 negate = !negate;
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19372
diff changeset
1715 condition = logicNegationNode.getValue();
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19372
diff changeset
1716 }
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19372
diff changeset
1717
19117
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1718 if (condition instanceof LogicConstantNode) {
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1719 LogicConstantNode constantLogicNode = (LogicConstantNode) condition;
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1720 boolean value = constantLogicNode.getValue();
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1721 if (negate) {
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1722 value = !value;
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1723 }
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1724 BciBlock nextBlock = falseBlock;
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1725 if (value) {
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1726 nextBlock = trueBlock;
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1727 }
19366
4acfeb8a0010 Prototype avoiding the creation of begin nodes for target blocks with single predecessor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19365
diff changeset
1728 appendGoto(nextBlock);
19117
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1729 } else {
19367
f9ccdf258dd4 Further reduction of begin node creation when inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19366
diff changeset
1730
19374
2412408a4319 Fixes to the graph builder after recent changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
1731 if (condition.graph() == null) {
2412408a4319 Fixes to the graph builder after recent changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
1732 condition = currentGraph.unique(condition);
2412408a4319 Fixes to the graph builder after recent changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
1733 }
2412408a4319 Fixes to the graph builder after recent changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
1734
19381
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1735 int oldBci = stream.currentBCI();
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1736 int trueBlockInt = checkPositiveIntConstantPushed(trueBlock);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1737 if (trueBlockInt != -1) {
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1738 int falseBlockInt = checkPositiveIntConstantPushed(falseBlock);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1739 if (falseBlockInt != -1) {
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1740
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1741 boolean genReturn = false;
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1742 boolean genConditional = false;
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1743 if (gotoOrFallThroughAfterConstant(trueBlock) && gotoOrFallThroughAfterConstant(falseBlock) && trueBlock.getSuccessor(0) == falseBlock.getSuccessor(0)) {
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1744 genConditional = true;
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1745 } else if (this.currentDepth != 0 && returnAfterConstant(trueBlock) && returnAfterConstant(falseBlock)) {
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1746 genReturn = true;
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1747 genConditional = true;
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1748 }
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1749
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1750 if (genConditional) {
19372
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1751 ConstantNode trueValue = currentGraph.unique(ConstantNode.forInt(trueBlockInt));
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1752 ConstantNode falseValue = currentGraph.unique(ConstantNode.forInt(falseBlockInt));
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1753 if (negate) {
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1754 ConstantNode tmp = falseValue;
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1755 falseValue = trueValue;
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1756 trueValue = tmp;
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1757 }
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1758 ValueNode conditionalNode = ConditionalNode.create(condition, trueValue, falseValue);
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1759 if (conditionalNode.graph() == null) {
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1760 conditionalNode = currentGraph.addOrUnique(conditionalNode);
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1761 }
19381
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1762 if (genReturn) {
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1763 this.genReturn(conditionalNode);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1764 } else {
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1765 frameState.push(Kind.Int, conditionalNode);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1766 appendGoto(trueBlock.getSuccessor(0));
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1767 stream.setBCI(oldBci);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1768 }
19372
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1769 return;
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1770 }
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1771 }
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1772 }
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1773
19367
f9ccdf258dd4 Further reduction of begin node creation when inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19366
diff changeset
1774 this.controlFlowSplit = true;
19117
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1775 ValueNode trueSuccessor = createBlockTarget(probability, trueBlock, frameState);
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1776 ValueNode falseSuccessor = createBlockTarget(1 - probability, falseBlock, frameState);
14947
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1777
19117
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1778 ValueNode ifNode = negate ? genIfNode(condition, falseSuccessor, trueSuccessor, 1 - probability) : genIfNode(condition, trueSuccessor, falseSuccessor, probability);
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1779 append(ifNode);
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
1780 }
14947
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1781 }
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
1782
19372
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1783 private int checkPositiveIntConstantPushed(BciBlock block) {
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1784 stream.setBCI(block.startBci);
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1785 int currentBC = stream.currentBC();
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1786 if (currentBC >= Bytecodes.ICONST_0 && currentBC <= Bytecodes.ICONST_5) {
19374
2412408a4319 Fixes to the graph builder after recent changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
1787 int constValue = currentBC - Bytecodes.ICONST_0;
19381
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1788 return constValue;
19372
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1789 }
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1790 return -1;
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1791 }
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
1792
19381
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1793 private boolean gotoOrFallThroughAfterConstant(BciBlock block) {
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1794 stream.setBCI(block.startBci);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1795 int currentBCI = stream.nextBCI();
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1796 stream.setBCI(currentBCI);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1797 int currentBC = stream.currentBC();
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1798 return stream.currentBCI() > block.endBci || currentBC == Bytecodes.GOTO || currentBC == Bytecodes.GOTO_W;
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1799 }
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1800
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1801 private boolean returnAfterConstant(BciBlock block) {
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1802 stream.setBCI(block.startBci);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1803 int currentBCI = stream.nextBCI();
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1804 stream.setBCI(currentBCI);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1805 int currentBC = stream.currentBC();
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1806 return currentBC == Bytecodes.IRETURN;
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1807 }
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1808
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1809 public StampProvider getStampProvider() {
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1810 return stampProvider;
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1811 }
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1812
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1813 public MetaAccessProvider getMetaAccess() {
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1814 return metaAccess;
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1815 }
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1816
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1817 public Assumptions getAssumptions() {
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19241
diff changeset
1818 return currentGraph.getAssumptions();
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1819 }
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1820
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1821 public void push(Kind kind, ValueNode value) {
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19173
diff changeset
1822 assert kind == kind.getStackKind();
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1823 frameState.push(kind, value);
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1824 }
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1825
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1826 private int getCurrentDimension() {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1827 if (this.explodeLoopsContext == null || this.explodeLoopsContext.isEmpty()) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1828 return 0;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1829 } else {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1830 return this.explodeLoopsContext.peek().peelIteration;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1831 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1832 }
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19173
diff changeset
1833
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19173
diff changeset
1834 public ConstantReflectionProvider getConstantReflection() {
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
1835 return constantReflection;
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19173
diff changeset
1836 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19173
diff changeset
1837
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
1838 public SnippetReflectionProvider getSnippetReflection() {
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
1839 return snippetReflectionProvider;
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
1840 }
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
1841
19409
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
1842 public boolean parsingReplacement() {
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
1843 return parsingReplacement;
1307b475f10d added BytecodeParser.parsingReplacement field to distinguish parsing method replacements (or snippets) from normal method parsing
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
1844 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1845 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1846 }
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
1847
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
1848 static String nSpaces(int n) {
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
1849 return n == 0 ? "" : format("%" + n + "s", "");
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
1850 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1851 }