Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java @ 19846:93b74f0db076
don't treat Truffle method inlining substitutions as graph builder replacements
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 13 Mar 2015 23:27:53 +0100 |
parents | 14e703edb2ab |
children | d4c45ab543c8 |
rev | line source |
---|---|
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
19148
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19147
diff
changeset
|
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.truffle; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
15259
d90e5c22ba55
Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15254
diff
changeset
|
25 import static com.oracle.graal.compiler.common.GraalOptions.*; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 import static com.oracle.graal.truffle.TruffleCompilerOptions.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 import java.util.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.api.code.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.api.meta.*; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14991
diff
changeset
|
32 import com.oracle.graal.api.replacements.*; |
19360
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
33 import com.oracle.graal.compiler.common.*; |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19771
diff
changeset
|
34 import com.oracle.graal.compiler.common.type.*; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.debug.*; |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
36 import com.oracle.graal.debug.Debug.Scope; |
11551
63b4694d3627
split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents:
11496
diff
changeset
|
37 import com.oracle.graal.debug.internal.*; |
18963
892e466d28f3
Allow PartialEvaluator to use a custom SnippetReflectionProvider
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18845
diff
changeset
|
38 import com.oracle.graal.graph.Graph.Mark; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 import com.oracle.graal.graph.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 import com.oracle.graal.graph.Node; |
19107
46544f51cde4
Move some logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19075
diff
changeset
|
41 import com.oracle.graal.java.*; |
19771
7117697d11e1
refactored graph builder plugins into a separate class
Doug Simon <doug.simon@oracle.com>
parents:
19767
diff
changeset
|
42 import com.oracle.graal.java.GraphBuilderConfiguration.Plugins; |
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:
19388
diff
changeset
|
43 import com.oracle.graal.java.GraphBuilderPlugin.LoadFieldPlugin; |
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:
19388
diff
changeset
|
44 import com.oracle.graal.java.GraphBuilderPlugin.ParameterPlugin; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 import com.oracle.graal.loop.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16733
diff
changeset
|
46 import com.oracle.graal.nodes.CallTargetNode.InvokeKind; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 import com.oracle.graal.nodes.*; |
19306
a0a760b0fb5f
pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19253
diff
changeset
|
48 import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; |
19112
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
49 import com.oracle.graal.nodes.calc.*; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 import com.oracle.graal.nodes.java.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 import com.oracle.graal.nodes.spi.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 import com.oracle.graal.nodes.util.*; |
11496
b36028c30a81
Allow escape analysis to ignore object identity correctness for types marked via the CompilerDirectives.ValueType annotation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11437
diff
changeset
|
53 import com.oracle.graal.nodes.virtual.*; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 import com.oracle.graal.phases.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 import com.oracle.graal.phases.common.*; |
15470
c55f44b3c5e5
remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15311
diff
changeset
|
56 import com.oracle.graal.phases.common.inlining.*; |
15964
9d7b2134c4ce
less canonicalization during Truffle partial evaluation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15641
diff
changeset
|
57 import com.oracle.graal.phases.common.inlining.info.*; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 import com.oracle.graal.phases.tiers.*; |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
59 import com.oracle.graal.phases.util.*; |
18204
a1873eefea65
Truffle: refactor TraceTrufflePerformanceWarnings into separate class.
Christian Humer <christian.humer@gmail.com>
parents:
18187
diff
changeset
|
60 import com.oracle.graal.truffle.debug.*; |
17600
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17409
diff
changeset
|
61 import com.oracle.graal.truffle.nodes.*; |
11312
f0c8303cf88e
Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11208
diff
changeset
|
62 import com.oracle.graal.truffle.nodes.asserts.*; |
f0c8303cf88e
Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11208
diff
changeset
|
63 import com.oracle.graal.truffle.nodes.frame.*; |
f0c8303cf88e
Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11208
diff
changeset
|
64 import com.oracle.graal.truffle.nodes.frame.NewFrameNode.VirtualOnlyInstanceNode; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 import com.oracle.graal.truffle.phases.*; |
19177
1a7b33c96c0d
Fixes for TruffleGraphBuilderPluginsProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19170
diff
changeset
|
66 import com.oracle.graal.truffle.substitutions.*; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 import com.oracle.graal.virtual.phases.ea.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 import com.oracle.truffle.api.*; |
19132
8fe322db4b6d
Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19116
diff
changeset
|
69 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 import com.oracle.truffle.api.nodes.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 /** |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 * Class performing the partial evaluation starting from the root node of an AST. |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 */ |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 public class PartialEvaluator { |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
77 private final Providers providers; |
11567
c69df2e602f4
Use CanonicalizerPhase.applyIncremental in InliningPhase.
Roland Schatz <roland.schatz@oracle.com>
parents:
11551
diff
changeset
|
78 private final CanonicalizerPhase canonicalizer; |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18141
diff
changeset
|
79 private Set<JavaConstant> constantReceivers; |
10611
1546866ebb8d
First draft of Truffle graph caching.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10529
diff
changeset
|
80 private final TruffleCache truffleCache; |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
81 private final SnippetReflectionProvider snippetReflection; |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17273
diff
changeset
|
82 private final ResolvedJavaMethod callDirectMethod; |
19108
c4cb2ccd0b96
Move more logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19107
diff
changeset
|
83 private final ResolvedJavaMethod callInlinedMethod; |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17273
diff
changeset
|
84 private final ResolvedJavaMethod callSiteProxyMethod; |
19107
46544f51cde4
Move some logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19075
diff
changeset
|
85 protected final ResolvedJavaMethod callRootMethod; |
46544f51cde4
Move some logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19075
diff
changeset
|
86 private final GraphBuilderConfiguration configForRoot; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 |
19107
46544f51cde4
Move some logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19075
diff
changeset
|
88 public PartialEvaluator(Providers providers, GraphBuilderConfiguration configForRoot, TruffleCache truffleCache, SnippetReflectionProvider snippetReflection) { |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
89 this.providers = providers; |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19629
diff
changeset
|
90 this.canonicalizer = new CanonicalizerPhase(); |
18963
892e466d28f3
Allow PartialEvaluator to use a custom SnippetReflectionProvider
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18845
diff
changeset
|
91 this.snippetReflection = snippetReflection; |
10611
1546866ebb8d
First draft of Truffle graph caching.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10529
diff
changeset
|
92 this.truffleCache = truffleCache; |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17273
diff
changeset
|
93 this.callDirectMethod = providers.getMetaAccess().lookupJavaMethod(OptimizedCallTarget.getCallDirectMethod()); |
19108
c4cb2ccd0b96
Move more logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19107
diff
changeset
|
94 this.callInlinedMethod = providers.getMetaAccess().lookupJavaMethod(OptimizedCallTarget.getCallInlinedMethod()); |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17273
diff
changeset
|
95 this.callSiteProxyMethod = providers.getMetaAccess().lookupJavaMethod(GraalFrameInstance.CallNodeFrame.METHOD); |
19107
46544f51cde4
Move some logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19075
diff
changeset
|
96 this.configForRoot = configForRoot; |
46544f51cde4
Move some logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19075
diff
changeset
|
97 |
46544f51cde4
Move some logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19075
diff
changeset
|
98 try { |
46544f51cde4
Move some logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19075
diff
changeset
|
99 callRootMethod = providers.getMetaAccess().lookupJavaMethod(OptimizedCallTarget.class.getDeclaredMethod("callRoot", Object[].class)); |
46544f51cde4
Move some logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19075
diff
changeset
|
100 } catch (NoSuchMethodException ex) { |
46544f51cde4
Move some logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19075
diff
changeset
|
101 throw new RuntimeException(ex); |
46544f51cde4
Move some logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19075
diff
changeset
|
102 } |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 |
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:
19388
diff
changeset
|
105 public StructuredGraph createGraph(final OptimizedCallTarget callTarget, AllowAssumptions allowAssumptions) { |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
106 if (TraceTruffleCompilationHistogram.getValue() || TraceTruffleCompilationDetails.getValue()) { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
107 constantReceivers = new HashSet<>(); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
108 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
109 |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
110 try (Scope c = Debug.scope("TruffleTree")) { |
13207
9500ac5269ff
add truffle tree dump handler in order to make tree dumping respect the method filter.
Andreas Woess <andreas.woess@jku.at>
parents:
13197
diff
changeset
|
111 Debug.dump(callTarget, "truffle tree"); |
9500ac5269ff
add truffle tree dump handler in order to make tree dumping respect the method filter.
Andreas Woess <andreas.woess@jku.at>
parents:
13197
diff
changeset
|
112 } catch (Throwable e) { |
9500ac5269ff
add truffle tree dump handler in order to make tree dumping respect the method filter.
Andreas Woess <andreas.woess@jku.at>
parents:
13197
diff
changeset
|
113 throw Debug.handle(e); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
114 } |
19109
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
115 |
19306
a0a760b0fb5f
pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19253
diff
changeset
|
116 final StructuredGraph graph = new StructuredGraph(callTarget.toString(), callRootMethod, allowAssumptions); |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14620
diff
changeset
|
117 assert graph != null : "no graph for root method"; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 |
17337
8043c997764d
Truffle: fix dump output for truffle compilations.
Christian Humer <christian.humer@gmail.com>
parents:
17331
diff
changeset
|
119 try (Scope s = Debug.scope("CreateGraph", graph); Indent indent = Debug.logAndIndent("createGraph %s", graph)) { |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 |
19109
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
121 Map<ResolvedJavaMethod, StructuredGraph> graphCache = null; |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
122 if (CacheGraphs.getValue()) { |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
123 graphCache = new HashMap<>(); |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
124 } |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
125 PhaseContext baseContext = new PhaseContext(providers); |
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
126 HighTierContext tierContext = new HighTierContext(providers, graphCache, new PhaseSuite<HighTierContext>(), OptimisticOptimizations.NONE); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 |
19109
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
128 if (TruffleCompilerOptions.FastPE.getValue()) { |
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:
19388
diff
changeset
|
129 fastPartialEvaluation(callTarget, graph, baseContext, tierContext); |
19109
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
130 } else { |
19110
9e07d5219944
Further restructuring in the PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19109
diff
changeset
|
131 createRootGraph(graph); |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
132 partialEvaluation(callTarget, graph, baseContext, tierContext); |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
133 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
134 |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14866
diff
changeset
|
135 if (Thread.currentThread().isInterrupted()) { |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14866
diff
changeset
|
136 return null; |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
137 } |
12592
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12432
diff
changeset
|
138 |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
139 new VerifyFrameDoesNotEscapePhase().apply(graph, false); |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13916
diff
changeset
|
140 if (TraceTruffleCompilationHistogram.getValue() && constantReceivers != null) { |
16545
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
141 createHistogram(); |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
142 } |
19075
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
143 postPartialEvaluation(graph); |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
144 |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
145 } catch (Throwable e) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
146 throw Debug.handle(e); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
147 } |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
149 return graph; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
151 |
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:
19388
diff
changeset
|
152 private class InterceptLoadFieldPlugin implements LoadFieldPlugin { |
19111
0b15114268c8
Draft for LoadFieldPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19110
diff
changeset
|
153 |
0b15114268c8
Draft for LoadFieldPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19110
diff
changeset
|
154 public boolean apply(GraphBuilderContext builder, ValueNode receiver, ResolvedJavaField field) { |
19113
844ee652443f
Canonicalize load fields on constant receivers at partial evaluation parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19112
diff
changeset
|
155 if (receiver.isConstant()) { |
844ee652443f
Canonicalize load fields on constant receivers at partial evaluation parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19112
diff
changeset
|
156 JavaConstant asJavaConstant = receiver.asJavaConstant(); |
19396
7345e1a7069f
added LoadFieldPlugin for Graal
Doug Simon <doug.simon@oracle.com>
parents:
19395
diff
changeset
|
157 return tryConstantFold(builder, providers.getMetaAccess(), providers.getConstantReflection(), field, asJavaConstant); |
19113
844ee652443f
Canonicalize load fields on constant receivers at partial evaluation parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19112
diff
changeset
|
158 } |
19111
0b15114268c8
Draft for LoadFieldPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19110
diff
changeset
|
159 return false; |
0b15114268c8
Draft for LoadFieldPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19110
diff
changeset
|
160 } |
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:
19145
diff
changeset
|
161 |
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:
19145
diff
changeset
|
162 public boolean apply(GraphBuilderContext builder, ResolvedJavaField staticField) { |
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:
19145
diff
changeset
|
163 if (TruffleCompilerOptions.TruffleExcludeAssertions.getValue() && staticField.getName().equals("$assertionsDisabled")) { |
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:
19145
diff
changeset
|
164 ConstantNode trueNode = builder.append(ConstantNode.forBoolean(true)); |
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:
19145
diff
changeset
|
165 builder.push(trueNode.getKind().getStackKind(), trueNode); |
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:
19145
diff
changeset
|
166 return true; |
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:
19145
diff
changeset
|
167 } |
19396
7345e1a7069f
added LoadFieldPlugin for Graal
Doug Simon <doug.simon@oracle.com>
parents:
19395
diff
changeset
|
168 return tryConstantFold(builder, providers.getMetaAccess(), providers.getConstantReflection(), staticField, 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:
19145
diff
changeset
|
169 } |
19113
844ee652443f
Canonicalize load fields on constant receivers at partial evaluation parse time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19112
diff
changeset
|
170 } |
19111
0b15114268c8
Draft for LoadFieldPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19110
diff
changeset
|
171 |
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:
19388
diff
changeset
|
172 private class InterceptReceiverPlugin implements ParameterPlugin { |
19112
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
173 |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
174 private final Object receiver; |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
175 |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
176 public InterceptReceiverPlugin(Object receiver) { |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
177 this.receiver = receiver; |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
178 } |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
179 |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19771
diff
changeset
|
180 public FloatingNode interceptParameter(GraphBuilderContext b, int index, Stamp stamp) { |
19112
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
181 if (index == 0) { |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
182 return ConstantNode.forConstant(snippetReflection.forObject(receiver), providers.getMetaAccess()); |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
183 } |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
184 return null; |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
185 } |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
186 } |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19111
diff
changeset
|
187 |
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:
19388
diff
changeset
|
188 private class InlineInvokePlugin implements GraphBuilderPlugin.InlineInvokePlugin { |
19132
8fe322db4b6d
Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19116
diff
changeset
|
189 |
19375
3d750310932f
Fix inline decisions in fast partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19361
diff
changeset
|
190 private Stack<TruffleInlining> inlining; |
19360
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
191 private OptimizedDirectCallNode lastDirectCallNode; |
19399
7d924ac67522
moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents:
19396
diff
changeset
|
192 private final Replacements replacements; |
19360
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
193 |
19399
7d924ac67522
moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents:
19396
diff
changeset
|
194 public InlineInvokePlugin(TruffleInlining inlining, Replacements replacements) { |
19375
3d750310932f
Fix inline decisions in fast partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19361
diff
changeset
|
195 this.inlining = new Stack<>(); |
3d750310932f
Fix inline decisions in fast partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19361
diff
changeset
|
196 this.inlining.push(inlining); |
19399
7d924ac67522
moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents:
19396
diff
changeset
|
197 this.replacements = replacements; |
19360
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
198 } |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
199 |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19771
diff
changeset
|
200 public InlineInfo getInlineInfo(GraphBuilderContext builder, ResolvedJavaMethod original, ValueNode[] arguments, JavaType returnType) { |
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:
19388
diff
changeset
|
201 if (original.getAnnotation(TruffleBoundary.class) != null) { |
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:
19388
diff
changeset
|
202 return null; |
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:
19388
diff
changeset
|
203 } |
19399
7d924ac67522
moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents:
19396
diff
changeset
|
204 if (replacements != null && (replacements.getMethodSubstitutionMethod(original) != null || replacements.getMacroSubstitution(original) != null)) { |
7d924ac67522
moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents:
19396
diff
changeset
|
205 return null; |
7d924ac67522
moved use of Replacements in GraphBuilderPhase.Instance into InlineInvokePlugins
Doug Simon <doug.simon@oracle.com>
parents:
19396
diff
changeset
|
206 } |
19846
93b74f0db076
don't treat Truffle method inlining substitutions as graph builder replacements
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
207 assert !builder.parsingReplacement(); |
19360
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
208 if (original.equals(callSiteProxyMethod)) { |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
209 ValueNode arg1 = arguments[0]; |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
210 if (!arg1.isConstant()) { |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
211 GraalInternalError.shouldNotReachHere("The direct call node does not resolve to a constant!"); |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
212 } |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
213 |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
214 Object callNode = builder.getSnippetReflection().asObject(Object.class, (JavaConstant) arg1.asConstant()); |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
215 if (callNode instanceof OptimizedDirectCallNode) { |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
216 OptimizedDirectCallNode directCallNode = (OptimizedDirectCallNode) callNode; |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
217 lastDirectCallNode = directCallNode; |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
218 } |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
219 } else if (original.equals(callDirectMethod)) { |
19375
3d750310932f
Fix inline decisions in fast partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19361
diff
changeset
|
220 TruffleInliningDecision decision = getDecision(inlining.peek(), lastDirectCallNode); |
19360
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
221 lastDirectCallNode = null; |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
222 if (decision != null && decision.isInline()) { |
19375
3d750310932f
Fix inline decisions in fast partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19361
diff
changeset
|
223 inlining.push(decision); |
19360
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
224 builder.getAssumptions().record(new AssumptionValidAssumption((OptimizedAssumption) decision.getTarget().getNodeRewritingAssumption())); |
19846
93b74f0db076
don't treat Truffle method inlining substitutions as graph builder replacements
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
225 return new InlineInfo(callInlinedMethod, false, false); |
19360
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
226 } |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
227 } |
19846
93b74f0db076
don't treat Truffle method inlining substitutions as graph builder replacements
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
228 return new InlineInfo(original, false, false); |
19360
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
229 } |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
230 |
19375
3d750310932f
Fix inline decisions in fast partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19361
diff
changeset
|
231 public void postInline(ResolvedJavaMethod inlinedTargetMethod) { |
3d750310932f
Fix inline decisions in fast partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19361
diff
changeset
|
232 if (inlinedTargetMethod.equals(callInlinedMethod)) { |
3d750310932f
Fix inline decisions in fast partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19361
diff
changeset
|
233 inlining.pop(); |
3d750310932f
Fix inline decisions in fast partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19361
diff
changeset
|
234 } |
3d750310932f
Fix inline decisions in fast partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19361
diff
changeset
|
235 } |
19132
8fe322db4b6d
Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19116
diff
changeset
|
236 } |
8fe322db4b6d
Prototype for configuring inlining during parsing via a closure in the GraphBuilderConfiguration object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19116
diff
changeset
|
237 |
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:
19388
diff
changeset
|
238 private class LoopExplosionPlugin implements GraphBuilderPlugin.LoopExplosionPlugin { |
19145
18caaceabfdb
Create prototype for new graph builder plugin for loop explosion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19135
diff
changeset
|
239 |
18caaceabfdb
Create prototype for new graph builder plugin for loop explosion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19135
diff
changeset
|
240 public boolean shouldExplodeLoops(ResolvedJavaMethod method) { |
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:
19145
diff
changeset
|
241 return method.getAnnotation(ExplodeLoop.class) != null; |
19145
18caaceabfdb
Create prototype for new graph builder plugin for loop explosion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19135
diff
changeset
|
242 } |
18caaceabfdb
Create prototype for new graph builder plugin for loop explosion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19135
diff
changeset
|
243 |
19629
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:
19626
diff
changeset
|
244 public boolean shouldMergeExplosions(ResolvedJavaMethod method) { |
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:
19626
diff
changeset
|
245 ExplodeLoop explodeLoop = method.getAnnotation(ExplodeLoop.class); |
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:
19626
diff
changeset
|
246 if (explodeLoop != null) { |
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:
19626
diff
changeset
|
247 return explodeLoop.merge(); |
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:
19626
diff
changeset
|
248 } |
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:
19626
diff
changeset
|
249 return false; |
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:
19626
diff
changeset
|
250 } |
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:
19626
diff
changeset
|
251 |
19145
18caaceabfdb
Create prototype for new graph builder plugin for loop explosion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19135
diff
changeset
|
252 } |
18caaceabfdb
Create prototype for new graph builder plugin for loop explosion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19135
diff
changeset
|
253 |
19109
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
254 @SuppressWarnings("unused") |
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:
19388
diff
changeset
|
255 private void fastPartialEvaluation(OptimizedCallTarget callTarget, StructuredGraph graph, PhaseContext baseContext, HighTierContext tierContext) { |
19111
0b15114268c8
Draft for LoadFieldPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19110
diff
changeset
|
256 GraphBuilderConfiguration newConfig = configForRoot.copy(); |
19443
5be35dd0a9dd
Disable use of profiling information during partial evaluation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19440
diff
changeset
|
257 newConfig.setUseProfiling(false); |
19771
7117697d11e1
refactored graph builder plugins into a separate class
Doug Simon <doug.simon@oracle.com>
parents:
19767
diff
changeset
|
258 Plugins plugins = newConfig.getPlugins(); |
7117697d11e1
refactored graph builder plugins into a separate class
Doug Simon <doug.simon@oracle.com>
parents:
19767
diff
changeset
|
259 plugins.setLoadFieldPlugin(new InterceptLoadFieldPlugin()); |
7117697d11e1
refactored graph builder plugins into a separate class
Doug Simon <doug.simon@oracle.com>
parents:
19767
diff
changeset
|
260 plugins.setParameterPlugin(new InterceptReceiverPlugin(callTarget)); |
19360
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
261 callTarget.setInlining(new TruffleInlining(callTarget, new DefaultInliningPolicy())); |
19771
7117697d11e1
refactored graph builder plugins into a separate class
Doug Simon <doug.simon@oracle.com>
parents:
19767
diff
changeset
|
262 plugins.setInlineInvokePlugin(new InlineInvokePlugin(callTarget.getInlining(), providers.getReplacements())); |
7117697d11e1
refactored graph builder plugins into a separate class
Doug Simon <doug.simon@oracle.com>
parents:
19767
diff
changeset
|
263 plugins.setLoopExplosionPlugin(new LoopExplosionPlugin()); |
7117697d11e1
refactored graph builder plugins into a separate class
Doug Simon <doug.simon@oracle.com>
parents:
19767
diff
changeset
|
264 TruffleGraphBuilderPlugins.registerInvocationPlugins(providers.getMetaAccess(), newConfig.getPlugins().getInvocationPlugins()); |
19505
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:
19477
diff
changeset
|
265 new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), this.snippetReflection, providers.getConstantReflection(), newConfig, |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19771
diff
changeset
|
266 TruffleCompilerImpl.Optimizations, null).apply(graph); |
19110
9e07d5219944
Further restructuring in the PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19109
diff
changeset
|
267 Debug.dump(graph, "After FastPE"); |
19148
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19147
diff
changeset
|
268 |
19551
c99fb69e93c7
Perform deoptimize to guard conversion for fast partial evaluation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19477
diff
changeset
|
269 // Perform deoptimize to guard conversion. |
c99fb69e93c7
Perform deoptimize to guard conversion for fast partial evaluation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19477
diff
changeset
|
270 new ConvertDeoptimizeToGuardPhase().apply(graph, tierContext); |
c99fb69e93c7
Perform deoptimize to guard conversion for fast partial evaluation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19477
diff
changeset
|
271 |
19410
61d3cb8e1280
Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19392
diff
changeset
|
272 for (MethodCallTargetNode methodCallTargetNode : graph.getNodes(MethodCallTargetNode.TYPE)) { |
19388
aadf2fd0a4a2
Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19382
diff
changeset
|
273 Class<? extends FixedWithNextNode> macroSubstitution = providers.getReplacements().getMacroSubstitution(methodCallTargetNode.targetMethod()); |
aadf2fd0a4a2
Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19382
diff
changeset
|
274 if (macroSubstitution != null) { |
aadf2fd0a4a2
Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19382
diff
changeset
|
275 InliningUtil.inlineMacroNode(methodCallTargetNode.invoke(), methodCallTargetNode.targetMethod(), macroSubstitution); |
19392
c46d8322ef98
Truffle: also apply method substitutions after FastPE
Andreas Woess <andreas.woess@oracle.com>
parents:
19390
diff
changeset
|
276 } else { |
c46d8322ef98
Truffle: also apply method substitutions after FastPE
Andreas Woess <andreas.woess@oracle.com>
parents:
19390
diff
changeset
|
277 StructuredGraph inlineGraph = providers.getReplacements().getMethodSubstitution(methodCallTargetNode.targetMethod()); |
c46d8322ef98
Truffle: also apply method substitutions after FastPE
Andreas Woess <andreas.woess@oracle.com>
parents:
19390
diff
changeset
|
278 if (inlineGraph != null) { |
c46d8322ef98
Truffle: also apply method substitutions after FastPE
Andreas Woess <andreas.woess@oracle.com>
parents:
19390
diff
changeset
|
279 InliningUtil.inline(methodCallTargetNode.invoke(), inlineGraph, true, null); |
c46d8322ef98
Truffle: also apply method substitutions after FastPE
Andreas Woess <andreas.woess@oracle.com>
parents:
19390
diff
changeset
|
280 } |
19388
aadf2fd0a4a2
Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19382
diff
changeset
|
281 } |
aadf2fd0a4a2
Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19382
diff
changeset
|
282 } |
aadf2fd0a4a2
Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19382
diff
changeset
|
283 |
19747
0493ae8a552d
Modification of phase order for fast partial evaluation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
284 // Perform conditional elimination. |
0493ae8a552d
Modification of phase order for fast partial evaluation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
285 new DominatorConditionalEliminationPhase(false).apply(graph); |
0493ae8a552d
Modification of phase order for fast partial evaluation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
286 |
0493ae8a552d
Modification of phase order for fast partial evaluation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
287 canonicalizer.apply(graph, tierContext); |
19477
1cbf4661e1e9
Fix phase applications in partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19445
diff
changeset
|
288 |
19148
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19147
diff
changeset
|
289 // Do single partial escape and canonicalization pass. |
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19147
diff
changeset
|
290 try (Scope pe = Debug.scope("TrufflePartialEscape", graph)) { |
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19147
diff
changeset
|
291 new PartialEscapePhase(true, canonicalizer).apply(graph, tierContext); |
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19147
diff
changeset
|
292 } catch (Throwable t) { |
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19147
diff
changeset
|
293 Debug.handle(t); |
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19147
diff
changeset
|
294 } |
19109
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
295 } |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
296 |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
297 private void partialEvaluation(final OptimizedCallTarget callTarget, final StructuredGraph graph, PhaseContext baseContext, HighTierContext tierContext) { |
19109
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
298 injectConstantCallTarget(graph, callTarget, baseContext); |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
299 |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
300 Debug.dump(graph, "Before expansion"); |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
301 |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
302 TruffleExpansionLogger expansionLogger = null; |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
303 if (TraceTruffleExpansion.getValue()) { |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
304 expansionLogger = new TruffleExpansionLogger(providers, graph); |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
305 } |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
306 |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
307 expandTree(graph, expansionLogger); |
19109
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
308 |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
309 TruffleInliningCache inliningCache = null; |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
310 if (TruffleFunctionInlining.getValue()) { |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
311 callTarget.setInlining(new TruffleInlining(callTarget, new DefaultInliningPolicy())); |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
312 if (TruffleFunctionInliningCache.getValue()) { |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
313 inliningCache = new TruffleInliningCache(); |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
314 } |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
315 } |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
316 |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
317 expandDirectCalls(graph, expansionLogger, callTarget.getInlining(), inliningCache); |
19109
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
318 |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
319 if (Thread.currentThread().isInterrupted()) { |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
320 return; |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
321 } |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
322 |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
323 canonicalizer.apply(graph, baseContext); |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
324 // EA frame and clean up. |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
325 do { |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
326 try (Scope pe = Debug.scope("TrufflePartialEscape", graph)) { |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
327 new PartialEscapePhase(true, canonicalizer).apply(graph, tierContext); |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
328 new IncrementalCanonicalizerPhase<>(canonicalizer, new ConditionalEliminationPhase()).apply(graph, tierContext); |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
329 } catch (Throwable t) { |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
330 Debug.handle(t); |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
331 } |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
332 } while (expandTree(graph, expansionLogger)); |
19109
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
333 |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
334 if (expansionLogger != null) { |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
335 expansionLogger.print(callTarget); |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
336 } |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
337 } |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
338 |
61c772f6d8eb
More restructuring in PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19108
diff
changeset
|
339 public StructuredGraph createRootGraph(StructuredGraph graph) { |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19771
diff
changeset
|
340 new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), providers.getConstantReflection(), configForRoot, TruffleCompilerImpl.Optimizations, null).apply(graph); |
19107
46544f51cde4
Move some logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19075
diff
changeset
|
341 return graph; |
46544f51cde4
Move some logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19075
diff
changeset
|
342 } |
46544f51cde4
Move some logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19075
diff
changeset
|
343 |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
344 public StructuredGraph createInlineGraph(String name, StructuredGraph caller) { |
19306
a0a760b0fb5f
pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19253
diff
changeset
|
345 StructuredGraph graph = new StructuredGraph(name, callInlinedMethod, AllowAssumptions.from(caller.getAssumptions() != null)); |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19771
diff
changeset
|
346 new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), providers.getConstantReflection(), configForRoot, TruffleCompilerImpl.Optimizations, null).apply(graph); |
19108
c4cb2ccd0b96
Move more logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19107
diff
changeset
|
347 return graph; |
c4cb2ccd0b96
Move more logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19107
diff
changeset
|
348 } |
c4cb2ccd0b96
Move more logic from TruffleCache to PartialEvaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19107
diff
changeset
|
349 |
19075
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
350 private static void postPartialEvaluation(final StructuredGraph graph) { |
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
351 NeverPartOfCompilationNode.verifyNotFoundIn(graph); |
19410
61d3cb8e1280
Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19392
diff
changeset
|
352 for (MaterializeFrameNode materializeNode : graph.getNodes(MaterializeFrameNode.TYPE).snapshot()) { |
19075
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
353 materializeNode.replaceAtUsages(materializeNode.getFrame()); |
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
354 graph.removeFixed(materializeNode); |
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
355 } |
19410
61d3cb8e1280
Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19392
diff
changeset
|
356 for (VirtualObjectNode virtualObjectNode : graph.getNodes(VirtualObjectNode.TYPE)) { |
19075
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
357 if (virtualObjectNode instanceof VirtualOnlyInstanceNode) { |
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
358 VirtualOnlyInstanceNode virtualOnlyInstanceNode = (VirtualOnlyInstanceNode) virtualObjectNode; |
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
359 virtualOnlyInstanceNode.setAllowMaterialization(true); |
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
360 } else if (virtualObjectNode instanceof VirtualInstanceNode) { |
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
361 VirtualInstanceNode virtualInstanceNode = (VirtualInstanceNode) virtualObjectNode; |
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
362 ResolvedJavaType type = virtualInstanceNode.type(); |
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
363 if (type.getAnnotation(CompilerDirectives.ValueType.class) != null) { |
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
364 virtualInstanceNode.setIdentity(false); |
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
365 } |
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
366 } |
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
367 } |
19626
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:
19551
diff
changeset
|
368 |
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:
19551
diff
changeset
|
369 if (!TruffleCompilerOptions.TruffleInlineAcrossTruffleBoundary.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:
19551
diff
changeset
|
370 // Do not inline across Truffle boundaries. |
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:
19551
diff
changeset
|
371 for (MethodCallTargetNode mct : graph.getNodes(MethodCallTargetNode.TYPE)) { |
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:
19551
diff
changeset
|
372 mct.invoke().setUseForInlining(false); |
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:
19551
diff
changeset
|
373 } |
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:
19551
diff
changeset
|
374 } |
19075
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
375 } |
336adcd0070b
Clean ups in partial evaluator. New development-only option FastPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18963
diff
changeset
|
376 |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
377 private void injectConstantCallTarget(final StructuredGraph graph, final OptimizedCallTarget constantCallTarget, PhaseContext baseContext) { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
378 ParameterNode thisNode = graph.getParameter(0); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
379 |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
380 /* |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
381 * Converting the call target to a Constant using the SnippetReflectionProvider is a |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
382 * workaround, we should think about a better solution. Since object constants are |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
383 * VM-specific, only the hosting VM knows how to do the conversion. |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
384 */ |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
385 thisNode.replaceAndDelete(ConstantNode.forConstant(snippetReflection.forObject(constantCallTarget), providers.getMetaAccess(), graph)); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
386 |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
387 canonicalizer.apply(graph, baseContext); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
388 |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
389 new IncrementalCanonicalizerPhase<>(canonicalizer, new ReplaceIntrinsicsPhase(providers.getReplacements())).apply(graph, baseContext); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
390 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
391 |
16545
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
392 private void createHistogram() { |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
393 DebugHistogram histogram = Debug.createHistogram("Expanded Truffle Nodes"); |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18141
diff
changeset
|
394 for (JavaConstant c : constantReceivers) { |
16545
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
395 String javaName = providers.getMetaAccess().lookupJavaType(c).toJavaName(false); |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
396 |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
397 // The DSL uses nested classes with redundant names - only show the inner class |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
398 int index = javaName.indexOf('$'); |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
399 if (index != -1) { |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
400 javaName = javaName.substring(index + 1); |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
401 } |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
402 |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
403 histogram.add(javaName); |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
404 |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
405 } |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
406 new DebugHistogramAsciiPrinter(TTY.out().out()).print(histogram); |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
407 } |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
408 |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
409 private boolean expandTree(StructuredGraph graph, TruffleExpansionLogger expansionLogger) { |
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
410 PhaseContext phaseContext = new PhaseContext(providers); |
17038
3b3e768a2b92
Truffle: run expandTree iteratively to make frame propagations visible to expandTree.
Christian Humer <christian.humer@gmail.com>
parents:
16841
diff
changeset
|
411 boolean changed = false; |
3b3e768a2b92
Truffle: run expandTree iteratively to make frame propagations visible to expandTree.
Christian Humer <christian.humer@gmail.com>
parents:
16841
diff
changeset
|
412 boolean changedInIteration; |
18678
e04d70a4d3ae
prefer profile methods during partial evaluation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18583
diff
changeset
|
413 ArrayDeque<MethodCallTargetNode> queue = new ArrayDeque<>(); |
e04d70a4d3ae
prefer profile methods during partial evaluation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18583
diff
changeset
|
414 MetaAccessProvider metaAccess = providers.getMetaAccess(); |
e04d70a4d3ae
prefer profile methods during partial evaluation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18583
diff
changeset
|
415 ResolvedJavaType profileClass = metaAccess.lookupJavaType(NodeCloneable.class); |
10528
5fb4a450b7a7
PartialEvaluator: iterative version of expandTree
Andreas Woess <andreas.woess@jku.at>
parents:
10487
diff
changeset
|
416 do { |
17038
3b3e768a2b92
Truffle: run expandTree iteratively to make frame propagations visible to expandTree.
Christian Humer <christian.humer@gmail.com>
parents:
16841
diff
changeset
|
417 changedInIteration = false; |
18716
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
418 |
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
419 Mark mark = null; |
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
420 while (true) { |
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
421 |
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
422 for (MethodCallTargetNode methodCallTargetNode : graph.getNewNodes(mark).filter(MethodCallTargetNode.class)) { |
18822
fad37aaed6d2
Add utilities isDirect and isIndirect to InvokeKind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18716
diff
changeset
|
423 if (methodCallTargetNode.invokeKind().isDirect()) { |
18716
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
424 ValueNode receiver = methodCallTargetNode.receiver(); |
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
425 if (receiver != null && receiver.isConstant() && profileClass.isAssignableFrom(receiver.stamp().javaType(metaAccess))) { |
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
426 queue.addFirst(methodCallTargetNode); |
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
427 } else { |
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
428 queue.addLast(methodCallTargetNode); |
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
429 } |
18678
e04d70a4d3ae
prefer profile methods during partial evaluation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18583
diff
changeset
|
430 } |
e04d70a4d3ae
prefer profile methods during partial evaluation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18583
diff
changeset
|
431 } |
18716
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
432 mark = graph.getMark(); |
18678
e04d70a4d3ae
prefer profile methods during partial evaluation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18583
diff
changeset
|
433 |
18716
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
434 if (queue.isEmpty()) { |
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
435 break; |
d1826470d1ec
continuously update method queue in PartialEvaluator.expandTree
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18678
diff
changeset
|
436 } |
18678
e04d70a4d3ae
prefer profile methods during partial evaluation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18583
diff
changeset
|
437 MethodCallTargetNode methodCallTargetNode = queue.removeFirst(); |
e04d70a4d3ae
prefer profile methods during partial evaluation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18583
diff
changeset
|
438 if (!methodCallTargetNode.isAlive()) { |
e04d70a4d3ae
prefer profile methods during partial evaluation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18583
diff
changeset
|
439 continue; |
e04d70a4d3ae
prefer profile methods during partial evaluation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18583
diff
changeset
|
440 } |
e04d70a4d3ae
prefer profile methods during partial evaluation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18583
diff
changeset
|
441 InvokeKind kind = methodCallTargetNode.invokeKind(); |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14620
diff
changeset
|
442 try (Indent id1 = Debug.logAndIndent("try inlining %s, kind = %s", methodCallTargetNode.targetMethod(), kind)) { |
18822
fad37aaed6d2
Add utilities isDirect and isIndirect to InvokeKind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18716
diff
changeset
|
443 if (kind.isDirect()) { |
15072
7b3175685d19
PartialEvaluator: fix compilation tracing
Andreas Woess <andreas.woess@jku.at>
parents:
15018
diff
changeset
|
444 if ((TraceTruffleCompilationHistogram.getValue() || TraceTruffleCompilationDetails.getValue()) && kind == InvokeKind.Special && methodCallTargetNode.receiver().isConstant()) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18141
diff
changeset
|
445 constantReceivers.add(methodCallTargetNode.receiver().asJavaConstant()); |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14620
diff
changeset
|
446 } |
15072
7b3175685d19
PartialEvaluator: fix compilation tracing
Andreas Woess <andreas.woess@jku.at>
parents:
15018
diff
changeset
|
447 |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14620
diff
changeset
|
448 Replacements replacements = providers.getReplacements(); |
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14620
diff
changeset
|
449 Class<? extends FixedWithNextNode> macroSubstitution = replacements.getMacroSubstitution(methodCallTargetNode.targetMethod()); |
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14620
diff
changeset
|
450 if (macroSubstitution != null) { |
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14620
diff
changeset
|
451 InliningUtil.inlineMacroNode(methodCallTargetNode.invoke(), methodCallTargetNode.targetMethod(), macroSubstitution); |
17038
3b3e768a2b92
Truffle: run expandTree iteratively to make frame propagations visible to expandTree.
Christian Humer <christian.humer@gmail.com>
parents:
16841
diff
changeset
|
452 changed = changedInIteration = true; |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14620
diff
changeset
|
453 continue; |
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14620
diff
changeset
|
454 } |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
455 StructuredGraph inlineGraph = replacements.getMethodSubstitution(methodCallTargetNode.targetMethod()); |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14620
diff
changeset
|
456 |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17273
diff
changeset
|
457 ResolvedJavaMethod targetMethod = methodCallTargetNode.targetMethod(); |
18834
21de06b3f429
Respect canBeInlined in Truffle partial evaluation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18829
diff
changeset
|
458 if (inlineGraph == null && targetMethod.hasBytecodes() && targetMethod.canBeInlined()) { |
18141
e47d597a0652
TruffleCache: remove unused assumption argument.
Bernhard Urban <bernhard.urban@jku.at>
parents:
17600
diff
changeset
|
459 inlineGraph = parseGraph(methodCallTargetNode.targetMethod(), methodCallTargetNode.arguments(), phaseContext); |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14620
diff
changeset
|
460 } |
11680
524d0a0a47b8
New algorithm for Truffle tree expansion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11646
diff
changeset
|
461 |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14620
diff
changeset
|
462 if (inlineGraph != null) { |
17038
3b3e768a2b92
Truffle: run expandTree iteratively to make frame propagations visible to expandTree.
Christian Humer <christian.humer@gmail.com>
parents:
16841
diff
changeset
|
463 expandTreeInline(graph, phaseContext, expansionLogger, methodCallTargetNode, inlineGraph); |
3b3e768a2b92
Truffle: run expandTree iteratively to make frame propagations visible to expandTree.
Christian Humer <christian.humer@gmail.com>
parents:
16841
diff
changeset
|
464 changed = changedInIteration = true; |
13203
401e1473c546
Truffle: Implemented basic tracing of truffle compiler tree expansion (-G:+TraceTruffleExpansion, -G:+TraceTruffleExpansionSource)
Christian Humer <christian.humer@gmail.com>
parents:
13197
diff
changeset
|
465 } |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
466 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
467 } |
10677
3bbe14e492fb
Introduce TruffleGraphMaxNodes option with default value 10000.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10676
diff
changeset
|
468 |
3bbe14e492fb
Introduce TruffleGraphMaxNodes option with default value 10000.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10676
diff
changeset
|
469 if (graph.getNodeCount() > TruffleCompilerOptions.TruffleGraphMaxNodes.getValue()) { |
17341
e3f3233ec6cd
refactor BailoutException to include information about non-permanent errors
Lukas Stadler <lukas.stadler@oracle.com>
parents:
17337
diff
changeset
|
470 throw new BailoutException("Truffle compilation is exceeding maximum node count: %d", graph.getNodeCount()); |
10677
3bbe14e492fb
Introduce TruffleGraphMaxNodes option with default value 10000.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10676
diff
changeset
|
471 } |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
472 } |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
473 |
17038
3b3e768a2b92
Truffle: run expandTree iteratively to make frame propagations visible to expandTree.
Christian Humer <christian.humer@gmail.com>
parents:
16841
diff
changeset
|
474 } while (changedInIteration); |
13203
401e1473c546
Truffle: Implemented basic tracing of truffle compiler tree expansion (-G:+TraceTruffleExpansion, -G:+TraceTruffleExpansionSource)
Christian Humer <christian.humer@gmail.com>
parents:
13197
diff
changeset
|
475 |
17038
3b3e768a2b92
Truffle: run expandTree iteratively to make frame propagations visible to expandTree.
Christian Humer <christian.humer@gmail.com>
parents:
16841
diff
changeset
|
476 return changed; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
477 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
478 |
17038
3b3e768a2b92
Truffle: run expandTree iteratively to make frame propagations visible to expandTree.
Christian Humer <christian.humer@gmail.com>
parents:
16841
diff
changeset
|
479 private void expandTreeInline(StructuredGraph graph, PhaseContext phaseContext, TruffleExpansionLogger expansionLogger, MethodCallTargetNode methodCallTargetNode, StructuredGraph inlineGraph) { |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
480 try (Indent indent = Debug.logAndIndent("expand graph %s", methodCallTargetNode.targetMethod())) { |
16545
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
481 int nodeCountBefore = graph.getNodeCount(); |
17402
ce7058005115
Truffle: fix TraceTruffleExpansion for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
482 if (expansionLogger != null) { |
16545
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
483 expansionLogger.preExpand(methodCallTargetNode, inlineGraph); |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
484 } |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
485 List<Node> canonicalizedNodes = methodCallTargetNode.invoke().asNode().usages().snapshot(); |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
486 |
16545
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
487 Map<Node, Node> inlined = InliningUtil.inline(methodCallTargetNode.invoke(), inlineGraph, false, canonicalizedNodes); |
17402
ce7058005115
Truffle: fix TraceTruffleExpansion for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
488 if (expansionLogger != null) { |
16545
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
489 expansionLogger.postExpand(inlined); |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
490 } |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
491 if (Debug.isDumpEnabled()) { |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
492 int nodeCountAfter = graph.getNodeCount(); |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
493 Debug.dump(graph, "After expand %s %+d (%d)", methodCallTargetNode.targetMethod().toString(), nodeCountAfter - nodeCountBefore, nodeCountAfter); |
16545
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
494 } |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
495 AbstractInlineInfo.getInlinedParameterUsages(canonicalizedNodes, inlineGraph, inlined); |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
496 canonicalizer.applyIncremental(graph, phaseContext, canonicalizedNodes); |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
497 } |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
498 } |
c667378e4699
extract methods in PartialEvaluator
Christian Wirth <christian.wirth@oracle.com>
parents:
16494
diff
changeset
|
499 |
18141
e47d597a0652
TruffleCache: remove unused assumption argument.
Bernhard Urban <bernhard.urban@jku.at>
parents:
17600
diff
changeset
|
500 private StructuredGraph parseGraph(final ResolvedJavaMethod targetMethod, final NodeInputList<ValueNode> arguments, final PhaseContext phaseContext) { |
e47d597a0652
TruffleCache: remove unused assumption argument.
Bernhard Urban <bernhard.urban@jku.at>
parents:
17600
diff
changeset
|
501 StructuredGraph graph = truffleCache.lookup(targetMethod, arguments, canonicalizer); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
502 |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14620
diff
changeset
|
503 if (graph != null && targetMethod.getAnnotation(ExplodeLoop.class) != null) { |
14612
3c8de2692867
TruffleCompiler: print hint if hitting the assertion
Bernhard Urban <bernhard.urban@jku.at>
parents:
14172
diff
changeset
|
504 assert graph.hasLoops() : graph + " does not contain a loop"; |
11680
524d0a0a47b8
New algorithm for Truffle tree expansion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11646
diff
changeset
|
505 final StructuredGraph graphCopy = graph.copy(); |
524d0a0a47b8
New algorithm for Truffle tree expansion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11646
diff
changeset
|
506 final List<Node> modifiedNodes = new ArrayList<>(); |
19410
61d3cb8e1280
Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19392
diff
changeset
|
507 for (ParameterNode param : graphCopy.getNodes(ParameterNode.TYPE).snapshot()) { |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13597
diff
changeset
|
508 ValueNode arg = arguments.get(param.index()); |
11680
524d0a0a47b8
New algorithm for Truffle tree expansion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11646
diff
changeset
|
509 if (arg.isConstant()) { |
18487
0f4813e0b4a9
Use asConstant() instead of asJavaConstant() where possible.
Roland Schatz <roland.schatz@oracle.com>
parents:
18473
diff
changeset
|
510 Constant constant = arg.asConstant(); |
17342
a690ca62772c
add array length information in PartialEvaluator before expanding @ExplodeLoop
Lukas Stadler <lukas.stadler@oracle.com>
parents:
17341
diff
changeset
|
511 param.usages().snapshotTo(modifiedNodes); |
18487
0f4813e0b4a9
Use asConstant() instead of asJavaConstant() where possible.
Roland Schatz <roland.schatz@oracle.com>
parents:
18473
diff
changeset
|
512 param.replaceAndDelete(ConstantNode.forConstant(arg.stamp(), constant, phaseContext.getMetaAccess(), graphCopy)); |
17342
a690ca62772c
add array length information in PartialEvaluator before expanding @ExplodeLoop
Lukas Stadler <lukas.stadler@oracle.com>
parents:
17341
diff
changeset
|
513 } else { |
a690ca62772c
add array length information in PartialEvaluator before expanding @ExplodeLoop
Lukas Stadler <lukas.stadler@oracle.com>
parents:
17341
diff
changeset
|
514 ValueNode length = GraphUtil.arrayLength(arg); |
a690ca62772c
add array length information in PartialEvaluator before expanding @ExplodeLoop
Lukas Stadler <lukas.stadler@oracle.com>
parents:
17341
diff
changeset
|
515 if (length != null && length.isConstant()) { |
a690ca62772c
add array length information in PartialEvaluator before expanding @ExplodeLoop
Lukas Stadler <lukas.stadler@oracle.com>
parents:
17341
diff
changeset
|
516 param.usages().snapshotTo(modifiedNodes); |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18834
diff
changeset
|
517 ParameterNode newParam = graphCopy.addWithoutUnique(new ParameterNode(param.index(), param.stamp())); |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18834
diff
changeset
|
518 param.replaceAndDelete(graphCopy.addWithoutUnique(new PiArrayNode(newParam, ConstantNode.forInt(length.asJavaConstant().asInt(), graphCopy), param.stamp()))); |
11680
524d0a0a47b8
New algorithm for Truffle tree expansion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11646
diff
changeset
|
519 } |
524d0a0a47b8
New algorithm for Truffle tree expansion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11646
diff
changeset
|
520 } |
524d0a0a47b8
New algorithm for Truffle tree expansion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11646
diff
changeset
|
521 } |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
522 try (Scope s = Debug.scope("TruffleUnrollLoop", targetMethod)) { |
11680
524d0a0a47b8
New algorithm for Truffle tree expansion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11646
diff
changeset
|
523 |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
524 canonicalizer.applyIncremental(graphCopy, phaseContext, modifiedNodes); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
525 boolean unrolled; |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
526 do { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
527 unrolled = false; |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
528 LoopsData loopsData = new LoopsData(graphCopy); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
529 loopsData.detectedCountedLoops(); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
530 for (LoopEx ex : innerLoopsFirst(loopsData.countedLoops())) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
531 if (ex.counted().isConstantMaxTripCount()) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
532 long constant = ex.counted().constantMaxTripCount(); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
533 LoopTransformations.fullUnroll(ex, phaseContext, canonicalizer); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
534 Debug.dump(graphCopy, "After loop unrolling %d times", constant); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
535 unrolled = true; |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
536 break; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
537 } |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
538 } |
16194
7fb828b4c32b
made LoopsData clients clean up dead nodes created during loop analysis
Doug Simon <doug.simon@oracle.com>
parents:
16191
diff
changeset
|
539 loopsData.deleteUnusedNodes(); |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
540 } while (unrolled); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
541 } catch (Throwable e) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
542 throw Debug.handle(e); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
543 } |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
544 |
11680
524d0a0a47b8
New algorithm for Truffle tree expansion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11646
diff
changeset
|
545 return graphCopy; |
524d0a0a47b8
New algorithm for Truffle tree expansion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11646
diff
changeset
|
546 } else { |
524d0a0a47b8
New algorithm for Truffle tree expansion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11646
diff
changeset
|
547 return graph; |
524d0a0a47b8
New algorithm for Truffle tree expansion.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11646
diff
changeset
|
548 } |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
549 } |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
550 |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
551 private void expandDirectCalls(StructuredGraph graph, TruffleExpansionLogger expansionLogger, TruffleInlining inlining, TruffleInliningCache inliningCache) { |
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
552 PhaseContext phaseContext = new PhaseContext(providers); |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
553 |
19410
61d3cb8e1280
Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19392
diff
changeset
|
554 for (MethodCallTargetNode methodCallTargetNode : graph.getNodes(MethodCallTargetNode.TYPE).snapshot()) { |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
555 StructuredGraph inlineGraph = parseDirectCallGraph(phaseContext, graph, inlining, inliningCache, methodCallTargetNode); |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
556 |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
557 if (inlineGraph != null) { |
17402
ce7058005115
Truffle: fix TraceTruffleExpansion for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
558 expandTreeInline(graph, phaseContext, expansionLogger, methodCallTargetNode, inlineGraph); |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
559 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
560 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
561 // non inlined direct calls need to be expanded until TruffleCallBoundary. |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
562 expandTree(graph, expansionLogger); |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
563 assert noDirectCallsLeft(graph); |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
564 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
565 |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
566 private boolean noDirectCallsLeft(StructuredGraph graph) { |
19410
61d3cb8e1280
Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19392
diff
changeset
|
567 for (MethodCallTargetNode methodCallTargetNode : graph.getNodes(MethodCallTargetNode.TYPE).snapshot()) { |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
568 if (methodCallTargetNode.targetMethod().equals(callDirectMethod)) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
569 return false; |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
570 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
571 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
572 return true; |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
573 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
574 |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
575 private StructuredGraph parseDirectCallGraph(PhaseContext phaseContext, StructuredGraph caller, TruffleInlining inlining, TruffleInliningCache inliningCache, |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
576 MethodCallTargetNode methodCallTargetNode) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
577 OptimizedDirectCallNode callNode = resolveConstantCallNode(methodCallTargetNode); |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
578 if (callNode == null) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
579 return null; |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
580 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
581 |
19360
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
582 TruffleInliningDecision decision = getDecision(inlining, callNode); |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
583 |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
584 StructuredGraph graph; |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
585 if (decision != null && decision.isInline()) { |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
586 if (inliningCache == null) { |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
587 graph = createInlineGraph(phaseContext, caller, null, decision); |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
588 } else { |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
589 graph = inliningCache.getCachedGraph(phaseContext, caller, decision); |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
590 } |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
591 caller.getAssumptions().record(new AssumptionValidAssumption((OptimizedAssumption) decision.getTarget().getNodeRewritingAssumption())); |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
592 } else { |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
593 // we continue expansion of callDirect until we reach the callBoundary. |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
594 graph = parseGraph(methodCallTargetNode.targetMethod(), methodCallTargetNode.arguments(), phaseContext); |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
595 } |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
596 |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
597 return graph; |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
598 } |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
599 |
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
600 private static TruffleInliningDecision getDecision(TruffleInlining inlining, OptimizedDirectCallNode callNode) { |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
601 TruffleInliningDecision decision = inlining.findByCall(callNode); |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
602 if (decision == null) { |
17407
c4cdee8566a4
Truffle: rename PrintTrufflePerformanceWarnings to TraceTrufflePerformanceWarnings.
Christian Humer <christian.humer@gmail.com>
parents:
17402
diff
changeset
|
603 if (TruffleCompilerOptions.TraceTrufflePerformanceWarnings.getValue()) { |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
604 Map<String, Object> properties = new LinkedHashMap<>(); |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
605 properties.put("callNode", callNode); |
18204
a1873eefea65
Truffle: refactor TraceTrufflePerformanceWarnings into separate class.
Christian Humer <christian.humer@gmail.com>
parents:
18187
diff
changeset
|
606 TracePerformanceWarningsListener.logPerformanceWarning("A direct call within the Truffle AST is not reachable anymore. Call node could not be inlined.", properties); |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
607 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
608 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
609 |
17409
4c0dcd164718
Truffle: fix potential null dereference error in partial evaluator.
Christian Humer <christian.humer@gmail.com>
parents:
17407
diff
changeset
|
610 if (decision != null && decision.getTarget() != decision.getProfile().getCallNode().getCurrentCallTarget()) { |
17407
c4cdee8566a4
Truffle: rename PrintTrufflePerformanceWarnings to TraceTrufflePerformanceWarnings.
Christian Humer <christian.humer@gmail.com>
parents:
17402
diff
changeset
|
611 if (TruffleCompilerOptions.TraceTrufflePerformanceWarnings.getValue()) { |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
612 Map<String, Object> properties = new LinkedHashMap<>(); |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
613 properties.put("originalTarget", decision.getTarget()); |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
614 properties.put("callNode", callNode); |
18204
a1873eefea65
Truffle: refactor TraceTrufflePerformanceWarnings into separate class.
Christian Humer <christian.humer@gmail.com>
parents:
18187
diff
changeset
|
615 TracePerformanceWarningsListener.logPerformanceWarning(String.format("CallTarget changed during compilation. Call node could not be inlined."), properties); |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
616 } |
19360
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
617 return null; |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
618 } |
19360
dc59d2800470
Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
619 return decision; |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
620 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
621 |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
622 private OptimizedDirectCallNode resolveConstantCallNode(MethodCallTargetNode methodCallTargetNode) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
623 if (!methodCallTargetNode.targetMethod().equals(callDirectMethod)) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
624 return null; |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
625 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
626 |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
627 Invoke invoke = methodCallTargetNode.invoke(); |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
628 if (invoke == null) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
629 return null; |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
630 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
631 |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
632 FrameState directCallState = invoke.stateAfter(); |
18583
12bd2b344b08
replace usages of == with .equals()
Doug Simon <doug.simon@oracle.com>
parents:
18548
diff
changeset
|
633 while (directCallState != null && !directCallState.method().equals(callSiteProxyMethod)) { |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
634 directCallState = directCallState.outerFrameState(); |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
635 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
636 |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
637 if (directCallState == null) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
638 // not a direct call. May be indirect call. |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
639 return null; |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
640 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
641 |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
642 if (directCallState.values().isEmpty()) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
643 throw new AssertionError(String.format("Frame state of method '%s' is invalid.", callDirectMethod.toString())); |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
644 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
645 |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
646 ValueNode node = directCallState.values().get(0); |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
647 if (!node.isConstant()) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
648 throw new AssertionError(String.format("Method argument for method '%s' is not constant.", callDirectMethod.toString())); |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
649 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
650 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18141
diff
changeset
|
651 JavaConstant constantCallNode = node.asJavaConstant(); |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18487
diff
changeset
|
652 Object value = snippetReflection.asObject(Object.class, constantCallNode); |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
653 |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
654 if (!(value instanceof OptimizedDirectCallNode)) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
655 // might be an indirect call. |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
656 return null; |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
657 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
658 |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
659 return (OptimizedDirectCallNode) value; |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
660 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
661 |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
662 private StructuredGraph createInlineGraph(PhaseContext phaseContext, StructuredGraph caller, TruffleInliningCache cache, TruffleInliningDecision decision) { |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
663 try (Scope s = Debug.scope("GuestLanguageInlinedGraph", new DebugDumpScope(decision.getTarget().toString()))) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
664 OptimizedCallTarget target = decision.getTarget(); |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
665 StructuredGraph inlineGraph = createInlineGraph(target.toString(), caller); |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
666 injectConstantCallTarget(inlineGraph, decision.getTarget(), phaseContext); |
17402
ce7058005115
Truffle: fix TraceTruffleExpansion for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
667 TruffleExpansionLogger expansionLogger = null; |
ce7058005115
Truffle: fix TraceTruffleExpansion for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
668 if (TraceTruffleExpansion.getValue()) { |
ce7058005115
Truffle: fix TraceTruffleExpansion for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
669 expansionLogger = new TruffleExpansionLogger(providers, inlineGraph); |
ce7058005115
Truffle: fix TraceTruffleExpansion for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
670 } |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
671 expandTree(inlineGraph, expansionLogger); |
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
672 expandDirectCalls(inlineGraph, expansionLogger, decision, cache); |
17402
ce7058005115
Truffle: fix TraceTruffleExpansion for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
673 |
ce7058005115
Truffle: fix TraceTruffleExpansion for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
674 if (expansionLogger != null) { |
ce7058005115
Truffle: fix TraceTruffleExpansion for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
675 expansionLogger.print(target); |
ce7058005115
Truffle: fix TraceTruffleExpansion for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
676 } |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
677 return inlineGraph; |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
678 } catch (Throwable e) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
679 throw Debug.handle(e); |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
680 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
681 } |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
682 |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
683 private static List<LoopEx> innerLoopsFirst(Collection<LoopEx> loops) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
684 ArrayList<LoopEx> sortedLoops = new ArrayList<>(loops); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
685 Collections.sort(sortedLoops, new Comparator<LoopEx>() { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
686 |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
687 @Override |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
688 public int compare(LoopEx o1, LoopEx o2) { |
16191
3e3578bc8f9b
rename: lirLoop* -> loop*
Doug Simon <doug.simon@oracle.com>
parents:
15964
diff
changeset
|
689 return o2.loop().getDepth() - o1.loop().getDepth(); |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
690 } |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
691 }); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
692 return sortedLoops; |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
693 } |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
694 |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
695 private final class TruffleInliningCache { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
696 |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
697 private final Map<CacheKey, StructuredGraph> cache; |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
698 |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
699 public TruffleInliningCache() { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
700 this.cache = new HashMap<>(); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
701 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
702 |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
703 public StructuredGraph getCachedGraph(PhaseContext phaseContext, StructuredGraph caller, TruffleInliningDecision decision) { |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
704 CacheKey cacheKey = new CacheKey(decision); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
705 StructuredGraph inlineGraph = cache.get(cacheKey); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
706 if (inlineGraph == null) { |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19245
diff
changeset
|
707 inlineGraph = createInlineGraph(phaseContext, caller, this, decision); |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
708 cache.put(cacheKey, inlineGraph); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
709 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
710 return inlineGraph; |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
711 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
712 |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
713 private final class CacheKey { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
714 |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
715 public final TruffleInliningDecision decision; |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
716 |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17342
diff
changeset
|
717 public CacheKey(TruffleInliningDecision decision) { |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
718 this.decision = decision; |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
719 /* |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
720 * If decision.isInline() is not true CacheKey#hashCode does not match |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
721 * CacheKey#equals |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
722 */ |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
723 assert decision.isInline(); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
724 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
725 |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
726 @Override |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
727 public int hashCode() { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
728 return decision.getTarget().hashCode(); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
729 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
730 |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
731 @Override |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
732 public boolean equals(Object obj) { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
733 if (!(obj instanceof CacheKey)) { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
734 return false; |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
735 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
736 CacheKey other = (CacheKey) obj; |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
737 return decision.isSameAs(other.decision); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
738 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
739 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
740 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17203
diff
changeset
|
741 |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
742 } |