annotate graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java @ 19955:517cbecdc20f

factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
author Doug Simon <doug.simon@oracle.com>
date Wed, 18 Mar 2015 11:46:06 +0100
parents 87c62a38f843
children 3a1ce0aeb829
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.*;
19955
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
28 import static com.oracle.graal.compiler.common.GraalInternalError.*;
15259
d90e5c22ba55 Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15220
diff changeset
29 import static com.oracle.graal.compiler.common.GraalOptions.*;
19496
9525e4d5b385 disable (asserting) type checks in the FrameStateBuilder when parsing a replacement
Doug Simon <doug.simon@oracle.com>
parents: 19485
diff changeset
30 import static com.oracle.graal.graph.iterators.NodePredicates.*;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
31 import static com.oracle.graal.java.AbstractBytecodeParser.Options.*;
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
32 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
33 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
34
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
37 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
38 import com.oracle.graal.api.meta.*;
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
39 import com.oracle.graal.api.replacements.*;
5568
fdf19fa15ce4 Split bytecode utilities into separate project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
40 import com.oracle.graal.bytecode.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15145
diff changeset
41 import com.oracle.graal.compiler.common.*;
15200
97eed257999b Move Condition to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
42 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
43 import com.oracle.graal.compiler.common.type.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
44 import com.oracle.graal.debug.*;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
45 import com.oracle.graal.debug.Debug.Scope;
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19173
diff changeset
46 import com.oracle.graal.graph.Graph.Mark;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
47 import com.oracle.graal.graph.*;
14922
ea57ed7085cf Move options from GraphBuilderPhase to AbstractBytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents: 14906
diff changeset
48 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
49 import com.oracle.graal.graph.iterators.*;
19883
4d33cd6e0c8f refactored GraphBuilderConfiguration (and its component classes) into a separate project
Doug Simon <doug.simon@oracle.com>
parents: 19812
diff changeset
50 import com.oracle.graal.graphbuilderconf.*;
19884
87736c089259 refactored graph builder plugins to be top level interfaces
Doug Simon <doug.simon@oracle.com>
parents: 19883
diff changeset
51 import com.oracle.graal.graphbuilderconf.InlineInvokePlugin.InlineInfo;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
52 import com.oracle.graal.java.AbstractBytecodeParser.ReplacementContext;
14827
2ed3233503b8 Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14826
diff changeset
53 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
54 import com.oracle.graal.java.BciBlockMapping.ExceptionDispatchBlock;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
55 import com.oracle.graal.nodeinfo.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
56 import com.oracle.graal.nodes.*;
16563
1e63cb55f61d Move InvokeKind from MethodCallTargetNode to CallTargetNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16490
diff changeset
57 import com.oracle.graal.nodes.CallTargetNode.InvokeKind;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
58 import com.oracle.graal.nodes.calc.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
59 import com.oracle.graal.nodes.extended.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
60 import com.oracle.graal.nodes.java.*;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
61 import com.oracle.graal.nodes.spi.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
62 import com.oracle.graal.nodes.type.*;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
63 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
64 import com.oracle.graal.phases.*;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
65 import com.oracle.graal.phases.tiers.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 * 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
69 */
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
70 public class GraphBuilderPhase extends BasePhase<HighTierContext> {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71
5109
6766253384bf more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5105
diff changeset
72 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
73
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
74 public GraphBuilderPhase(GraphBuilderConfiguration config) {
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
75 this.graphBuilderConfig = config;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 @Override
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
79 protected void run(StructuredGraph graph, HighTierContext context) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
80 new Instance(context.getMetaAccess(), context.getStampProvider(), null, context.getConstantReflection(), graphBuilderConfig, context.getOptimisticOptimizations(), null).run(graph);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82
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
83 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
84 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
85 }
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
86
19793
9cfcbadec537 workaround for JDK-8056066
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
87 // Fully qualified name is a workaround for JDK-8056066
9cfcbadec537 workaround for JDK-8056066
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
88 public static class Instance extends com.oracle.graal.phases.Phase {
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
89
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
90 protected StructuredGraph currentGraph;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
91
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
92 private final MetaAccessProvider metaAccess;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
93
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18917
diff changeset
94 private ResolvedJavaMethod rootMethod;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
95
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
96 /**
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
97 * If not null, then this indicates {@link #rootMethod} is a replacement or a snippet.
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
98 * Furthermore, if it is non-null and not equal to {@link #rootMethod} then this is the
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
99 * original method for which a snippet exists (e.g., System.arraycopy()).
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
100 */
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
101 private final ResolvedJavaMethod rootMethodIsReplacement;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
102
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
103 private final GraphBuilderConfiguration graphBuilderConfig;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
104 private final OptimisticOptimizations optimisticOpts;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
105 private final StampProvider stampProvider;
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
106 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
107 private final SnippetReflectionProvider snippetReflectionProvider;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
108
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
109 public Instance(MetaAccessProvider metaAccess, StampProvider stampProvider, SnippetReflectionProvider snippetReflectionProvider, ConstantReflectionProvider constantReflection,
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
110 GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, ResolvedJavaMethod rootMethodIsReplacement) {
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
111 this.graphBuilderConfig = graphBuilderConfig;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
112 this.optimisticOpts = optimisticOpts;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
113 this.metaAccess = metaAccess;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
114 this.stampProvider = stampProvider;
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
115 this.constantReflection = constantReflection;
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
116 this.snippetReflectionProvider = snippetReflectionProvider;
19776
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
117 this.rootMethodIsReplacement = rootMethodIsReplacement;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
118 assert metaAccess != null;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
119 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120
19253
2caf12d746a3 merge fixes
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
121 public Instance(MetaAccessProvider metaAccess, StampProvider stampProvider, ConstantReflectionProvider constantReflection, GraphBuilderConfiguration graphBuilderConfig,
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
122 OptimisticOptimizations optimisticOpts, ResolvedJavaMethod rootMethodIsReplacement) {
19776
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
123 this(metaAccess, stampProvider, null, constantReflection, graphBuilderConfig, optimisticOpts, rootMethodIsReplacement);
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
124 }
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
125
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
126 @Override
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
127 protected void run(StructuredGraph graph) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
128 ResolvedJavaMethod method = graph.method();
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18917
diff changeset
129 this.rootMethod = method;
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
130 int entryBCI = graph.getEntryBCI();
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
131 assert method.getCode() != null : "method must contain bytecodes: " + method;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
132 this.currentGraph = graph;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
133 TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method);
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
134 try {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
135 ReplacementContext replacementContext = rootMethodIsReplacement != null ? new ReplacementContext(rootMethodIsReplacement, rootMethod) : null;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
136 BytecodeParser parser = new BytecodeParser(null, metaAccess, method, graphBuilderConfig, optimisticOpts, entryBCI, replacementContext);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
137 HIRFrameStateBuilder frameState = new HIRFrameStateBuilder(parser, method, graph);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
138 frameState.initializeForMethodStart(graphBuilderConfig.eagerResolving() || rootMethodIsReplacement != null, graphBuilderConfig.getPlugins().getParameterPlugin());
19776
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
139 parser.build(graph.start(), frameState);
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
140
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
141 parser.connectLoopEndToBegin();
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
142
19581
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
143 // Remove dead parameters.
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19390
diff changeset
144 for (ParameterNode param : currentGraph.getNodes(ParameterNode.TYPE)) {
18937
ff232ff8d028 Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18925
diff changeset
145 if (param.hasNoUsages()) {
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
146 assert param.inputs().isEmpty();
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
147 param.safeDelete();
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
148 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
149 }
19581
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
150
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
151 // Remove redundant begin nodes.
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
152 Debug.dump(graph, "Before removing redundant begins");
19581
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
153 for (BeginNode beginNode : currentGraph.getNodes(BeginNode.TYPE)) {
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
154 Node predecessor = beginNode.predecessor();
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
155 if (predecessor instanceof ControlSplitNode) {
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
156 // The begin node is necessary.
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
157 } else {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
158 if (beginNode.hasUsages()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
159 reanchorGuardedNodes(beginNode);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
160 }
19581
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
161 GraphUtil.unlinkFixedNode(beginNode);
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
162 beginNode.safeDelete();
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
163 }
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
164 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
165 } finally {
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
166 filter.remove();
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
167 }
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15311
diff changeset
168
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15311
diff changeset
169 ComputeLoopFrequenciesClosure.compute(graph);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
170 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
172 /**
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
173 * Removes {@link GuardedNode}s from {@code beginNode}'s usages and re-attaches them to an
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
174 * appropriate preceeding {@link GuardingNode}.
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
175 */
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
176 protected void reanchorGuardedNodes(BeginNode beginNode) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
177 // Find the new guarding node
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
178 GuardingNode guarding = null;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
179 Node pred = beginNode.predecessor();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
180 while (pred != null) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
181 if (pred instanceof BeginNode) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
182 if (pred.predecessor() instanceof ControlSplitNode) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
183 guarding = (GuardingNode) pred;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
184 break;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
185 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
186 } else if (pred.getNodeClass().getAllowedUsageTypes().contains(InputType.Guard)) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
187 guarding = (GuardingNode) pred;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
188 break;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
189 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
190 pred = pred.predecessor();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
191 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
192
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
193 // Reset the guard for all of beginNode's usages
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
194 for (Node usage : beginNode.usages().snapshot()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
195 GuardedNode guarded = (GuardedNode) usage;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
196 assert guarded.getGuard() == beginNode;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
197 guarded.setGuard(guarding);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
198 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
199 assert beginNode.hasNoUsages() : beginNode;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
200 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
201
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
202 @Override
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
203 protected String getDetailedName() {
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18917
diff changeset
204 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
205 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
206
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
207 private static class Target {
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
208
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
209 FixedNode fixed;
14792
b9805a622546 Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14068
diff changeset
210 HIRFrameStateBuilder state;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
211
14792
b9805a622546 Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14068
diff changeset
212 public Target(FixedNode fixed, HIRFrameStateBuilder state) {
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
213 this.fixed = fixed;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
214 this.state = state;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
215 }
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6699
diff changeset
216 }
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6699
diff changeset
217
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
218 private static class ExplodedLoopContext {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
219 private BciBlock header;
19619
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
220 private int[] targetPeelIteration;
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
221 private int peelIteration;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
222 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
223
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
224 @SuppressWarnings("serial")
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
225 public class BytecodeParserError extends GraalInternalError {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
226
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
227 public BytecodeParserError(Throwable cause) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
228 super(cause);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
229 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
230
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
231 public BytecodeParserError(String msg, Object... args) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
232 super(msg, args);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
233 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
234 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
235
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19534
diff changeset
236 public class BytecodeParser extends AbstractBytecodeParser implements GraphBuilderContext {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
237
19483
625633886e25 Reduce number of fields in BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19482
diff changeset
238 private BciBlockMapping blockMap;
15032
c9bf91560c82 BciBlock: make entryState abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 15030
diff changeset
239 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
240 protected final int entryBCI;
19776
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
241 private final BytecodeParser parent;
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
242
18920
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
243 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
244 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
245 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
246
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
247 private ValueNode methodSynchronizedObject;
18925
14599c77560a Do not always allocate monitorId NodeInputList. Allow null NodeInputList.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18923
diff changeset
248
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
249 private ValueNode returnValue;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
250 private FixedWithNextNode beforeReturnNode;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
251 private ValueNode unwindValue;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
252 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
253
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
254 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
255 private final boolean explodeLoops;
19622
0e90dbf0b9fd Add merge boolean property to ExplodeLoop annotation to indicate that backward branches should be merged if possible.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19619
diff changeset
256 private final boolean mergeExplosions;
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
257 private final Map<HIRFrameStateBuilder, Integer> mergeExplosionsMap;
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
258 private Stack<ExplodedLoopContext> explodeLoopsContext;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
259 private int nextPeelIteration = 1;
19367
f9ccdf258dd4 Further reduction of begin node creation when inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19366
diff changeset
260 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
261
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
262 private FixedWithNextNode[] firstInstructionArray;
19515
387d7192e18f Replace abstract type usage in graph builder with concrete type usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19512
diff changeset
263 private HIRFrameStateBuilder[] entryStateArray;
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
264 private FixedWithNextNode[][] firstInstructionMatrix;
19515
387d7192e18f Replace abstract type usage in graph builder with concrete type usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19512
diff changeset
265 private HIRFrameStateBuilder[][] entryStateMatrix;
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
266
19776
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
267 public BytecodeParser(BytecodeParser parent, MetaAccessProvider metaAccess, ResolvedJavaMethod method, GraphBuilderConfiguration graphBuilderConfig,
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
268 OptimisticOptimizations optimisticOpts, int entryBCI, ReplacementContext replacementContext) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
269 super(metaAccess, method, graphBuilderConfig, optimisticOpts, replacementContext);
18920
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
270 this.entryBCI = entryBCI;
19776
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
271 this.parent = parent;
18920
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
272
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18919
diff changeset
273 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
274 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
275 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
276 }
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
277
19787
7117697d11e1 refactored graph builder plugins into a separate class
Doug Simon <doug.simon@oracle.com>
parents: 19783
diff changeset
278 LoopExplosionPlugin loopExplosionPlugin = graphBuilderConfig.getPlugins().getLoopExplosionPlugin();
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
279 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
280 explodeLoops = loopExplosionPlugin.shouldExplodeLoops(method);
19622
0e90dbf0b9fd Add merge boolean property to ExplodeLoop annotation to indicate that backward branches should be merged if possible.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19619
diff changeset
281 if (explodeLoops) {
0e90dbf0b9fd Add merge boolean property to ExplodeLoop annotation to indicate that backward branches should be merged if possible.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19619
diff changeset
282 mergeExplosions = loopExplosionPlugin.shouldMergeExplosions(method);
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
283 mergeExplosionsMap = new HashMap<>();
19622
0e90dbf0b9fd Add merge boolean property to ExplodeLoop annotation to indicate that backward branches should be merged if possible.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19619
diff changeset
284 } else {
0e90dbf0b9fd Add merge boolean property to ExplodeLoop annotation to indicate that backward branches should be merged if possible.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19619
diff changeset
285 mergeExplosions = false;
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
286 mergeExplosionsMap = null;
19622
0e90dbf0b9fd Add merge boolean property to ExplodeLoop annotation to indicate that backward branches should be merged if possible.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19619
diff changeset
287 }
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
288 } 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
289 explodeLoops = false;
19622
0e90dbf0b9fd Add merge boolean property to ExplodeLoop annotation to indicate that backward branches should be merged if possible.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19619
diff changeset
290 mergeExplosions = false;
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
291 mergeExplosionsMap = null;
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
292 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
293 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
294
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
295 public ValueNode getReturnValue() {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
296 return returnValue;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
297 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
298
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
299 public FixedWithNextNode getBeforeReturnNode() {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
300 return this.beforeReturnNode;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
301 }
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 public ValueNode getUnwindValue() {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
304 return unwindValue;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
305 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
306
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
307 public FixedWithNextNode getBeforeUnwindNode() {
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
308 return this.beforeUnwindNode;
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
309 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
310
19776
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
311 protected void build(FixedWithNextNode startInstruction, HIRFrameStateBuilder startFrameState) {
19439
5be35dd0a9dd Disable use of profiling information during partial evaluation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19437
diff changeset
312 if (PrintProfilingInformation.getValue() && profilingInfo != null) {
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
313 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
314 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
315 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
316
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
317 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
318
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
319 // compute the block map, setup exception handlers and get the entrypoint(s)
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
320 BciBlockMapping newMapping = BciBlockMapping.create(stream, method);
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
321 this.blockMap = newMapping;
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
322 this.firstInstructionArray = new FixedWithNextNode[blockMap.getBlockCount()];
19515
387d7192e18f Replace abstract type usage in graph builder with concrete type usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19512
diff changeset
323 this.entryStateArray = new HIRFrameStateBuilder[blockMap.getBlockCount()];
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
324
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
325 if (graphBuilderConfig.doLivenessAnalysis()) {
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
326 try (Scope s = Debug.scope("LivenessAnalysis")) {
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
327 int maxLocals = method.getMaxLocals();
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
328 liveness = LocalLiveness.compute(stream, blockMap.getBlocks(), maxLocals, blockMap.getLoopCount());
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
329 } catch (Throwable e) {
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
330 throw Debug.handle(e);
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
331 }
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
332 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
333
18919
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
334 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
335 this.setCurrentFrameState(startFrameState);
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
336 stream.setBCI(0);
18919
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
337
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
338 BciBlock startBlock = blockMap.getStartBlock();
18919
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
339 if (startInstruction == currentGraph.start()) {
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
340 StartNode startNode = currentGraph.start();
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
341 if (method.isSynchronized()) {
19585
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19581
diff changeset
342 startNode.setStateAfter(createFrameState(BytecodeFrame.BEFORE_BCI));
18919
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
343 } else {
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
344 frameState.clearNonLiveLocals(startBlock, liveness, true);
18919
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
345 assert bci() == 0;
19585
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19581
diff changeset
346 startNode.setStateAfter(createFrameState(bci()));
18919
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
347 }
0061f550ef31 Make starting node a parameter in the GraphBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
348 }
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18917
diff changeset
349
15267
98d45600222c Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15266
diff changeset
350 if (method.isSynchronized()) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
351 // 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
352 methodSynchronizedObject = synchronizedObject(frameState, method);
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
353 frameState.clearNonLiveLocals(startBlock, liveness, true);
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
354 assert bci() == 0;
19854
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
355 genMonitorEnter(methodSynchronizedObject, bci());
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
356 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
357
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
358 if (graphBuilderConfig.insertNonSafepointDebugInfo()) {
18916
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
359 append(createInfoPointNode(InfopointReason.METHOD_START));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
360 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
361
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
362 currentBlock = blockMap.getStartBlock();
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
363 setEntryState(startBlock, 0, frameState);
19479
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
364 if (startBlock.isLoopHeader && !explodeLoops) {
7837f7aab5ed Split bci block mapping and local liveness analysis. Clean up bci block mapping. Always sort loop blocks to be consecutive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19461
diff changeset
365 appendGoto(startBlock);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
366 } else {
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
367 setFirstInstruction(startBlock, 0, lastInstr);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
368 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7522
diff changeset
369
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
370 int index = 0;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
371 BciBlock[] blocks = blockMap.getBlocks();
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
372 while (index < blocks.length) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
373 BciBlock block = blocks[index];
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
374 index = iterateBlock(blocks, block);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
375 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
376
19632
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
377 if (this.mergeExplosions) {
19638
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
378 Debug.dump(currentGraph, "Before loop detection");
19632
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
379 detectLoops(startInstruction);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
380 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
381
19580
e7d46a5f177b Add option DumpDuringGraphBuilding and default to false.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19536
diff changeset
382 if (Debug.isDumpEnabled() && DumpDuringGraphBuilding.getValue() && this.beforeReturnNode != startInstruction) {
19445
82c5dfb8435a Fix graph dumping in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19440
diff changeset
383 Debug.dump(currentGraph, "Bytecodes parsed: " + method.getDeclaringClass().getUnqualifiedName() + "." + method.getName());
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
384 }
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
385 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
386 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
387
19632
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
388 private void detectLoops(FixedNode startInstruction) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
389 NodeBitMap visited = currentGraph.createNodeBitMap();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
390 NodeBitMap active = currentGraph.createNodeBitMap();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
391 Stack<Node> stack = new Stack<>();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
392 stack.add(startInstruction);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
393 visited.mark(startInstruction);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
394 while (!stack.isEmpty()) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
395 Node next = stack.peek();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
396 assert next.isDeleted() || visited.isMarked(next);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
397 if (next.isDeleted() || active.isMarked(next)) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
398 stack.pop();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
399 if (!next.isDeleted()) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
400 active.clear(next);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
401 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
402 } else {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
403 active.mark(next);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
404 for (Node n : next.cfgSuccessors()) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
405 if (active.contains(n)) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
406 // Detected cycle.
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
407 assert n instanceof MergeNode;
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
408 assert next instanceof EndNode;
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
409 MergeNode merge = (MergeNode) n;
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
410 EndNode endNode = (EndNode) next;
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
411 merge.removeEnd(endNode);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
412 FixedNode afterMerge = merge.next();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
413 if (!(afterMerge instanceof EndNode) || !(((EndNode) afterMerge).merge() instanceof LoopBeginNode)) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
414 merge.setNext(null);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
415 LoopBeginNode newLoopBegin = this.appendLoopBegin(merge);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
416 newLoopBegin.setNext(afterMerge);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
417 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
418 LoopBeginNode loopBegin = (LoopBeginNode) ((EndNode) merge.next()).merge();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
419 LoopEndNode loopEnd = currentGraph.add(new LoopEndNode(loopBegin));
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
420 endNode.replaceAndDelete(loopEnd);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
421 } else if (visited.contains(n)) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
422 // Normal merge into a branch we are already exploring.
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
423 } else {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
424 visited.mark(n);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
425 stack.push(n);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
426 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
427 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
428 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
429 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
430
19638
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
431 Debug.dump(currentGraph, "After loops detected");
19632
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
432 insertLoopEnds(startInstruction);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
433 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
434
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
435 private void insertLoopEnds(FixedNode startInstruction) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
436 NodeBitMap visited = currentGraph.createNodeBitMap();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
437 Stack<Node> stack = new Stack<>();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
438 stack.add(startInstruction);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
439 visited.mark(startInstruction);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
440 List<LoopBeginNode> loopBegins = new ArrayList<>();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
441 while (!stack.isEmpty()) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
442 Node next = stack.pop();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
443 assert visited.isMarked(next);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
444 if (next instanceof LoopBeginNode) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
445 loopBegins.add((LoopBeginNode) next);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
446 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
447 for (Node n : next.cfgSuccessors()) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
448 if (visited.contains(n)) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
449 // Nothing to do.
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
450 } else {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
451 visited.mark(n);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
452 stack.push(n);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
453 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
454 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
455 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
456
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
457 IdentityHashMap<LoopBeginNode, List<LoopBeginNode>> innerLoopsMap = new IdentityHashMap<>();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
458 for (int i = loopBegins.size() - 1; i >= 0; --i) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
459 LoopBeginNode loopBegin = loopBegins.get(i);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
460 insertLoopExits(loopBegin, innerLoopsMap);
19808
73dddd2d8710 moved bytecode paring options to AbstractBytecodeParser.Options
Doug Simon <doug.simon@oracle.com>
parents: 19793
diff changeset
461 if (DumpDuringGraphBuilding.getValue()) {
19638
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
462 Debug.dump(currentGraph, "After building loop exits for %s.", loopBegin);
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
463 }
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
464 }
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
465
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
466 // Remove degenerated merges with only one predecessor.
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
467 for (LoopBeginNode loopBegin : loopBegins) {
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
468 Node pred = loopBegin.forwardEnd().predecessor();
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
469 if (pred instanceof MergeNode) {
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
470 MergeNode.removeMergeIfDegenerated((MergeNode) pred);
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
471 }
19632
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
472 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
473 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
474
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
475 private void insertLoopExits(LoopBeginNode loopBegin, IdentityHashMap<LoopBeginNode, List<LoopBeginNode>> innerLoopsMap) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
476 NodeBitMap visited = currentGraph.createNodeBitMap();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
477 Stack<Node> stack = new Stack<>();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
478 for (LoopEndNode loopEnd : loopBegin.loopEnds()) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
479 stack.push(loopEnd);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
480 visited.mark(loopEnd);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
481 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
482
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
483 List<ControlSplitNode> controlSplits = new ArrayList<>();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
484 List<LoopBeginNode> innerLoopBegins = new ArrayList<>();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
485
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
486 while (!stack.isEmpty()) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
487 Node current = stack.pop();
19638
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
488 if (current == loopBegin) {
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
489 continue;
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
490 }
19632
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
491 for (Node pred : current.cfgPredecessors()) {
19638
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
492 if (!visited.isMarked(pred)) {
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
493 visited.mark(pred);
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
494 if (pred instanceof LoopExitNode) {
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
495 // Inner loop
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
496 LoopExitNode loopExitNode = (LoopExitNode) pred;
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
497 LoopBeginNode innerLoopBegin = loopExitNode.loopBegin();
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
498 if (!visited.isMarked(innerLoopBegin)) {
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
499 stack.push(innerLoopBegin);
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
500 visited.mark(innerLoopBegin);
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
501 innerLoopBegins.add(innerLoopBegin);
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
502 }
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
503 } else {
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
504 if (pred instanceof ControlSplitNode) {
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
505 ControlSplitNode controlSplitNode = (ControlSplitNode) pred;
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
506 controlSplits.add(controlSplitNode);
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
507 }
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
508 stack.push(pred);
19632
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
509 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
510 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
511 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
512 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
513
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
514 for (ControlSplitNode controlSplit : controlSplits) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
515 for (Node succ : controlSplit.cfgSuccessors()) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
516 if (!visited.isMarked(succ)) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
517 LoopExitNode loopExit = currentGraph.add(new LoopExitNode(loopBegin));
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
518 FixedNode next = ((FixedWithNextNode) succ).next();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
519 next.replaceAtPredecessor(loopExit);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
520 loopExit.setNext(next);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
521 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
522 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
523 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
524
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
525 for (LoopBeginNode inner : innerLoopBegins) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
526 addLoopExits(loopBegin, inner, innerLoopsMap, visited);
19808
73dddd2d8710 moved bytecode paring options to AbstractBytecodeParser.Options
Doug Simon <doug.simon@oracle.com>
parents: 19793
diff changeset
527 if (DumpDuringGraphBuilding.getValue()) {
19638
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
528 Debug.dump(currentGraph, "After adding loop exits for %s.", inner);
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
529 }
19632
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
530 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
531
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
532 innerLoopsMap.put(loopBegin, innerLoopBegins);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
533 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
534
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
535 private void addLoopExits(LoopBeginNode loopBegin, LoopBeginNode inner, IdentityHashMap<LoopBeginNode, List<LoopBeginNode>> innerLoopsMap, NodeBitMap visited) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
536 for (LoopExitNode exit : inner.loopExits()) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
537 if (!visited.isMarked(exit)) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
538 LoopExitNode newLoopExit = currentGraph.add(new LoopExitNode(loopBegin));
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
539 FixedNode next = exit.next();
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
540 next.replaceAtPredecessor(newLoopExit);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
541 newLoopExit.setNext(next);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
542 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
543 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
544
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
545 for (LoopBeginNode innerInner : innerLoopsMap.get(inner)) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
546 addLoopExits(loopBegin, innerInner, innerLoopsMap, visited);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
547 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
548 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
549
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
550 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
551 if (block.isLoopHeader && this.explodeLoops) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
552 return iterateExplodedLoopHeader(blocks, block);
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
553 } else {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
554 processBlock(this, block);
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
555 return block.getId() + 1;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
556 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
557 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
558
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
559 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
560 if (explodeLoopsContext == null) {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
561 explodeLoopsContext = new Stack<>();
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
562 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
563
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
564 ExplodedLoopContext context = new ExplodedLoopContext();
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
565 context.header = header;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
566 context.peelIteration = this.getCurrentDimension();
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
567 if (this.mergeExplosions) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
568 this.addToMergeCache(getEntryState(context.header, context.peelIteration), context.peelIteration);
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
569 }
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
570 explodeLoopsContext.push(context);
19580
e7d46a5f177b Add option DumpDuringGraphBuilding and default to false.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19536
diff changeset
571 if (Debug.isDumpEnabled() && DumpDuringGraphBuilding.getValue()) {
e7d46a5f177b Add option DumpDuringGraphBuilding and default to false.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19536
diff changeset
572 Debug.dump(currentGraph, "before loop explosion dimension " + context.peelIteration);
e7d46a5f177b Add option DumpDuringGraphBuilding and default to false.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19536
diff changeset
573 }
19619
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
574 peelIteration(blocks, header, context);
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
575 explodeLoopsContext.pop();
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
576 return header.loopEnd + 1;
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
577 }
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
578
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
579 private void addToMergeCache(HIRFrameStateBuilder key, int dimension) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
580 mergeExplosionsMap.put(key, dimension);
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
581 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
582
19619
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
583 private void peelIteration(BciBlock[] blocks, BciBlock header, ExplodedLoopContext context) {
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
584 while (true) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
585 if (TraceParserPlugins.getValue()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
586 traceWithContext("exploding loop, iteration %d", context.peelIteration);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
587 }
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
588 processBlock(this, header);
19737
de35dd773272 Fixed an issue with nested loop explosion. Added a unit test to prevent future regressions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19717
diff changeset
589 int j = header.getId() + 1;
de35dd773272 Fixed an issue with nested loop explosion. Added a unit test to prevent future regressions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19717
diff changeset
590 while (j <= header.loopEnd) {
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
591 BciBlock block = blocks[j];
19737
de35dd773272 Fixed an issue with nested loop explosion. Added a unit test to prevent future regressions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19717
diff changeset
592 j = iterateBlock(blocks, block);
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
593 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
594
19619
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
595 int[] targets = context.targetPeelIteration;
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
596 if (targets != null) {
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
597 // We were reaching the backedge during explosion. Explode further.
19619
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
598 for (int i = 0; i < targets.length; ++i) {
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
599 context.peelIteration = targets[i];
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
600 context.targetPeelIteration = null;
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
601 if (Debug.isDumpEnabled() && DumpDuringGraphBuilding.getValue()) {
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
602 Debug.dump(currentGraph, "next loop explosion iteration " + context.peelIteration);
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
603 }
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
604 if (i < targets.length - 1) {
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
605 peelIteration(blocks, header, context);
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
606 }
19580
e7d46a5f177b Add option DumpDuringGraphBuilding and default to false.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19536
diff changeset
607 }
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
608 } else {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
609 // 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
610 break;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
611 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
612 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
613 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
614
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
615 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
616 * @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
617 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
618 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
619 protected void handleUnresolvedLoadConstant(JavaType type) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
620 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
621 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
622 }
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 * @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
626 * @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
627 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
628 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
629 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
630 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
631 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
632 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
633 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
634
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
635 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
636 * @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
637 * @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
638 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
639 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
640 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
641 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
642 AbstractBeginNode successor = currentGraph.add(new BeginNode());
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
643 DeoptimizeNode deopt = currentGraph.add(new DeoptimizeNode(InvalidateRecompile, Unresolved));
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
644 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
645 lastInstr = successor;
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
646 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
647 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
648
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 * @param type the type being instantiated
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
651 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
652 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
653 protected void handleUnresolvedNewInstance(JavaType type) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
654 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
655 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
656 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
657
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 * @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
660 * @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
661 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
662 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
663 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
664 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
665 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
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
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
668 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
669 * @param type the type being instantiated
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
670 * @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
671 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
672 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
673 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
674 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
675 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
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
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
678 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
679 * @param field the unresolved field
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
680 * @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
681 * static
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
682 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
683 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
684 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
685 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
686 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
687 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
688
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
689 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
690 * @param field the unresolved field
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
691 * @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
692 * @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
693 * static
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
694 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
695 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
696 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
697 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
698 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
699 }
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 * @param type
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
703 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
704 @Override
18361
6ac7e9c85be6 Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
705 protected void handleUnresolvedExceptionType(JavaType type) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
706 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
707 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
708 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
709
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
710 /**
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
711 * @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
712 * @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
713 */
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
714 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
715 assert !graphBuilderConfig.eagerResolving();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
716 append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
717 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
718
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
719 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
720 assert bci == BytecodeFrame.BEFORE_BCI || bci == bci() : "invalid bci";
19439
5be35dd0a9dd Disable use of profiling information during partial evaluation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19437
diff changeset
721 Debug.log("Creating exception dispatch edges at %d, exception object=%s, exception seen=%s", bci, exceptionObject, (profilingInfo == null ? "" : profilingInfo.getExceptionSeen(bci)));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
722
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
723 BciBlock dispatchBlock = currentBlock.exceptionDispatchBlock();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
724 /*
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
725 * 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
726 * 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
727 * unwind immediately.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
728 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
729 if (bci != currentBlock.endBci || dispatchBlock == null) {
19483
625633886e25 Reduce number of fields in BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19482
diff changeset
730 dispatchBlock = blockMap.getUnwindBlock();
14900
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
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
733 HIRFrameStateBuilder dispatchState = frameState.copy();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
734 dispatchState.clearStack();
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 DispatchBeginNode dispatchBegin;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
737 if (exceptionObject == null) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
738 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
739 dispatchState.apush(dispatchBegin);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
740 dispatchState.setRethrowException(true);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
741 dispatchBegin.setStateAfter(dispatchState.create(bci));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
742 } else {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
743 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
744 dispatchState.apush(exceptionObject);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
745 dispatchBegin.setStateAfter(dispatchState.create(bci));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
746 dispatchState.setRethrowException(true);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
747 }
19367
f9ccdf258dd4 Further reduction of begin node creation when inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19366
diff changeset
748 this.controlFlowSplit = true;
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
749 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
750 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
751 finishedDispatch.setNext(target);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
752 return dispatchBegin;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
753 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
754
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
755 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
756 protected ValueNode genLoadIndexed(ValueNode array, ValueNode index, Kind kind) {
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
757 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
758 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
759
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
760 @Override
19854
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
761 protected void genStoreIndexed(ValueNode array, ValueNode index, Kind kind, ValueNode value) {
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
762 StoreIndexedNode storeIndexed = new StoreIndexedNode(array, index, kind, value);
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
763 append(storeIndexed);
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
764 storeIndexed.setStateAfter(this.createStateAfter());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
765 }
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 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
768 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
769 return AddNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
770 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
771
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
772 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
773 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
774 return SubNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
775 }
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 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
778 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
779 return MulNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
780 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
781
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
782 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
783 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
784 return AddNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
785 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
786
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
787 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
788 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
789 return SubNode.create(x, y);
14900
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 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
793 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
794 return MulNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
795 }
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 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
798 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
799 return DivNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
800 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
801
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
802 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
803 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
804 return new RemNode(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
805 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
806
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
807 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
808 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
809 return new IntegerDivNode(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
810 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
811
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
812 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
813 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
814 return new IntegerRemNode(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
815 }
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 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
818 protected ValueNode genNegateOp(ValueNode x) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
819 return (new NegateNode(x));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
820 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
821
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
822 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
823 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
824 return new LeftShiftNode(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
825 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
826
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
827 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
828 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
829 return new RightShiftNode(x, y);
14900
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
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
832 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
833 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
834 return new UnsignedRightShiftNode(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
835 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
836
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
837 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
838 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
839 return AndNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
840 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
841
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
842 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
843 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
844 return OrNode.create(x, y);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
845 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
846
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
847 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
848 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
849 return XorNode.create(x, y);
14900
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
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
852 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
853 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
854 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
855 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
856
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
857 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
858 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
859 return FloatConvertNode.create(op, input);
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
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
862 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
863 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
864 return NarrowNode.create(input, bitCount);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
865 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
866
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
867 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
868 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
869 return SignExtendNode.create(input, bitCount);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
870 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
871
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
872 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
873 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
874 return ZeroExtendNode.create(input, bitCount);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
875 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
876
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
877 @Override
15030
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
878 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
879 appendGoto(currentBlock.getSuccessor(0));
15030
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
880 assert currentBlock.numNormalSuccessors() == 1;
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
881 }
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
882
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
883 @Override
19372
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
884 protected LogicNode genObjectEquals(ValueNode x, ValueNode y) {
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
885 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
886 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
887
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
888 @Override
19372
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
889 protected LogicNode genIntegerEquals(ValueNode x, ValueNode y) {
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
890 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
891 }
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 @Override
19372
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
894 protected LogicNode genIntegerLessThan(ValueNode x, ValueNode y) {
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
895 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
896 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
897
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
898 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
899 protected ValueNode genUnique(ValueNode x) {
14904
162d8fe89017 Revert 3e9a8ef2e0e1.
Josef Eisl <josef.eisl@jku.at>
parents: 14902
diff changeset
900 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
901 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
902
19532
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
903 protected ValueNode genIfNode(LogicNode condition, FixedNode falseSuccessor, FixedNode trueSuccessor, double d) {
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
904 return new IfNode(condition, falseSuccessor, trueSuccessor, d);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
905 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
906
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
907 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
908 protected void genThrow() {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
909 ValueNode exception = frameState.apop();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
910 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
911 lastInstr.setNext(handleException(exception, bci()));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
912 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
913
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
914 @Override
15837
6fe57ff3f02c Rename methods to have consistent names, allow subclasses of bytecode parsers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15470
diff changeset
915 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
916 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
917 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
918
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
919 @Override
15837
6fe57ff3f02c Rename methods to have consistent names, allow subclasses of bytecode parsers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15470
diff changeset
920 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
921 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
922 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
923
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
924 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
925 protected ValueNode genConditional(ValueNode x) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
926 return new ConditionalNode((LogicNode) x);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
927 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
928
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
929 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
930 protected NewInstanceNode createNewInstance(ResolvedJavaType type, boolean fillContents) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
931 return new NewInstanceNode(type, fillContents);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
932 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
933
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
934 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
935 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
936 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
937 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
938
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
939 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
940 protected NewMultiArrayNode createNewMultiArray(ResolvedJavaType type, List<ValueNode> dimensions) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
941 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
942 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
943
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
944 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
945 protected ValueNode genLoadField(ValueNode receiver, ResolvedJavaField field) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
946 return new LoadFieldNode(receiver, field);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
947 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
948
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
949 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
950 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
951 if (StampTool.isPointerNonNull(receiver.stamp())) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
952 return;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
953 }
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
954 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
955 AbstractBeginNode falseSucc = currentGraph.add(new BeginNode());
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
956 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
957 lastInstr = falseSucc;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
958
19585
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19581
diff changeset
959 exception.setStateAfter(createFrameState(bci()));
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14973
diff changeset
960 exception.setNext(handleException(exception, bci()));
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
961 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
962
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
963 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
964 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
965 AbstractBeginNode trueSucc = currentGraph.add(new BeginNode());
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
966 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
967 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
968 lastInstr = trueSucc;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
969
19585
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19581
diff changeset
970 exception.setStateAfter(createFrameState(bci()));
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14973
diff changeset
971 exception.setNext(handleException(exception, bci()));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
972 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
973
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
974 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
975 protected ValueNode genArrayLength(ValueNode x) {
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
976 return ArrayLengthNode.create(x, constantReflection);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
977 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
978
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
979 @Override
19854
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
980 protected void genStoreField(ValueNode receiver, ResolvedJavaField field, ValueNode value) {
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
981 StoreFieldNode storeFieldNode = new StoreFieldNode(receiver, field, value);
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
982 append(storeFieldNode);
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
983 storeFieldNode.setStateAfter(this.createFrameState(stream.nextBCI()));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
984 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
985
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
986 /**
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
987 * 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
988 * 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
989 *
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
990 * @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
991 * @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
992 */
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
993 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
994 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
995 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
996 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
997 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
998 }
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
999 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
1000 }
e0f77d30ad07 ensure the declared method holder is at least linked before emitting an invoke
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16340
diff changeset
1001
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1002 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1003 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
1004 if (callTargetIsResolved(target)) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1005 ResolvedJavaMethod resolvedTarget = (ResolvedJavaMethod) target;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1006 ResolvedJavaType holder = resolvedTarget.getDeclaringClass();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1007 if (!holder.isInitialized() && ResolveClassBeforeStaticInvoke.getValue()) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1008 handleUnresolvedInvoke(target, InvokeKind.Static);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1009 } else {
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18361
diff changeset
1010 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
1011 appendInvoke(InvokeKind.Static, resolvedTarget, args);
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 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1014 handleUnresolvedInvoke(target, InvokeKind.Static);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1015 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1016 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1017
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1018 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1019 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
1020 if (callTargetIsResolved(target)) {
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18361
diff changeset
1021 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
1022 appendInvoke(InvokeKind.Interface, (ResolvedJavaMethod) target, args);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1023 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1024 handleUnresolvedInvoke(target, InvokeKind.Interface);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1025 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1026 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1027
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1028 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1029 protected void genInvokeDynamic(JavaMethod target) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1030 if (target instanceof ResolvedJavaMethod) {
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
1031 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
1032 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
1033 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
1034 }
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18361
diff changeset
1035 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
1036 appendInvoke(InvokeKind.Static, (ResolvedJavaMethod) target, args);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1037 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1038 handleUnresolvedInvoke(target, InvokeKind.Static);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1039 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1040 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1041
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1042 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1043 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
1044 if (callTargetIsResolved(target)) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1045 /*
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1046 * 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
1047 * 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
1048 * adapter. HotSpot does this - see
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1049 * 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
1050 * +and+invokedynamic
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1051 */
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
1052 boolean hasReceiver = !((ResolvedJavaMethod) target).isStatic();
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
1053 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
1054 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
1055 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
1056 }
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18361
diff changeset
1057 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
1058 if (hasReceiver) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1059 appendInvoke(InvokeKind.Virtual, (ResolvedJavaMethod) target, args);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1060 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1061 appendInvoke(InvokeKind.Static, (ResolvedJavaMethod) target, args);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1062 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1063 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1064 handleUnresolvedInvoke(target, InvokeKind.Virtual);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1065 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1066
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1067 }
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1068
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1069 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1070 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
1071 if (callTargetIsResolved(target)) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1072 assert target != null;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1073 assert target.getSignature() != null;
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18361
diff changeset
1074 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
1075 appendInvoke(InvokeKind.Special, (ResolvedJavaMethod) target, args);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1076 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1077 handleUnresolvedInvoke(target, InvokeKind.Special);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1078 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1079 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1080
19136
29f2815009d4 Resolve simple method calls to Special invoke kind before processing the invoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19132
diff changeset
1081 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
1082 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
1083 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
1084 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
1085 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
1086 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
1087 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
1088 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
1089 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
1090 }
29f2815009d4 Resolve simple method calls to Special invoke kind before processing the invoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19132
diff changeset
1091 }
29f2815009d4 Resolve simple method calls to Special invoke kind before processing the invoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19132
diff changeset
1092
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1093 Kind resultType = targetMethod.getSignature().getReturnKind();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1094 if (DeoptALot.getValue()) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1095 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
1096 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
1097 return;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1098 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1099
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1100 JavaType returnType = targetMethod.getSignature().getReturnType(method.getDeclaringClass());
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1101 if (graphBuilderConfig.eagerResolving() || parsingReplacement()) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1102 returnType = returnType.resolve(targetMethod.getDeclaringClass());
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1103 }
18822
fad37aaed6d2 Add utilities isDirect and isIndirect to InvokeKind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18821
diff changeset
1104 if (invokeKind.hasReceiver()) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1105 emitExplicitExceptions(args[0], null);
19439
5be35dd0a9dd Disable use of profiling information during partial evaluation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19437
diff changeset
1106 if (invokeKind.isIndirect() && profilingInfo != null && this.optimisticOpts.useTypeCheckHints()) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1107 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
1108 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
1109 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1110 }
18822
fad37aaed6d2 Add utilities isDirect and isIndirect to InvokeKind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18821
diff changeset
1111
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1112 if (tryGenericInvocationPlugin(args, targetMethod)) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1113 if (TraceParserPlugins.getValue()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1114 traceWithContext("used generic invocation plugin for %s", targetMethod.format("%h.%n(%p)"));
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
1115 }
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
1116 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
1117 }
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
1118
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1119 if (tryInvocationPlugin(args, targetMethod, resultType)) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1120 if (TraceParserPlugins.getValue()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1121 traceWithContext("used invocation plugin for %s", targetMethod.format("%h.%n(%p)"));
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
1122 }
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
1123 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
1124 }
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
1125
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
1126 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
1127 return;
18912
9536c47658a2 Introduce new option InlineDuringParsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
1128 }
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
1129
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1130 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
1131
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1132 // 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
1133 // recompiles otherwise)
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1134 Invoke invoke;
19440
d59f813786f6 Merge and merge fixes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19439 19420
diff changeset
1135 if (graphBuilderConfig.omitAllExceptionEdges() || (optimisticOpts.useExceptionProbability() && profilingInfo != null && profilingInfo.getExceptionSeen(bci()) == TriState.FALSE)) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1136 invoke = createInvoke(callTarget, resultType);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1137 } else {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1138 invoke = createInvokeWithException(callTarget, resultType);
19845
3d0116ec99c5 Create utilities LocationIdentity#isAny, LocationIdentity#isSingle, LocationIdentity#any, LocationIdentity#overlaps.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19812
diff changeset
1139 AbstractBeginNode beginNode = currentGraph.add(new KillingBeginNode(LocationIdentity.any()));
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
1140 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
1141 lastInstr = beginNode;
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1142 }
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1143
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1144 InlineInvokePlugin plugin = graphBuilderConfig.getPlugins().getInlineInvokePlugin();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1145 if (plugin != null) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1146 if (TraceParserPlugins.getValue()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1147 traceWithContext("did not inline %s", targetMethod.format("%h.%n(%p)"));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1148 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1149 plugin.notifyOfNoninlinedInvoke(this, targetMethod, invoke);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1150 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1151 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1152
19955
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1153 /**
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1154 * Contains all the assertion checking logic around the application of an
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1155 * {@link InvocationPlugin}. This class is only loaded when assertions are enabled.
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1156 */
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1157 class InvocationPluginAssertions {
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1158 final InvocationPlugin plugin;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1159 final ValueNode[] args;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1160 final ResolvedJavaMethod targetMethod;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1161 final Kind resultType;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1162 final int beforeStackSize;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1163 final boolean needsNullCheck;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1164 final int nodeCount;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1165 final Mark mark;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1166
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1167 public InvocationPluginAssertions(InvocationPlugin plugin, ValueNode[] args, ResolvedJavaMethod targetMethod, Kind resultType) {
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1168 guarantee(assertionsEnabled(), "%s should only be loaded and instantiated if assertions are enabled", getClass().getSimpleName());
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1169 this.plugin = plugin;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1170 this.targetMethod = targetMethod;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1171 this.args = args;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1172 this.resultType = resultType;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1173 this.beforeStackSize = frameState.stackSize;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1174 this.needsNullCheck = !targetMethod.isStatic() && args[0].getKind() == Kind.Object && !StampTool.isPointerNonNull(args[0].stamp());
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1175 this.nodeCount = currentGraph.getNodeCount();
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1176 this.mark = currentGraph.getMark();
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1177 }
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1178
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1179 boolean check(boolean pluginResult) {
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1180 if (pluginResult == true) {
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1181 assert beforeStackSize + resultType.getSlotCount() == frameState.stackSize : "plugin manipulated the stack incorrectly " + targetMethod;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1182 NodeIterable<Node> newNodes = currentGraph.getNewNodes(mark);
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1183 assert !needsNullCheck || args[0].usages().filter(isNotA(FrameState.class)).isEmpty() || containsNullCheckOf(newNodes, args[0]) : format(
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1184 "plugin needs to null check the receiver of %s: receiver=%s%n\tplugin at %s", targetMethod.format("%H.%n(%p)"), args[0],
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1185 plugin.getApplySourceLocation(metaAccess));
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1186 for (Node n : newNodes) {
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1187 if (n instanceof StateSplit) {
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1188 StateSplit stateSplit = (StateSplit) n;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1189 assert stateSplit.stateAfter() != null : format("%s node added by plugin for %s need to have a non-null frame state: %s%n\tplugin at %s",
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1190 StateSplit.class.getSimpleName(), targetMethod.format("%H.%n(%p)"), stateSplit, plugin.getApplySourceLocation(metaAccess));
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1191 }
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1192 }
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1193 } else {
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1194 assert nodeCount == currentGraph.getNodeCount() : "plugin that returns false must not create new nodes";
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1195 assert beforeStackSize == frameState.stackSize : "plugin that returns false must modify the stack";
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1196 }
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1197 return true;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1198 }
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1199 }
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1200
19412
a9ff83864e8c rename: tryUsingInvocationPlugin -> tryInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19411
diff changeset
1201 private boolean tryInvocationPlugin(ValueNode[] args, ResolvedJavaMethod targetMethod, Kind resultType) {
19787
7117697d11e1 refactored graph builder plugins into a separate class
Doug Simon <doug.simon@oracle.com>
parents: 19783
diff changeset
1202 InvocationPlugin plugin = graphBuilderConfig.getPlugins().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
1203 if (plugin != null) {
19955
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1204 InvocationPluginAssertions assertions = assertionsEnabled() ? new InvocationPluginAssertions(plugin, args, targetMethod, resultType) : null;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1205 if (InvocationPlugin.execute(this, targetMethod, plugin, args)) {
19955
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1206 assert assertions.check(true);
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
1207 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
1208 }
19955
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
1209 assert assertions.check(false);
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
1210 }
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
1211 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
1212 }
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
1213
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1214 private boolean tryGenericInvocationPlugin(ValueNode[] args, ResolvedJavaMethod targetMethod) {
19787
7117697d11e1 refactored graph builder plugins into a separate class
Doug Simon <doug.simon@oracle.com>
parents: 19783
diff changeset
1215 GenericInvocationPlugin plugin = graphBuilderConfig.getPlugins().getGenericInvocationPlugin();
19417
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
1216 return plugin != null && plugin.apply(this, targetMethod, args);
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
1217 }
042f0a8ebce2 completed integration of AnnotatedInvocationPlugin
Doug Simon <doug.simon@oracle.com>
parents: 19414
diff changeset
1218
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
1219 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
1220 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
1221 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
1222 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
1223 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
1224 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
1225 }
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
1226 }
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
1227 }
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
1228 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
1229 }
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
1230
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
1231 private boolean tryInline(ValueNode[] args, ResolvedJavaMethod targetMethod, InvokeKind invokeKind, JavaType returnType) {
19787
7117697d11e1 refactored graph builder plugins into a separate class
Doug Simon <doug.simon@oracle.com>
parents: 19783
diff changeset
1232 InlineInvokePlugin plugin = graphBuilderConfig.getPlugins().getInlineInvokePlugin();
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
1233 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
1234 return false;
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
1235 }
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1236 InlineInfo inlineInfo = plugin.getInlineInfo(this, targetMethod, args, returnType);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1237 if (inlineInfo != null) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1238 return inline(plugin, targetMethod, inlineInfo, args);
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
1239 }
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
1240 return false;
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
1241 }
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
1242
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1243 boolean inline(InlineInvokePlugin plugin, ResolvedJavaMethod targetMethod, InlineInfo inlineInfo, ValueNode[] args) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1244 int bci = bci();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1245 ResolvedJavaMethod inlinedMethod = inlineInfo.methodToInline;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1246 if (TraceInlineDuringParsing.getValue() || TraceParserPlugins.getValue()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1247 if (targetMethod.equals(inlinedMethod)) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1248 traceWithContext("inlining call to %s", inlinedMethod.format("%h.%n(%p)"));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1249 } else {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1250 traceWithContext("inlining call to %s as replacement for %s", inlinedMethod.format("%h.%n(%p)"), targetMethod.format("%h.%n(%p)"));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1251 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1252 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1253 ReplacementContext context = this.replacementContext;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1254 if (context != null && context.isCallToOriginal(targetMethod)) {
19812
97a72dcdac8d disallow intrinsics from calling the original method
Doug Simon <doug.simon@oracle.com>
parents: 19811
diff changeset
1255 assert context.asIntrinsic() == null : "intrinsic cannot call the method it is intrinsifying";
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1256 // Self recursive replacement means the original
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1257 // method should be called.
19811
1e27e31aca11 fixed bug in managing replacement scope during bytecode parsing and improved API for querying replacement info from graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19808
diff changeset
1258 if (context.method.hasBytecodes()) {
19812
97a72dcdac8d disallow intrinsics from calling the original method
Doug Simon <doug.simon@oracle.com>
parents: 19811
diff changeset
1259 parseAndInlineCallee(context.method, args, null);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1260 } else {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1261 return false;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1262 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1263 } else {
19839
93b74f0db076 don't treat Truffle method inlining substitutions as graph builder replacements
Doug Simon <doug.simon@oracle.com>
parents: 19812
diff changeset
1264 if (context == null && inlineInfo.isReplacement) {
93b74f0db076 don't treat Truffle method inlining substitutions as graph builder replacements
Doug Simon <doug.simon@oracle.com>
parents: 19812
diff changeset
1265 assert !inlinedMethod.equals(targetMethod);
93b74f0db076 don't treat Truffle method inlining substitutions as graph builder replacements
Doug Simon <doug.simon@oracle.com>
parents: 19812
diff changeset
1266 if (inlineInfo.isIntrinsic) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1267 context = new IntrinsicContext(targetMethod, inlinedMethod, args, bci);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1268 } else {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1269 context = new ReplacementContext(targetMethod, inlinedMethod);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1270 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1271 }
19811
1e27e31aca11 fixed bug in managing replacement scope during bytecode parsing and improved API for querying replacement info from graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19808
diff changeset
1272 if (inlinedMethod.hasBytecodes()) {
1e27e31aca11 fixed bug in managing replacement scope during bytecode parsing and improved API for querying replacement info from graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19808
diff changeset
1273 parseAndInlineCallee(inlinedMethod, args, context);
1e27e31aca11 fixed bug in managing replacement scope during bytecode parsing and improved API for querying replacement info from graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19808
diff changeset
1274 if (plugin != null) {
1e27e31aca11 fixed bug in managing replacement scope during bytecode parsing and improved API for querying replacement info from graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19808
diff changeset
1275 plugin.postInline(inlinedMethod);
1e27e31aca11 fixed bug in managing replacement scope during bytecode parsing and improved API for querying replacement info from graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19808
diff changeset
1276 }
1e27e31aca11 fixed bug in managing replacement scope during bytecode parsing and improved API for querying replacement info from graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19808
diff changeset
1277 } else {
1e27e31aca11 fixed bug in managing replacement scope during bytecode parsing and improved API for querying replacement info from graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19808
diff changeset
1278 return false;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1279 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1280 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1281 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1282 }
19496
9525e4d5b385 disable (asserting) type checks in the FrameStateBuilder when parsing a replacement
Doug Simon <doug.simon@oracle.com>
parents: 19485
diff changeset
1283
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1284 /**
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1285 * Prints a line to {@link TTY} with a prefix indicating the current parse context. The
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1286 * prefix is of the form:
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1287 *
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1288 * <pre>
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1289 * {SPACE * n} {name of method being parsed} "(" {file name} ":" {line number} ")"
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1290 * </pre>
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1291 *
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1292 * where {@code n} is the current inlining depth.
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1293 *
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1294 * @param format a format string
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1295 * @param args arguments to the format string
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1296 */
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1297 @Override
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1298 protected void traceWithContext(String format, Object... args) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1299 StackTraceElement where = method.asStackTraceElement(bci());
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1300 TTY.println(format("%s%s (%s:%d) %s", nSpaces(getDepth()), method.isConstructor() ? method.format("%h.%n") : method.getName(), where.getFileName(), where.getLineNumber(),
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1301 format(format, args)));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1302 }
19496
9525e4d5b385 disable (asserting) type checks in the FrameStateBuilder when parsing a replacement
Doug Simon <doug.simon@oracle.com>
parents: 19485
diff changeset
1303
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1304 protected BytecodeParserError asParserError(Throwable e) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1305 if (e instanceof BytecodeParserError) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1306 return (BytecodeParserError) e;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1307 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1308 BytecodeParser bp = this;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1309 BytecodeParserError res = new BytecodeParserError(e);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1310 while (bp != null) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1311 res.addContext("parsing " + bp.method.asStackTraceElement(bp.bci()));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1312 bp = bp.parent;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1313 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1314 return res;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1315 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1316
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1317 private void parseAndInlineCallee(ResolvedJavaMethod targetMethod, ValueNode[] args, ReplacementContext calleeReplacementContext) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1318 BytecodeParser parser = new BytecodeParser(this, metaAccess, targetMethod, graphBuilderConfig, optimisticOpts, INVOCATION_ENTRY_BCI, calleeReplacementContext);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1319 HIRFrameStateBuilder startFrameState = new HIRFrameStateBuilder(parser, targetMethod, currentGraph);
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
1320 startFrameState.initializeFromArgumentsArray(args);
19776
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
1321 parser.build(this.lastInstr, startFrameState);
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
1322
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
1323 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
1324 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
1325 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
1326 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
1327 if (calleeReturnValue != null) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1328 frameState.push(targetMethod.getSignature().getReturnKind().getStackKind(), calleeReturnValue);
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
1329 }
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
1330 }
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
1331
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
1332 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
1333 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
1334 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
1335 assert calleeUnwindValue != 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
1336 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
1337 }
19323
a23984e249d2 record method dependencies if necessary when doing inlining during graph building
Doug Simon <doug.simon@oracle.com>
parents: 19253
diff changeset
1338
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
1339 // 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
1340 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
1341 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
1342 }
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
1343 }
8fe322db4b6d Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
1344
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1345 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
1346 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
1347 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1348
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1349 protected InvokeNode createInvoke(CallTargetNode callTarget, Kind resultType) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1350 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
1351 frameState.pushReturn(resultType, invoke);
19854
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
1352 invoke.setStateAfter(createFrameState(stream.nextBCI()));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1353 return invoke;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1354 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1355
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1356 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
1357 DispatchBeginNode exceptionEdge = handleException(null, bci());
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1358 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
1359 frameState.pushReturn(resultType, invoke);
19585
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19581
diff changeset
1360 invoke.setStateAfter(createFrameState(stream.nextBCI()));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1361 return invoke;
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
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1364 @Override
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1365 protected void genReturn(ValueNode returnVal, Kind returnKind) {
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1366
19776
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
1367 if (parent == null) {
19381
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1368 frameState.setRethrowException(false);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1369 frameState.clearStack();
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1370 beforeReturn(returnVal, returnKind);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1371 append(new ReturnNode(returnVal));
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1372 } else {
19483
625633886e25 Reduce number of fields in BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19482
diff changeset
1373 if (blockMap.getReturnCount() == 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
1374 // There is only a single return.
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1375 beforeReturn(returnVal, returnKind);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1376 this.returnValue = returnVal;
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
1377 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
1378 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
1379 } else {
19381
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1380 frameState.setRethrowException(false);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
1381 frameState.clearStack();
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1382 if (returnVal != null) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1383 frameState.push(returnKind, returnVal);
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
1384 }
19483
625633886e25 Reduce number of fields in BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19482
diff changeset
1385 assert blockMap.getReturnCount() > 1;
625633886e25 Reduce number of fields in BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19482
diff changeset
1386 appendGoto(blockMap.getReturnBlock());
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1387 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1388 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1389 }
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1390
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1391 private void beforeReturn(ValueNode x, Kind kind) {
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
1392 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
1393 append(createInfoPointNode(InfopointReason.METHOD_END));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1394 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1395
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1396 synchronizedEpilogue(BytecodeFrame.AFTER_BCI, x, kind);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1397 if (frameState.lockDepth() != 0) {
19521
9c4168877444 Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19515
diff changeset
1398 throw bailout("unbalanced monitors");
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1399 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1400 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1401
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1402 @Override
19854
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
1403 protected void genMonitorEnter(ValueNode x, int bci) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1404 MonitorIdNode monitorId = currentGraph.add(new MonitorIdNode(frameState.lockDepth()));
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1405 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
1406 frameState.pushLock(x, monitorId);
19854
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
1407 monitorEnter.setStateAfter(createFrameState(bci));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1408 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1409
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1410 @Override
19854
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
1411 protected void genMonitorExit(ValueNode x, ValueNode escapedReturnValue, int bci) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1412 MonitorIdNode monitorId = frameState.peekMonitorId();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1413 ValueNode lockedObject = frameState.popLock();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1414 if (GraphUtil.originalValue(lockedObject) != GraphUtil.originalValue(x)) {
19521
9c4168877444 Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19515
diff changeset
1415 throw bailout(String.format("unbalanced monitors: mismatch at monitorexit, %s != %s", GraphUtil.originalValue(x), GraphUtil.originalValue(lockedObject)));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1416 }
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1417 MonitorExitNode monitorExit = append(new MonitorExitNode(x, monitorId, escapedReturnValue));
19854
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
1418 monitorExit.setStateAfter(createFrameState(bci));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1419 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1420
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1421 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1422 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
1423 BciBlock successor = currentBlock.getJsrSuccessor();
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1424 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
1425 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
1426 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
1427 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
1428 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
1429 }
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
1430 if (successor.getJsrScope().nextReturnAddress() != nextBci) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1431 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
1432 }
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
1433 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
1434 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
1435 appendGoto(successor);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1436 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1437
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1438 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1439 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
1440 BciBlock successor = currentBlock.getRetSuccessor();
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1441 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
1442 JsrScope scope = currentBlock.getJsrScope();
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1443 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
1444 ConstantNode returnBciNode = getJsrConstant(retAddress);
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
1445 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
1446 guard = currentGraph.unique(guard);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1447 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
1448 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
1449 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
1450 }
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
1451 appendGoto(successor);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1452 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1453
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
1454 private ConstantNode getJsrConstant(long bci) {
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
1455 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
1456 Stamp nextBciStamp = StampFactory.forConstant(nextBciConstant);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1457 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
1458 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
1459 }
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
1460
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1461 @Override
15028
7ee9decb2784 AbstractBytecodeParser: rework genIntegerSwitch.
Josef Eisl <josef.eisl@jku.at>
parents: 15027
diff changeset
1462 protected void genIntegerSwitch(ValueNode value, ArrayList<BciBlock> actualSuccessors, int[] keys, double[] keyProbabilities, int[] keySuccessors) {
19512
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1463 if (value.isConstant()) {
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1464 JavaConstant constant = (JavaConstant) value.asConstant();
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1465 int constantValue = constant.asInt();
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1466 for (int i = 0; i < keys.length; ++i) {
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1467 if (keys[i] == constantValue) {
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1468 appendGoto(actualSuccessors.get(keySuccessors[i]));
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1469 return;
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1470 }
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1471 }
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1472 appendGoto(actualSuccessors.get(keySuccessors[keys.length]));
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1473 } else {
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1474 this.controlFlowSplit = true;
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1475 double[] successorProbabilities = successorProbabilites(actualSuccessors.size(), keySuccessors, keyProbabilities);
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1476 IntegerSwitchNode switchNode = append(new IntegerSwitchNode(value, actualSuccessors.size(), keys, keyProbabilities, keySuccessors));
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1477 for (int i = 0; i < actualSuccessors.size(); i++) {
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1478 switchNode.setBlockSuccessor(i, createBlockTarget(successorProbabilities[i], actualSuccessors.get(i), frameState));
7f168e4c5dde Added flag FailedLoopExplosionIsFatal. Added support for graph builder canonicalization of integer switches.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19509
diff changeset
1479 }
15028
7ee9decb2784 AbstractBytecodeParser: rework genIntegerSwitch.
Josef Eisl <josef.eisl@jku.at>
parents: 15027
diff changeset
1480 }
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
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1483 @Override
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
1484 protected ConstantNode appendConstant(JavaConstant constant) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1485 assert constant != null;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1486 return ConstantNode.forConstant(constant, metaAccess, currentGraph);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1487 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1488
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
1489 @SuppressWarnings("unchecked")
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1490 @Override
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
1491 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
1492 if (v.graph() != null) {
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
1493 // 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
1494 return v;
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19173
diff changeset
1495 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1496 if (v instanceof ControlSinkNode) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1497 return append((ControlSinkNode) v);
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 if (v instanceof ControlSplitNode) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1500 return append((ControlSplitNode) v);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1501 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1502 if (v instanceof FixedWithNextNode) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1503 return append((FixedWithNextNode) v);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1504 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1505 if (v instanceof FloatingNode) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1506 return append((FloatingNode) v);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1507 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1508 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
1509 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1510
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1511 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
1512 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
1513 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
1514 T added = currentGraph.add(fixed);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1515 lastInstr.setNext(added);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1516 lastInstr = null;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1517 return added;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1518 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1519
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1520 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
1521 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
1522 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
1523 T added = currentGraph.add(fixed);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1524 lastInstr.setNext(added);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1525 lastInstr = null;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1526 return added;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1527 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1528
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1529 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
1530 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
1531 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
1532 T added = currentGraph.add(fixed);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1533 lastInstr.setNext(added);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1534 lastInstr = added;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1535 return added;
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
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
1538 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
1539 if (v.graph() != null) {
2412408a4319 Fixes to the graph builder after recent changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
1540 return v;
2412408a4319 Fixes to the graph builder after recent changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
1541 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1542 T added = currentGraph.unique(v);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1543 return added;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1544 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1545
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1546 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
1547 if (currentBlock != null && !explodeLoops) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1548 long exits = currentBlock.loops & ~targetBlock.loops;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1549 if (exits != 0) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1550 LoopExitNode firstLoopExit = null;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1551 LoopExitNode lastLoopExit = null;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1552
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1553 int pos = 0;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1554 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
1555 do {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1556 long lMask = 1L << pos;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1557 if ((exits & lMask) != 0) {
19483
625633886e25 Reduce number of fields in BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19482
diff changeset
1558 exitLoops.add(blockMap.getLoopHeader(pos));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1559 exits &= ~lMask;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1560 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1561 pos++;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1562 } while (exits != 0);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1563
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1564 Collections.sort(exitLoops, new Comparator<BciBlock>() {
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 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1567 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
1568 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
1569 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1570 });
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1571
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1572 int bci = targetBlock.startBci;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1573 if (targetBlock instanceof ExceptionDispatchBlock) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1574 bci = ((ExceptionDispatchBlock) targetBlock).deoptBci;
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 HIRFrameStateBuilder newState = state.copy();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1577 for (BciBlock loop : exitLoops) {
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1578 LoopBeginNode loopBegin = (LoopBeginNode) getFirstInstruction(loop, this.getCurrentDimension());
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1579 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
1580 if (lastLoopExit != null) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1581 lastLoopExit.setNext(loopExit);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1582 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1583 if (firstLoopExit == null) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1584 firstLoopExit = loopExit;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1585 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1586 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
1587 Debug.log("Target %s Exits %s, scanning framestates...", targetBlock, loop);
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19534
diff changeset
1588 newState.insertLoopProxies(loopExit, getEntryState(loop, this.getCurrentDimension()));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1589 loopExit.setStateAfter(newState.create(bci));
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1590 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1591
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1592 lastLoopExit.setNext(target);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1593 return new Target(firstLoopExit, newState);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1594 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1595 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1596 return new Target(target, state);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1597 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1598
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19534
diff changeset
1599 private HIRFrameStateBuilder getEntryState(BciBlock block, int dimension) {
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1600 int id = block.id;
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1601 if (dimension == 0) {
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1602 return entryStateArray[id];
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1603 } else {
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1604 return getEntryStateMultiDimension(dimension, id);
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1605 }
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1606 }
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1607
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19534
diff changeset
1608 private HIRFrameStateBuilder getEntryStateMultiDimension(int dimension, int id) {
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1609 if (entryStateMatrix != null && dimension - 1 < entryStateMatrix.length) {
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19534
diff changeset
1610 HIRFrameStateBuilder[] entryStateArrayEntry = entryStateMatrix[dimension - 1];
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1611 if (entryStateArrayEntry == null) {
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1612 return null;
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1613 }
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1614 return entryStateArrayEntry[id];
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1615 } else {
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1616 return null;
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1617 }
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1618 }
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1619
19515
387d7192e18f Replace abstract type usage in graph builder with concrete type usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19512
diff changeset
1620 private void setEntryState(BciBlock block, int dimension, HIRFrameStateBuilder entryState) {
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1621 int id = block.id;
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1622 if (dimension == 0) {
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1623 this.entryStateArray[id] = entryState;
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1624 } else {
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1625 setEntryStateMultiDimension(dimension, entryState, id);
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1626 }
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1627 }
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1628
19515
387d7192e18f Replace abstract type usage in graph builder with concrete type usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19512
diff changeset
1629 private void setEntryStateMultiDimension(int dimension, HIRFrameStateBuilder entryState, int id) {
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1630 if (entryStateMatrix == null) {
19515
387d7192e18f Replace abstract type usage in graph builder with concrete type usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19512
diff changeset
1631 entryStateMatrix = new HIRFrameStateBuilder[4][];
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1632 }
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1633 if (dimension - 1 < entryStateMatrix.length) {
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1634 // We are within bounds.
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1635 } else {
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1636 // We are out of bounds.
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1637 entryStateMatrix = Arrays.copyOf(entryStateMatrix, Math.max(entryStateMatrix.length * 2, dimension));
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1638 }
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1639 if (entryStateMatrix[dimension - 1] == null) {
19515
387d7192e18f Replace abstract type usage in graph builder with concrete type usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19512
diff changeset
1640 entryStateMatrix[dimension - 1] = new HIRFrameStateBuilder[blockMap.getBlockCount()];
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1641 }
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1642 entryStateMatrix[dimension - 1][id] = entryState;
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1643 }
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1644
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1645 private void setFirstInstruction(BciBlock block, int dimension, FixedWithNextNode firstInstruction) {
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1646 int id = block.id;
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1647 if (dimension == 0) {
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1648 this.firstInstructionArray[id] = firstInstruction;
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1649 } else {
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1650 setFirstInstructionMultiDimension(dimension, firstInstruction, id);
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1651 }
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1652 }
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1653
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1654 private void setFirstInstructionMultiDimension(int dimension, FixedWithNextNode firstInstruction, int id) {
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1655 if (firstInstructionMatrix == null) {
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1656 firstInstructionMatrix = new FixedWithNextNode[4][];
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1657 }
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1658 if (dimension - 1 < firstInstructionMatrix.length) {
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1659 // We are within bounds.
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1660 } else {
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1661 // We are out of bounds.
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1662 firstInstructionMatrix = Arrays.copyOf(firstInstructionMatrix, Math.max(firstInstructionMatrix.length * 2, dimension));
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1663 }
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1664 if (firstInstructionMatrix[dimension - 1] == null) {
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1665 firstInstructionMatrix[dimension - 1] = new FixedWithNextNode[blockMap.getBlockCount()];
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1666 }
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1667 firstInstructionMatrix[dimension - 1][id] = firstInstruction;
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1668 }
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1669
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1670 private FixedWithNextNode getFirstInstruction(BciBlock block, int dimension) {
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1671 int id = block.id;
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1672 if (dimension == 0) {
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1673 return firstInstructionArray[id];
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1674 } else {
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1675 return getFirstInstructionMultiDimension(dimension, id);
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1676 }
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1677 }
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1678
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1679 private FixedWithNextNode getFirstInstructionMultiDimension(int dimension, int id) {
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1680 if (firstInstructionMatrix != null && dimension - 1 < firstInstructionMatrix.length) {
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1681 FixedWithNextNode[] firstInstructionArrayEntry = firstInstructionMatrix[dimension - 1];
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1682 if (firstInstructionArrayEntry == null) {
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1683 return null;
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1684 }
19485
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1685 return firstInstructionArrayEntry[id];
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1686 } else {
82475095334f Refactorings / clean ups in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19484
diff changeset
1687 return null;
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1688 }
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1689 }
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1690
15030
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1691 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
1692 assert probability >= 0 && probability <= 1.01 : probability;
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1693 if (isNeverExecutedCode(probability)) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1694 return currentGraph.add(new DeoptimizeNode(InvalidateReprofile, UnreachedCode));
15030
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1695 } else {
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1696 assert block != null;
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1697 return createTarget(block, stateAfter);
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1698 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1699 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1700
15030
e098038093d5 AbstractBytecodeParser: move createTarget to GraphBuilderPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 15029
diff changeset
1701 private FixedNode createTarget(BciBlock block, HIRFrameStateBuilder state) {
19533
e5465c0c5828 Reuse HIRFrameStateBuilder for false branch of if.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19532
diff changeset
1702 return createTarget(block, state, false, false);
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
1703 }
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
1704
19533
e5465c0c5828 Reuse HIRFrameStateBuilder for false branch of if.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19532
diff changeset
1705 private FixedNode createTarget(BciBlock block, HIRFrameStateBuilder state, boolean canReuseInstruction, boolean canReuseState) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1706 assert block != null && state != null;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1707 assert !block.isExceptionEntry || state.stackSize() == 1;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1708
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1709 int operatingDimension = findOperatingDimension(block, state);
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1710
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1711 if (getFirstInstruction(block, operatingDimension) == null) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1712 /*
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1713 * 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
1714 * 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
1715 * this block again.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1716 */
18828
161503950494 Avoid insertion of block placeholder node. Use begin node instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18825
diff changeset
1717 FixedNode targetNode;
19533
e5465c0c5828 Reuse HIRFrameStateBuilder for false branch of if.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19532
diff changeset
1718 if (canReuseInstruction && (block.getPredecessorCount() == 1 || !controlFlowSplit) && !block.isLoopHeader && (currentBlock.loops & ~block.loops) == 0) {
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1719 setFirstInstruction(block, 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
1720 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
1721 } else {
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1722 setFirstInstruction(block, operatingDimension, currentGraph.add(new BeginNode()));
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
1723 }
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1724 targetNode = getFirstInstruction(block, operatingDimension);
18828
161503950494 Avoid insertion of block placeholder node. Use begin node instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18825
diff changeset
1725 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
1726 FixedNode result = target.fixed;
19533
e5465c0c5828 Reuse HIRFrameStateBuilder for false branch of if.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19532
diff changeset
1727 HIRFrameStateBuilder currentEntryState = target.state == state ? (canReuseState ? state : state.copy()) : target.state;
19484
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1728 setEntryState(block, operatingDimension, currentEntryState);
13d2019e24f1 Move mutable parts of BciBlock to BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19483
diff changeset
1729 currentEntryState.clearNonLiveLocals(block, liveness, true);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1730
18828
161503950494 Avoid insertion of block placeholder node. Use begin node instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18825
diff changeset
1731 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
1732 return result;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1733 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1734
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1735 // We already saw this block before, so we have to merge states.
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19534
diff changeset
1736 if (!getEntryState(block, operatingDimension).isCompatibleWith(state)) {
19521
9c4168877444 Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19515
diff changeset
1737 throw bailout("stacks do not match; bytecodes would not verify");
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1738 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1739
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1740 if (getFirstInstruction(block, operatingDimension) instanceof LoopBeginNode) {
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
1741 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
1742 /*
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1743 * 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
1744 * the loop begin node created before.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1745 */
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1746 LoopBeginNode loopBegin = (LoopBeginNode) getFirstInstruction(block, operatingDimension);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1747 LoopEndNode loopEnd = currentGraph.add(new LoopEndNode(loopBegin));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1748 if (parsingReplacement()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1749 loopEnd.disableSafepoint();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1750 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1751 Target target = checkLoopExit(loopEnd, block, state);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1752 FixedNode result = target.fixed;
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19534
diff changeset
1753 getEntryState(block, operatingDimension).merge(loopBegin, target.state);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1754
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1755 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
1756 return result;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1757 }
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1758 assert currentBlock == null || currentBlock.getId() < block.getId() || this.mergeExplosions : "must not be backward branch";
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1759 assert getFirstInstruction(block, operatingDimension).next() == null || this.mergeExplosions : "bytecodes already parsed for block";
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1760
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1761 if (getFirstInstruction(block, operatingDimension) instanceof AbstractBeginNode && !(getFirstInstruction(block, operatingDimension) instanceof AbstractMergeNode)) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1762 /*
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1763 * This is the second time we see this block. Create the actual MergeNode and
19581
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
1764 * the End Node for the already existing edge.
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1765 */
19581
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
1766 AbstractBeginNode beginNode = (AbstractBeginNode) getFirstInstruction(block, operatingDimension);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1767
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1768 // The EndNode for the already existing edge.
19509
caad3adc5fde Change forward ends to type EndNode and not AbstractEndNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
1769 EndNode end = currentGraph.add(new EndNode());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1770 // 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
1771 AbstractMergeNode mergeNode = currentGraph.add(new MergeNode());
19581
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
1772 FixedNode next = beginNode.next();
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1773
19581
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
1774 if (beginNode.predecessor() instanceof ControlSplitNode) {
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
1775 beginNode.setNext(end);
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
1776 } else {
19581
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
1777 beginNode.replaceAtPredecessor(end);
67d16e135ac2 Remove redundant begin nodes after graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19580
diff changeset
1778 beginNode.safeDelete();
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
1779 }
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
1780
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1781 mergeNode.addForwardEnd(end);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1782 mergeNode.setNext(next);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1783
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1784 setFirstInstruction(block, operatingDimension, mergeNode);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1785 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1786
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1787 AbstractMergeNode mergeNode = (AbstractMergeNode) getFirstInstruction(block, operatingDimension);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1788
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1789 // The EndNode for the newly merged edge.
19509
caad3adc5fde Change forward ends to type EndNode and not AbstractEndNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
1790 EndNode newEnd = currentGraph.add(new EndNode());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1791 Target target = checkLoopExit(newEnd, block, state);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1792 FixedNode result = target.fixed;
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19534
diff changeset
1793 getEntryState(block, operatingDimension).merge(mergeNode, target.state);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1794 mergeNode.addForwardEnd(newEnd);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1795
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1796 Debug.log("createTarget %s: merging state, result: %s", block, result);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1797 return result;
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1798 }
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1799
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1800 private int findOperatingDimension(BciBlock block, HIRFrameStateBuilder state) {
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1801 if (this.explodeLoops && this.explodeLoopsContext != null && !this.explodeLoopsContext.isEmpty()) {
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1802 return findOperatingDimensionWithLoopExplosion(block, state);
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1803 }
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1804 return this.getCurrentDimension();
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1805 }
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1806
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1807 private int findOperatingDimensionWithLoopExplosion(BciBlock block, HIRFrameStateBuilder state) {
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1808 int i;
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1809 for (i = explodeLoopsContext.size() - 1; i >= 0; --i) {
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1810 ExplodedLoopContext context = explodeLoopsContext.elementAt(i);
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1811 if (context.header == block) {
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1812
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1813 if (this.mergeExplosions) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1814 state.clearNonLiveLocals(block, liveness, true);
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1815 Integer cachedDimension = mergeExplosionsMap.get(state);
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1816 if (cachedDimension != null) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1817 return cachedDimension;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1818 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1819 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1820
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1821 // We have a hit on our current explosion context loop begin.
19619
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1822 if (context.targetPeelIteration == null) {
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1823 context.targetPeelIteration = new int[1];
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1824 } else {
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1825 context.targetPeelIteration = Arrays.copyOf(context.targetPeelIteration, context.targetPeelIteration.length + 1);
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1826 }
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1827
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1828 // This is the first hit => allocate a new dimension and at the same
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1829 // time mark the context loop begin as hit during the current
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1830 // iteration.
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1831 if (this.mergeExplosions) {
19638
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
1832 this.addToMergeCache(state, nextPeelIteration);
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19622
diff changeset
1833 }
19619
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1834 context.targetPeelIteration[context.targetPeelIteration.length - 1] = nextPeelIteration++;
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1835 if (nextPeelIteration > MaximumLoopExplosionCount.getValue()) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1836 String message = "too many loop explosion iterations - does the explosion not terminate for method " + method + "?";
19619
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1837 if (FailedLoopExplosionIsFatal.getValue()) {
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1838 throw new RuntimeException(message);
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1839 } else {
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1840 throw bailout(message);
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1841 }
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1842 }
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1843
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1844 // Operate on the target dimension.
19619
711f46f691cf New bytecode interpreter partial evaluation test including an IFZERO bytecode. Make graph builder loop explosion support multiple loop back edges from one peeling iteration.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
1845 return context.targetPeelIteration[context.targetPeelIteration.length - 1];
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1846 } else if (block.getId() > context.header.getId() && block.getId() <= context.header.loopEnd) {
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1847 // We hit the range of this context.
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1848 return context.peelIteration;
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1849 }
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1850 }
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1851
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1852 // No dimension found.
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1853 return 0;
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1854 }
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
1855
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1856 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1857 * 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
1858 * 0, the block deoptimizes immediately.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1859 */
18993
480bd3b1adcd Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18937
diff changeset
1860 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
1861 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
1862 AbstractBeginNode begin = BeginNode.begin(target);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1863
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15032
diff changeset
1864 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
1865 + "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
1866 return begin;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1867 }
5051
2ab527c53dba another fix for goto's deopt case
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5050
diff changeset
1868
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1869 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
1870 if (target.isStatic()) {
18361
6ac7e9c85be6 Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1871 return appendConstant(target.getDeclaringClass().getJavaClass());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1872 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1873 return state.loadLocal(0);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1874 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1875 }
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1876
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18917
diff changeset
1877 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
1878 // Ignore blocks that have no predecessors by the time their bytecodes are parsed
19536
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1879 int currentDimension = this.getCurrentDimension();
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1880 FixedWithNextNode firstInstruction = getFirstInstruction(block, currentDimension);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1881 if (firstInstruction == null) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1882 Debug.log("Ignoring block %s", block);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1883 return;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1884 }
19536
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1885 try (Indent indent = Debug.logAndIndent("Parsing block %s firstInstruction: %s loopHeader: %b", block, firstInstruction, 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
1886
19536
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1887 lastInstr = firstInstruction;
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1888 frameState = getEntryState(block, currentDimension);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1889 parser.setCurrentFrameState(frameState);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1890 currentBlock = block;
4614
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4554
diff changeset
1891
19536
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1892 if (firstInstruction instanceof AbstractMergeNode) {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1893 setMergeStateAfter(block, firstInstruction);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1894 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14851
diff changeset
1895
19483
625633886e25 Reduce number of fields in BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19482
diff changeset
1896 if (block == blockMap.getReturnBlock()) {
19536
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1897 handleReturnBlock();
19483
625633886e25 Reduce number of fields in BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19482
diff changeset
1898 } else if (block == blockMap.getUnwindBlock()) {
19536
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1899 handleUnwindBlock();
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1900 } else if (block instanceof ExceptionDispatchBlock) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1901 createExceptionDispatch((ExceptionDispatchBlock) block);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1902 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1903 frameState.setRethrowException(false);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1904 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
1905 }
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14851
diff changeset
1906 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1907 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1908
19536
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1909 private void handleUnwindBlock() {
19783
Doug Simon <doug.simon@oracle.com>
parents: 19776 19737
diff changeset
1910 if (parent == null) {
19536
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1911 frameState.setRethrowException(false);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1912 createUnwind();
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1913 } else {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1914 ValueNode exception = frameState.apop();
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1915 this.unwindValue = exception;
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1916 this.beforeUnwindNode = this.lastInstr;
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1917 }
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1918 }
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1919
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1920 private void handleReturnBlock() {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1921 Kind returnKind = method.getSignature().getReturnKind().getStackKind();
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1922 ValueNode x = returnKind == Kind.Void ? null : frameState.pop(returnKind);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1923 assert frameState.stackSize() == 0;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1924 beforeReturn(x, returnKind);
19536
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1925 this.returnValue = x;
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1926 this.beforeReturnNode = this.lastInstr;
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1927 }
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1928
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1929 private void setMergeStateAfter(BciBlock block, FixedWithNextNode firstInstruction) {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1930 AbstractMergeNode abstractMergeNode = (AbstractMergeNode) firstInstruction;
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1931 if (abstractMergeNode.stateAfter() == null) {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1932 int bci = block.startBci;
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1933 if (block instanceof ExceptionDispatchBlock) {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1934 bci = ((ExceptionDispatchBlock) block).deoptBci;
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1935 }
19585
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19581
diff changeset
1936 abstractMergeNode.setStateAfter(createFrameState(bci));
19536
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1937 }
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1938 }
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
1939
18916
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1940 /**
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1941 * 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
1942 * this one:
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1943 *
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1944 * <pre>
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1945 * for (;;) {
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1946 * try {
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1947 * break;
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1948 * } catch (UnresolvedException iioe) {
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1949 * }
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1950 * }
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1951 * </pre>
66669e016466 Small clean up in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18915
diff changeset
1952 */
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1953 private void connectLoopEndToBegin() {
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19390
diff changeset
1954 for (LoopBeginNode begin : currentGraph.getNodes(LoopBeginNode.TYPE)) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1955 if (begin.loopEnds().isEmpty()) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1956 assert begin.forwardEndCount() == 1;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1957 currentGraph.reduceDegenerateLoopBegin(begin);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1958 } else {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1959 GraphUtil.normalizeLoopBegin(begin);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1960 }
9003
a8fea2979e63 eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents: 8660
diff changeset
1961 }
a8fea2979e63 eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents: 8660
diff changeset
1962 }
a8fea2979e63 eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents: 8660
diff changeset
1963
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1964 private void createUnwind() {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1965 assert frameState.stackSize() == 1 : frameState;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1966 ValueNode exception = frameState.apop();
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1967 synchronizedEpilogue(BytecodeFrame.AFTER_EXCEPTION_BCI, null, null);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
1968 append(new UnwindNode(exception));
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1969 }
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1970
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1971 private void synchronizedEpilogue(int bci, ValueNode currentReturnValue, Kind currentReturnValueKind) {
15267
98d45600222c Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15266
diff changeset
1972 if (method.isSynchronized()) {
18922
fede93375dcb Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18921
diff changeset
1973 if (currentReturnValue != null) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
1974 frameState.push(currentReturnValueKind, currentReturnValue);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1975 }
19854
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
1976 genMonitorExit(methodSynchronizedObject, currentReturnValue, bci);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1977 assert !frameState.rethrowException();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1978 }
6676
090868cbcda6 Graal infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6648
diff changeset
1979 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1980
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1981 private void createExceptionDispatch(ExceptionDispatchBlock block) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1982 assert frameState.stackSize() == 1 : frameState;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1983 if (block.handler.isCatchAll()) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1984 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
1985 appendGoto(block.getSuccessor(0));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1986 return;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1987 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
1988
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1989 JavaType catchType = block.handler.getCatchType();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1990 if (graphBuilderConfig.eagerResolving()) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1991 catchType = lookupType(block.handler.catchTypeCPI(), INSTANCEOF);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1992 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1993 boolean initialized = (catchType instanceof ResolvedJavaType);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1994 if (initialized && graphBuilderConfig.getSkippedExceptionTypes() != null) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1995 ResolvedJavaType resolvedCatchType = (ResolvedJavaType) catchType;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1996 for (ResolvedJavaType skippedType : graphBuilderConfig.getSkippedExceptionTypes()) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1997 if (skippedType.isAssignableFrom(resolvedCatchType)) {
19483
625633886e25 Reduce number of fields in BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19482
diff changeset
1998 BciBlock nextBlock = block.getSuccessorCount() == 1 ? blockMap.getUnwindBlock() : block.getSuccessor(1);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
1999 ValueNode exception = frameState.stackAt(0);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
2000 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
2001 FixedNode nextDispatch = createTarget(nextBlock, frameState);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
2002 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
2003 return;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2004 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
2005 }
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
2006 }
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
2007
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2008 if (initialized) {
19483
625633886e25 Reduce number of fields in BytecodeParser.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19482
diff changeset
2009 BciBlock nextBlock = block.getSuccessorCount() == 1 ? blockMap.getUnwindBlock() : block.getSuccessor(1);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2010 ValueNode exception = frameState.stackAt(0);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
2011 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
2012 frameState.apop();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2013 frameState.push(Kind.Object, checkCast);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2014 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
2015 frameState.apop();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2016 frameState.push(Kind.Object, exception);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2017 FixedNode nextDispatch = createTarget(nextBlock, frameState);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2018 checkCast.setNext(catchSuccessor);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
2019 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
2020 } else {
18361
6ac7e9c85be6 Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
2021 handleUnresolvedExceptionType(catchType);
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
2022 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2023 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2024
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
2025 private void appendGoto(BciBlock successor) {
19533
e5465c0c5828 Reuse HIRFrameStateBuilder for false branch of if.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19532
diff changeset
2026 FixedNode targetInstr = createTarget(successor, frameState, true, true);
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
2027 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
2028 lastInstr.setNext(targetInstr);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2029 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2030 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2031
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2032 @Override
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2033 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
2034 if (block.isLoopHeader && !explodeLoops) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2035 // 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
2036 // the loop.
19367
f9ccdf258dd4 Further reduction of begin node creation when inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19366
diff changeset
2037 controlFlowSplit = true;
19632
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
2038 LoopBeginNode loopBegin = appendLoopBegin(this.lastInstr);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2039 lastInstr = loopBegin;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
2040
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2041 // 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
2042 frameState.insertLoopPhis(liveness, block.loopId, loopBegin);
19585
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19581
diff changeset
2043 loopBegin.setStateAfter(createFrameState(block.startBci));
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
2044
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2045 /*
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2046 * 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
2047 * 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
2048 * non-loop predecessor.
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2049 */
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
2050 setFirstInstruction(block, this.getCurrentDimension(), loopBegin);
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2051 /*
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2052 * 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
2053 * 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
2054 */
19482
63965fcb019b Create helper methods in graph builder to support pending refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19481
diff changeset
2055 setEntryState(block, this.getCurrentDimension(), frameState.copy());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2056
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2057 Debug.log(" created loop header %s", loopBegin);
19638
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
2058 } else if (block.isLoopHeader && explodeLoops && this.mergeExplosions) {
96cf6f7678d2 Add test case and support for nested loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19632
diff changeset
2059 frameState = frameState.copy();
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
2060 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2061 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
2062 Debug.log(" frameState: %s", frameState);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2063
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2064 lastInstr = finishInstruction(lastInstr, frameState);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2065
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2066 int endBCI = stream.endBCI();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2067
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2068 stream.setBCI(block.startBci);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2069 int bci = block.startBci;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2070 BytecodesParsed.add(block.endBci - bci);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2071
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2072 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
2073 if (graphBuilderConfig.insertNonSafepointDebugInfo() && lnt != null) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2074 currentLineNumber = lnt.getLineNumber(bci);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2075 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
2076 append(createInfoPointNode(InfopointReason.LINE_NUMBER));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2077 previousLineNumber = currentLineNumber;
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
2078 }
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
2079 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2080
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2081 // read the opcode
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2082 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
2083 assert traceState();
fc390dcb0ba5 Enable bytecode instruction level tracing only when assertions are enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19382
diff changeset
2084 assert traceInstruction(bci, opcode, bci == block.startBci);
19776
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2085 if (parent == null && bci == entryBCI) {
18818
adf3a8581a67 Factor JSR info data into separate data structure from BciBlock.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18817
diff changeset
2086 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
2087 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
2088 }
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
2089 EntryMarkerNode x = append(new EntryMarkerNode());
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2090 frameState.insertProxies(x);
19585
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19581
diff changeset
2091 x.setStateAfter(createFrameState(bci));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2092 }
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2093
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2094 try {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2095 processBytecode(bci, opcode);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2096 } catch (Throwable e) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2097 throw asParserError(e);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2098 }
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2099
19853
77c667701cf3 Small simplification in GraphBuilderPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19847
diff changeset
2100 if (lastInstr == null || lastInstr.next() != null) {
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2101 break;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2102 }
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2103
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2104 stream.next();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2105 bci = stream.currentBCI();
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2106
19854
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
2107 assert block == currentBlock;
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
2108 assert !(lastInstr instanceof StateSplit) || lastInstr instanceof BeginNode || ((StateSplit) lastInstr).stateAfter() != null : lastInstr;
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2109 lastInstr = finishInstruction(lastInstr, frameState);
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2110 if (bci < endBCI) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2111 if (bci > block.endBci) {
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2112 assert !block.getSuccessor(0).isExceptionEntry;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2113 assert block.numNormalSuccessors() == 1;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2114 // 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
2115 appendGoto(block.getSuccessor(0));
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2116 break;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2117 }
5375
3035b6b881d9 removed stateAfter field from FixedWithNextNode - now only StateSplit implementations have this field
Doug Simon <doug.simon@oracle.com>
parents: 5373
diff changeset
2118 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2119 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2120 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
2121
19632
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
2122 private LoopBeginNode appendLoopBegin(FixedWithNextNode fixedWithNext) {
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
2123 EndNode preLoopEnd = currentGraph.add(new EndNode());
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
2124 LoopBeginNode loopBegin = currentGraph.add(new LoopBeginNode());
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
2125 fixedWithNext.setNext(preLoopEnd);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
2126 // Add the single non-loop predecessor of the loop header.
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
2127 loopBegin.addForwardEnd(preLoopEnd);
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
2128 return loopBegin;
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
2129 }
f727ca2940ba Support for loops for Truffle bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
2130
14900
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2131 /**
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2132 * 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
2133 *
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2134 * @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
2135 * @param state The current frame state.
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14904
diff changeset
2136 * @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
2137 */
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2138 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
2139 return instr;
be4c28683c08 Moved bytecode parsing from GraphBuilderPhase to BytecodeParseHelper.
Josef Eisl <josef.eisl@jku.at>
parents: 14899
diff changeset
2140 }
14758
c612c2742a4f extend graph builder and CompilationResult for substrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14746
diff changeset
2141
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
2142 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
2143 if (graphBuilderConfig.insertFullDebugInfo()) {
19585
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19581
diff changeset
2144 return new FullInfopointNode(reason, createFrameState(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
2145 } else {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18833
diff changeset
2146 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
2147 }
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
2148 }
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
2149
19387
fc390dcb0ba5 Enable bytecode instruction level tracing only when assertions are enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19382
diff changeset
2150 private boolean traceState() {
18817
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
2151 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
2152 traceStateHelper();
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
2153 }
19387
fc390dcb0ba5 Enable bytecode instruction level tracing only when assertions are enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19382
diff changeset
2154 return true;
18817
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
2155 }
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
2156
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
2157 private void traceStateHelper() {
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
2158 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
2159 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
2160 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
2161 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
2162 }
b51cfbc2bd07 Make allocation of loop header array in BciBlockMapping lazy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18490
diff changeset
2163 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
2164 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
2165 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
2166 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2167 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2168
14947
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
2169 @Override
14948
bc72e5ed9752 AbstractBytecodeParser: rename ifNode to genIf.
Josef Eisl <josef.eisl@jku.at>
parents: 14947
diff changeset
2170 protected void genIf(ValueNode x, Condition cond, ValueNode y) {
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
2171 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
2172 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
2173 BciBlock falseBlock = currentBlock.getSuccessor(1);
14947
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
2174 if (trueBlock == falseBlock) {
19534
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2175 // The target block is the same independent of the condition.
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
2176 appendGoto(trueBlock);
14947
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
2177 return;
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
2178 }
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
2179
19534
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2180 ValueNode a = x;
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2181 ValueNode b = y;
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2182
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2183 // Check whether the condition needs to mirror the operands.
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2184 if (cond.canonicalMirror()) {
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2185 a = y;
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2186 b = x;
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2187 }
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2188
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2189 // Create the logic node for the condition.
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2190 LogicNode condition = createLogicNode(cond, a, b);
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2191
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2192 // Check whether the condition needs to negate the result.
14947
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
2193 boolean negate = cond.canonicalNegate();
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
2194
19534
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2195 // Remove a logic negation node and fold it into the negate boolean.
19373
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19372
diff changeset
2196 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
2197 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
2198 negate = !negate;
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19372
diff changeset
2199 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
2200 }
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19372
diff changeset
2201
19117
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
2202 if (condition instanceof LogicConstantNode) {
19534
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2203 genConstantTargetIf(trueBlock, falseBlock, negate, condition);
19117
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
2204 } else {
19374
2412408a4319 Fixes to the graph builder after recent changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
2205 if (condition.graph() == null) {
2412408a4319 Fixes to the graph builder after recent changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
2206 condition = currentGraph.unique(condition);
2412408a4319 Fixes to the graph builder after recent changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
2207 }
2412408a4319 Fixes to the graph builder after recent changes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
2208
19455
dd9811d734e1 Undo previous change on probability cut-off for inlining. Perform experiment later.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19452
diff changeset
2209 // Need to get probability based on current bci.
dd9811d734e1 Undo previous change on probability cut-off for inlining. Perform experiment later.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19452
diff changeset
2210 double probability = branchProbability();
dd9811d734e1 Undo previous change on probability cut-off for inlining. Perform experiment later.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19452
diff changeset
2211
19532
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2212 if (negate) {
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2213 BciBlock tmpBlock = trueBlock;
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2214 trueBlock = falseBlock;
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2215 falseBlock = tmpBlock;
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2216 probability = 1 - probability;
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2217 }
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2218
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2219 if (isNeverExecutedCode(probability)) {
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2220 append(new FixedGuardNode(condition, UnreachedCode, InvalidateReprofile, true));
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2221 appendGoto(falseBlock);
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2222 return;
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2223 } else if (isNeverExecutedCode(1 - probability)) {
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2224 append(new FixedGuardNode(condition, UnreachedCode, InvalidateReprofile, false));
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2225 appendGoto(trueBlock);
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2226 return;
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2227 }
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2228
19381
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2229 int oldBci = stream.currentBCI();
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2230 int trueBlockInt = checkPositiveIntConstantPushed(trueBlock);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2231 if (trueBlockInt != -1) {
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2232 int falseBlockInt = checkPositiveIntConstantPushed(falseBlock);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2233 if (falseBlockInt != -1) {
19534
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2234 if (tryGenConditionalForIf(trueBlock, falseBlock, condition, oldBci, trueBlockInt, falseBlockInt)) {
19372
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
2235 return;
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
2236 }
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
2237 }
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
2238 }
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
2239
19367
f9ccdf258dd4 Further reduction of begin node creation when inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19366
diff changeset
2240 this.controlFlowSplit = true;
19533
e5465c0c5828 Reuse HIRFrameStateBuilder for false branch of if.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19532
diff changeset
2241 FixedNode trueSuccessor = createTarget(trueBlock, frameState, false, false);
e5465c0c5828 Reuse HIRFrameStateBuilder for false branch of if.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19532
diff changeset
2242 FixedNode falseSuccessor = createTarget(falseBlock, frameState, false, true);
19532
a9aa368f9068 Improve IfNode construction in the graph builder. Start reusing previous frame states in createTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19521
diff changeset
2243 ValueNode ifNode = genIfNode(condition, trueSuccessor, falseSuccessor, probability);
19117
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
2244 append(ifNode);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2245 if (parsingReplacement()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2246 if (x instanceof BranchProbabilityNode) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2247 ((BranchProbabilityNode) x).simplify(null);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2248 } else if (y instanceof BranchProbabilityNode) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2249 ((BranchProbabilityNode) y).simplify(null);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2250 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2251 }
19117
4f30f1e7e1e6 Fold if nodes at parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19116
diff changeset
2252 }
14947
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
2253 }
3825cf50cc5a AbstractBytecodeParser: make ifNode abstract.
Josef Eisl <josef.eisl@jku.at>
parents: 14922
diff changeset
2254
19534
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2255 private boolean tryGenConditionalForIf(BciBlock trueBlock, BciBlock falseBlock, LogicNode condition, int oldBci, int trueBlockInt, int falseBlockInt) {
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2256 if (gotoOrFallThroughAfterConstant(trueBlock) && gotoOrFallThroughAfterConstant(falseBlock) && trueBlock.getSuccessor(0) == falseBlock.getSuccessor(0)) {
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2257 genConditionalForIf(trueBlock, condition, oldBci, trueBlockInt, falseBlockInt, false);
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2258 return true;
19783
Doug Simon <doug.simon@oracle.com>
parents: 19776 19737
diff changeset
2259 } else if (this.parent != null && returnAfterConstant(trueBlock) && returnAfterConstant(falseBlock)) {
19534
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2260 genConditionalForIf(trueBlock, condition, oldBci, trueBlockInt, falseBlockInt, true);
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2261 return true;
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2262 }
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2263 return false;
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2264 }
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2265
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2266 private void genConditionalForIf(BciBlock trueBlock, LogicNode condition, int oldBci, int trueBlockInt, int falseBlockInt, boolean genReturn) {
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2267 ConstantNode trueValue = currentGraph.unique(ConstantNode.forInt(trueBlockInt));
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2268 ConstantNode falseValue = currentGraph.unique(ConstantNode.forInt(falseBlockInt));
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2269 ValueNode conditionalNode = ConditionalNode.create(condition, trueValue, falseValue);
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2270 if (conditionalNode.graph() == null) {
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2271 conditionalNode = currentGraph.addOrUnique(conditionalNode);
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2272 }
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2273 if (genReturn) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2274 Kind returnKind = method.getSignature().getReturnKind().getStackKind();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2275 this.genReturn(conditionalNode, returnKind);
19534
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2276 } else {
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2277 frameState.push(Kind.Int, conditionalNode);
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2278 appendGoto(trueBlock.getSuccessor(0));
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2279 stream.setBCI(oldBci);
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2280 }
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2281 }
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2282
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2283 private LogicNode createLogicNode(Condition cond, ValueNode a, ValueNode b) {
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2284 LogicNode condition;
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2285 assert !a.getKind().isNumericFloat();
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2286 if (cond == Condition.EQ || cond == Condition.NE) {
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2287 if (a.getKind() == Kind.Object) {
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2288 condition = genObjectEquals(a, b);
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2289 } else {
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2290 condition = genIntegerEquals(a, b);
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2291 }
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2292 } else {
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2293 assert a.getKind() != Kind.Object && !cond.isUnsigned();
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2294 condition = genIntegerLessThan(a, b);
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2295 }
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2296 return condition;
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2297 }
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2298
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2299 private void genConstantTargetIf(BciBlock trueBlock, BciBlock falseBlock, boolean negate, LogicNode condition) {
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2300 LogicConstantNode constantLogicNode = (LogicConstantNode) condition;
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2301 boolean value = constantLogicNode.getValue();
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2302 if (negate) {
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2303 value = !value;
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2304 }
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2305 BciBlock nextBlock = falseBlock;
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2306 if (value) {
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2307 nextBlock = trueBlock;
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2308 }
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2309 appendGoto(nextBlock);
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2310 }
50b19dc35c66 Clean up and restructurings in GraphBuilderPhase#genIf.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19533
diff changeset
2311
19372
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
2312 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
2313 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
2314 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
2315 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
2316 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
2317 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
2318 }
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
2319 return -1;
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
2320 }
96f2ae02fa4f Short cut simple int constant materialization diamonds in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19371
diff changeset
2321
19381
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2322 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
2323 stream.setBCI(block.startBci);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2324 int currentBCI = stream.nextBCI();
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2325 stream.setBCI(currentBCI);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2326 int currentBC = stream.currentBC();
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2327 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
2328 }
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2329
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2330 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
2331 stream.setBCI(block.startBci);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2332 int currentBCI = stream.nextBCI();
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2333 stream.setBCI(currentBCI);
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2334 int currentBC = stream.currentBC();
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2335 return currentBC == Bytecodes.IRETURN;
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2336 }
31442a6da26d Avoid diamond shape for methods that return a condition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19380
diff changeset
2337
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2338 public StampProvider getStampProvider() {
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2339 return stampProvider;
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2340 }
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2341
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2342 public MetaAccessProvider getMetaAccess() {
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2343 return metaAccess;
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2344 }
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2345
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2346 public Assumptions getAssumptions() {
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19241
diff changeset
2347 return currentGraph.getAssumptions();
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2348 }
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2349
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2350 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
2351 assert kind == kind.getStackKind();
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2352 frameState.push(kind, value);
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2353 }
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18997
diff changeset
2354
19170
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
2355 private int getCurrentDimension() {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
2356 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
2357 return 0;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
2358 } else {
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
2359 return this.explodeLoopsContext.peek().peelIteration;
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
2360 }
3b2e98f9e47c Initial prototype for loop explosion during graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
2361 }
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19173
diff changeset
2362
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19173
diff changeset
2363 public ConstantReflectionProvider getConstantReflection() {
19179
df3561f7c9ad rename: constantReflectionProvider -> constantReflection
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
2364 return constantReflection;
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19173
diff changeset
2365 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19173
diff changeset
2366
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
2367 public SnippetReflectionProvider getSnippetReflection() {
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
2368 return snippetReflectionProvider;
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
2369 }
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
2370
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2371 /**
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2372 * Gets the graph being processed by this builder.
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2373 */
19496
9525e4d5b385 disable (asserting) type checks in the FrameStateBuilder when parsing a replacement
Doug Simon <doug.simon@oracle.com>
parents: 19485
diff changeset
2374 public StructuredGraph getGraph() {
9525e4d5b385 disable (asserting) type checks in the FrameStateBuilder when parsing a replacement
Doug Simon <doug.simon@oracle.com>
parents: 19485
diff changeset
2375 return currentGraph;
9525e4d5b385 disable (asserting) type checks in the FrameStateBuilder when parsing a replacement
Doug Simon <doug.simon@oracle.com>
parents: 19485
diff changeset
2376 }
9525e4d5b385 disable (asserting) type checks in the FrameStateBuilder when parsing a replacement
Doug Simon <doug.simon@oracle.com>
parents: 19485
diff changeset
2377
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2378 public BytecodeParser getParent() {
19776
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2379 return parent;
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2380 }
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2381
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2382 public int getDepth() {
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2383 return parent == null ? 0 : 1 + parent.getDepth();
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2384 }
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2385
19811
1e27e31aca11 fixed bug in managing replacement scope during bytecode parsing and improved API for querying replacement info from graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19808
diff changeset
2386 public Replacement getReplacement() {
1e27e31aca11 fixed bug in managing replacement scope during bytecode parsing and improved API for querying replacement info from graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19808
diff changeset
2387 return replacementContext;
1e27e31aca11 fixed bug in managing replacement scope during bytecode parsing and improved API for querying replacement info from graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19808
diff changeset
2388 }
1e27e31aca11 fixed bug in managing replacement scope during bytecode parsing and improved API for querying replacement info from graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19808
diff changeset
2389
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2390 public ResolvedJavaMethod getRootMethod() {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2391 return rootMethod;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2392 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2393
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2394 public boolean eagerResolving() {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2395 return graphBuilderConfig.eagerResolving();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2396 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2397
19496
9525e4d5b385 disable (asserting) type checks in the FrameStateBuilder when parsing a replacement
Doug Simon <doug.simon@oracle.com>
parents: 19485
diff changeset
2398 @Override
9525e4d5b385 disable (asserting) type checks in the FrameStateBuilder when parsing a replacement
Doug Simon <doug.simon@oracle.com>
parents: 19485
diff changeset
2399 public String toString() {
19776
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2400 Formatter fmt = new Formatter();
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2401 BytecodeParser bp = this;
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2402 String indent = "";
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2403 while (bp != null) {
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2404 if (bp != this) {
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2405 fmt.format("%n%s", indent);
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2406 }
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19787
diff changeset
2407 fmt.format("%s [bci: %d, replacement: %s]", bp.method.asStackTraceElement(bp.bci()), bci(), bp.parsingReplacement());
19776
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2408 bp = bp.parent;
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2409 indent += " ";
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2410 }
16ad9711b44f always inline intrinsics in the graph builder as well as any methods (recursively) called from an instrinsic
Doug Simon <doug.simon@oracle.com>
parents: 19496
diff changeset
2411 return fmt.toString();
19496
9525e4d5b385 disable (asserting) type checks in the FrameStateBuilder when parsing a replacement
Doug Simon <doug.simon@oracle.com>
parents: 19485
diff changeset
2412 }
19521
9c4168877444 Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19515
diff changeset
2413
9c4168877444 Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19515
diff changeset
2414 public BailoutException bailout(String string) {
19585
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19581
diff changeset
2415 FrameState currentFrameState = createFrameState(bci());
19521
9c4168877444 Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19515
diff changeset
2416 StackTraceElement[] elements = GraphUtil.approxSourceStackTraceElement(currentFrameState);
9c4168877444 Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19515
diff changeset
2417 BailoutException bailout = new BailoutException(string);
9c4168877444 Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19515
diff changeset
2418 throw GraphUtil.createBailoutException(string, bailout, elements);
9c4168877444 Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19515
diff changeset
2419 }
19585
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19581
diff changeset
2420
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19581
diff changeset
2421 private FrameState createFrameState(int bci) {
19854
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
2422 if (currentBlock != null && bci > currentBlock.endBci) {
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
2423 frameState.clearNonLiveLocals(currentBlock, liveness, false);
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
2424 }
19585
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19581
diff changeset
2425 return frameState.create(bci);
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19581
diff changeset
2426 }
19854
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
2427
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
2428 public FrameState createStateAfter() {
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
2429 return createFrameState(stream.nextBCI());
4178f9830a27 Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19853
diff changeset
2430 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2431 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2432 }
19411
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
2433
7d924ac67522 moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents: 19409
diff changeset
2434 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
2435 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
2436 }
19955
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
2437
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
2438 @SuppressWarnings("all")
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
2439 private static boolean assertionsEnabled() {
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
2440 boolean assertionsEnabled = false;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
2441 assert assertionsEnabled = true;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
2442 return assertionsEnabled;
517cbecdc20f factored out assertion checks around application of an InvocationPlugin and added a check that all StateSplit nodes added by a plugin have a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 19886
diff changeset
2443 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2444 }