Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java @ 18798:f1e7e4f6d833
Truffle: improve invalidation messages for assumptions.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Wed, 07 Jan 2015 18:02:00 +0100 |
parents | e3c95cbbb50c |
children | f70ce1a4472f |
rev | line source |
---|---|
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
17422
89f801a9b4d4
Truffle: fix headers.
Christian Humer <christian.humer@gmail.com>
parents:
17420
diff
changeset
|
2 * Copyright (c) 2013, 2014, 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 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 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
|
26 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 import java.io.*; |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
28 import java.lang.reflect.*; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 import java.util.*; |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
30 import java.util.concurrent.atomic.*; |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
31 import java.util.stream.*; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.api.code.*; |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
34 import com.oracle.graal.compiler.common.*; |
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.*; |
18204
a1873eefea65
Truffle: refactor TraceTrufflePerformanceWarnings into separate class.
Christian Humer <christian.humer@gmail.com>
parents:
18200
diff
changeset
|
36 import com.oracle.graal.truffle.debug.*; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.truffle.api.*; |
15216
d59f48be0ed6
Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15215
diff
changeset
|
38 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 import com.oracle.truffle.api.frame.*; |
18386
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
40 import com.oracle.truffle.api.impl.*; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 import com.oracle.truffle.api.nodes.*; |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
42 import com.oracle.truffle.api.nodes.Node; |
17600
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
43 import com.oracle.truffle.api.utilities.*; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 /** |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 * Call target that is optimized by Graal upon surpassing a specific invocation threshold. |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 */ |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
48 public class OptimizedCallTarget extends InstalledCode implements RootCallTarget, LoopCountReceiver, ReplaceObserver { |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
50 protected static final PrintStream OUT = TTY.out().out(); |
12709
d2d0c44662bb
Truffle: refactored CompilationProfile to separate the profile and the policy in separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
12708
diff
changeset
|
51 |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
52 protected final GraalTruffleRuntime runtime; |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
53 private SpeculationLog speculationLog; |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
54 protected final CompilationProfile compilationProfile; |
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
55 protected final CompilationPolicy compilationPolicy; |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
56 private final OptimizedCallTarget sourceCallTarget; |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
57 private final AtomicInteger callSitesKnown = new AtomicInteger(0); |
18276
1f3ab088d958
Truffle: implemented defer compilation.
Christian Humer <christian.humer@gmail.com>
parents:
18275
diff
changeset
|
58 |
15231
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
59 @CompilationFinal private Class<?>[] profiledArgumentTypes; |
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
60 @CompilationFinal private Assumption profiledArgumentTypesAssumption; |
15216
d59f48be0ed6
Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15215
diff
changeset
|
61 @CompilationFinal private Class<?> profiledReturnType; |
d59f48be0ed6
Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15215
diff
changeset
|
62 @CompilationFinal private Assumption profiledReturnTypeAssumption; |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
63 |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
64 private final RootNode uninitializedRootNode; |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
65 private final RootNode rootNode; |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
66 |
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:
17191
diff
changeset
|
67 /* Experimental fields for new splitting. */ |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
68 private final Map<TruffleStamp, OptimizedCallTarget> splitVersions = new HashMap<>(); |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
69 private TruffleStamp argumentStamp = DefaultTruffleStamp.getInstance(); |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
70 |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
71 private TruffleInlining inlining; |
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:
17191
diff
changeset
|
72 |
17600
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
73 /** |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
74 * When this call target is inlined, the inlining {@link InstalledCode} registers this |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
75 * assumption. It gets invalidated when a node rewriting is performed. This ensures that all |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
76 * compiled methods that have this call target inlined are properly invalidated. |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
77 */ |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
78 private final CyclicAssumption nodeRewritingAssumption; |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
79 |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
80 public final RootNode getRootNode() { |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
81 return rootNode; |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
82 } |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
83 |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
84 public OptimizedCallTarget(OptimizedCallTarget sourceCallTarget, RootNode rootNode, GraalTruffleRuntime runtime, CompilationPolicy compilationPolicy, SpeculationLog speculationLog) { |
16401
347915b8cea8
Move name from HotSpotNmethod to InstalledCode to have a name again for truffle nmethods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16044
diff
changeset
|
85 super(rootNode.toString()); |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
86 this.sourceCallTarget = sourceCallTarget; |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
87 this.runtime = runtime; |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
88 this.speculationLog = speculationLog; |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
89 this.rootNode = rootNode; |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
90 this.compilationPolicy = compilationPolicy; |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
91 this.rootNode.adoptChildren(); |
18485
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
92 this.rootNode.applyInstrumentation(); |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
93 this.rootNode.setCallTarget(this); |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
94 this.uninitializedRootNode = sourceCallTarget == null ? cloneRootNode(rootNode) : sourceCallTarget.uninitializedRootNode; |
10844
3cf5f371dc9f
Truffle: print inlined call target and rename profiling option.
Andreas Woess <andreas.woess@jku.at>
parents:
10797
diff
changeset
|
95 if (TruffleCallTargetProfiling.getValue()) { |
17420
e98150919577
Truffle: cleanup compilation profile fields.
Christian Humer <christian.humer@gmail.com>
parents:
17404
diff
changeset
|
96 this.compilationProfile = new TraceCompilationProfile(); |
17404
b725292b8a11
Truffle: updated TruffleCallTargetProfiling
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
97 } else { |
17420
e98150919577
Truffle: cleanup compilation profile fields.
Christian Humer <christian.humer@gmail.com>
parents:
17404
diff
changeset
|
98 this.compilationProfile = new CompilationProfile(); |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
99 } |
17600
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
100 this.nodeRewritingAssumption = new CyclicAssumption("nodeRewritingAssumption of " + rootNode.toString()); |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
101 } |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
102 |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
103 private static RootNode cloneRootNode(RootNode root) { |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
104 if (root == null || !root.isCloningAllowed()) { |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
105 return null; |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
106 } |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
107 return NodeUtil.cloneNode(root); |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
108 } |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
109 |
17600
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
110 public Assumption getNodeRewritingAssumption() { |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
111 return nodeRewritingAssumption.getAssumption(); |
13984
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
112 } |
13703
03b42f0fb635
Truffle: extend inlining interface with custom reprofile counters.
Christian Humer <christian.humer@gmail.com>
parents:
13208
diff
changeset
|
113 |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
114 public final void mergeArgumentStamp(TruffleStamp p) { |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
115 this.argumentStamp = this.argumentStamp.join(p); |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
116 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
117 |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
118 public final TruffleStamp getArgumentStamp() { |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
119 return argumentStamp; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
120 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
121 |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
122 private int cloneIndex; |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
123 |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
124 public int getCloneIndex() { |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
125 return cloneIndex; |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
126 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
127 |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
128 public OptimizedCallTarget cloneUninitialized() { |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
129 RootNode copiedRoot = cloneRootNode(uninitializedRootNode); |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
130 if (copiedRoot == null) { |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
131 return null; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
132 } |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
133 OptimizedCallTarget splitTarget = (OptimizedCallTarget) runtime.createClonedCallTarget(this, copiedRoot); |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
134 splitTarget.cloneIndex = cloneIndex++; |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
135 return splitTarget; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
136 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
137 |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
138 public Map<TruffleStamp, OptimizedCallTarget> getSplitVersions() { |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
139 return splitVersions; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
140 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
141 |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
142 public SpeculationLog getSpeculationLog() { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
143 return speculationLog; |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
144 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
145 |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
146 @Override |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
147 public Object call(Object... args) { |
17404
b725292b8a11
Truffle: updated TruffleCallTargetProfiling
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
148 compilationProfile.reportIndirectCall(); |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
149 if (profiledArgumentTypesAssumption != null && profiledArgumentTypesAssumption.isValid()) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
150 CompilerDirectives.transferToInterpreterAndInvalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
151 profiledArgumentTypesAssumption.invalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
152 profiledArgumentTypes = null; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
153 } |
17191
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
154 return doInvoke(args); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
155 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
156 |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
157 public final Object callDirect(Object... args) { |
17404
b725292b8a11
Truffle: updated TruffleCallTargetProfiling
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
158 compilationProfile.reportDirectCall(); |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
159 profileArguments(args); |
17191
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
160 Object result = doInvoke(args); |
15224
735147ef0176
Truffle: Move direct call logic from call site to optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15222
diff
changeset
|
161 Class<?> klass = profiledReturnType; |
15231
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
162 if (klass != null && CompilerDirectives.inCompiledCode() && profiledReturnTypeAssumption.isValid()) { |
15224
735147ef0176
Truffle: Move direct call logic from call site to optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15222
diff
changeset
|
163 result = CompilerDirectives.unsafeCast(result, klass, true, true); |
735147ef0176
Truffle: Move direct call logic from call site to optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15222
diff
changeset
|
164 } |
735147ef0176
Truffle: Move direct call logic from call site to optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15222
diff
changeset
|
165 return result; |
735147ef0176
Truffle: Move direct call logic from call site to optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15222
diff
changeset
|
166 } |
735147ef0176
Truffle: Move direct call logic from call site to optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15222
diff
changeset
|
167 |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
168 public final Object callInlined(Object... arguments) { |
17404
b725292b8a11
Truffle: updated TruffleCallTargetProfiling
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
169 compilationProfile.reportInlinedCall(); |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
170 VirtualFrame frame = createFrame(getRootNode().getFrameDescriptor(), arguments); |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
171 return callProxy(frame); |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
172 } |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
173 |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
174 @ExplodeLoop |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
175 private void profileArguments(Object[] args) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
176 if (profiledArgumentTypesAssumption == null) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
177 CompilerDirectives.transferToInterpreterAndInvalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
178 initializeProfiledArgumentTypes(args); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
179 } else if (profiledArgumentTypes != null) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
180 if (profiledArgumentTypes.length != args.length) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
181 CompilerDirectives.transferToInterpreterAndInvalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
182 profiledArgumentTypesAssumption.invalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
183 profiledArgumentTypes = null; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
184 } else if (TruffleArgumentTypeSpeculation.getValue() && profiledArgumentTypesAssumption.isValid()) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
185 for (int i = 0; i < profiledArgumentTypes.length; i++) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
186 if (profiledArgumentTypes[i] != null && !profiledArgumentTypes[i].isInstance(args[i])) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
187 CompilerDirectives.transferToInterpreterAndInvalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
188 updateProfiledArgumentTypes(args); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
189 break; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
190 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
191 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
192 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
193 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
194 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
195 |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
196 private void initializeProfiledArgumentTypes(Object[] args) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
197 CompilerAsserts.neverPartOfCompilation(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
198 profiledArgumentTypesAssumption = Truffle.getRuntime().createAssumption("Profiled Argument Types"); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
199 profiledArgumentTypes = new Class<?>[args.length]; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
200 if (TruffleArgumentTypeSpeculation.getValue()) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
201 for (int i = 0; i < args.length; i++) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
202 profiledArgumentTypes[i] = classOf(args[i]); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
203 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
204 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
205 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
206 |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
207 private void updateProfiledArgumentTypes(Object[] args) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
208 CompilerAsserts.neverPartOfCompilation(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
209 profiledArgumentTypesAssumption.invalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
210 for (int j = 0; j < profiledArgumentTypes.length; j++) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
211 profiledArgumentTypes[j] = joinTypes(profiledArgumentTypes[j], classOf(args[j])); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
212 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
213 profiledArgumentTypesAssumption = Truffle.getRuntime().createAssumption("Profiled Argument Types"); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
214 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
215 |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
216 private static Class<?> classOf(Object arg) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
217 return arg != null ? arg.getClass() : null; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
218 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
219 |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
220 private static Class<?> joinTypes(Class<?> class1, Class<?> class2) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
221 if (class1 == class2) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
222 return class1; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
223 } else if (class1 == null || class2 == null) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
224 return null; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
225 } else if (class1.isAssignableFrom(class2)) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
226 return class1; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
227 } else if (class2.isAssignableFrom(class1)) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
228 return class2; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
229 } else { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
230 return Object.class; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
231 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
232 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
233 |
17191
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
234 protected Object doInvoke(Object[] args) { |
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
235 return callBoundary(args); |
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
236 } |
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
237 |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
238 @TruffleCallBoundary |
17191
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
239 protected final Object callBoundary(Object[] args) { |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
240 if (CompilerDirectives.inInterpreter()) { |
15215
ca250afc78ec
Simplification of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15212
diff
changeset
|
241 // We are called and we are still in Truffle interpreter mode. |
ca250afc78ec
Simplification of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15212
diff
changeset
|
242 interpreterCall(); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
243 } else { |
18276
1f3ab088d958
Truffle: implemented defer compilation.
Christian Humer <christian.humer@gmail.com>
parents:
18275
diff
changeset
|
244 // We come here from compiled code |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
245 } |
15216
d59f48be0ed6
Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15215
diff
changeset
|
246 |
17427
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
247 return callRoot(args); |
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
248 } |
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
249 |
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
250 public final Object callRoot(Object[] originalArguments) { |
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
251 Object[] args = originalArguments; |
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:
17191
diff
changeset
|
252 if (this.profiledArgumentTypesAssumption != null && CompilerDirectives.inCompiledCode() && profiledArgumentTypesAssumption.isValid()) { |
17427
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
253 args = CompilerDirectives.unsafeCast(castArrayFixedLength(args, profiledArgumentTypes.length), Object[].class, true, true); |
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:
17191
diff
changeset
|
254 if (TruffleArgumentTypeSpeculation.getValue()) { |
17427
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
255 args = castArguments(args); |
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:
17191
diff
changeset
|
256 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
257 } |
17427
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
258 |
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
259 VirtualFrame frame = createFrame(getRootNode().getFrameDescriptor(), args); |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
260 Object result = callProxy(frame); |
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:
17191
diff
changeset
|
261 |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
262 // Profile call return type |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
263 if (profiledReturnTypeAssumption == null) { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
264 if (TruffleReturnTypeSpeculation.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:
17191
diff
changeset
|
265 CompilerDirectives.transferToInterpreterAndInvalidate(); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
266 profiledReturnType = (result == null ? null : result.getClass()); |
17427
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
267 profiledReturnTypeAssumption = Truffle.getRuntime().createAssumption("Profiled Return Type"); |
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:
17191
diff
changeset
|
268 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
269 } else if (profiledReturnType != null) { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
270 if (result == null || profiledReturnType != result.getClass()) { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
271 CompilerDirectives.transferToInterpreterAndInvalidate(); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
272 profiledReturnType = null; |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
273 profiledReturnTypeAssumption.invalidate(); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
274 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
275 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
276 |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
277 return result; |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
278 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
279 |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
280 @Override |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
281 public void invalidate() { |
18199
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
282 invalidate(null, null); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
283 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
284 |
18798
f1e7e4f6d833
Truffle: improve invalidation messages for assumptions.
Christian Humer <christian.humer@gmail.com>
parents:
18485
diff
changeset
|
285 protected void invalidate(Object source, CharSequence reason) { |
18210
84e270aa1f47
Truffle: fixed invalidations were printed multiple times.
Christian Humer <christian.humer@gmail.com>
parents:
18206
diff
changeset
|
286 if (isValid()) { |
84e270aa1f47
Truffle: fixed invalidations were printed multiple times.
Christian Humer <christian.humer@gmail.com>
parents:
18206
diff
changeset
|
287 this.runtime.invalidateInstalledCode(this, source, reason); |
84e270aa1f47
Truffle: fixed invalidations were printed multiple times.
Christian Humer <christian.humer@gmail.com>
parents:
18206
diff
changeset
|
288 } |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
289 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
290 |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
291 public TruffleInlining getInlining() { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
292 return inlining; |
16044
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
293 } |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
294 |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
295 public void setInlining(TruffleInlining inliningDecision) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
296 this.inlining = inliningDecision; |
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:
17191
diff
changeset
|
297 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
298 |
18200
62de94d5cf73
Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
18199
diff
changeset
|
299 private boolean cancelInstalledTask(Node source, CharSequence reason) { |
62de94d5cf73
Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
18199
diff
changeset
|
300 return this.runtime.cancelInstalledTask(this, source, reason); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
301 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
302 |
15215
ca250afc78ec
Simplification of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15212
diff
changeset
|
303 private void interpreterCall() { |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
304 CompilerAsserts.neverPartOfCompilation(); |
18386
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
305 if (isValid()) { |
15222
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
306 // Stubs were deoptimized => reinstall. |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
307 this.runtime.reinstallStubs(); |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
308 } else { |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
309 compilationProfile.reportInterpreterCall(); |
18386
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
310 if (compilationPolicy.shouldCompile(compilationProfile, getCompilerOptions())) { |
15222
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
311 compile(); |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
312 } |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
313 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
314 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
315 |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
316 public void compile() { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
317 if (!runtime.isCompiling(this)) { |
17423
5c8660c0e760
Truffle: TruffleCompilationExceptionsAreThrown implies synchronous compilation.
Chris Seaton <chris.seaton@oracle.com>
parents:
17404
diff
changeset
|
318 runtime.compile(this, TruffleBackgroundCompilation.getValue() && !TruffleCompilationExceptionsAreThrown.getValue()); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
319 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
320 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
321 |
18198
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
322 public void notifyCompilationFailed(Throwable t) { |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
323 if (!(t instanceof BailoutException) || ((BailoutException) t).isPermanent()) { |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
324 compilationPolicy.recordCompilationFailure(t); |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
325 if (TruffleCompilationExceptionsAreThrown.getValue()) { |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
326 throw new OptimizationFailedException(t, this); |
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:
17191
diff
changeset
|
327 } |
18198
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
328 } |
17152
d48738c27e7d
Truffle: restore "opt fail" message on compilation failure
Andreas Woess <andreas.woess@jku.at>
parents:
17079
diff
changeset
|
329 |
18198
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
330 if (t instanceof BailoutException) { |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
331 // Bailout => move on. |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
332 } else if (TruffleCompilationExceptionsAreFatal.getValue()) { |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
333 t.printStackTrace(OUT); |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
334 System.exit(-1); |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
335 } |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
336 } |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
337 |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
338 public void notifyCompilationFinished() { |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
339 // Compilation was successful. |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
340 if (inlining != null) { |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
341 dequeueInlinedCallSites(inlining); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
342 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
343 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
344 |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
345 private void dequeueInlinedCallSites(TruffleInlining parentDecision) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
346 for (TruffleInliningDecision decision : parentDecision) { |
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:
17191
diff
changeset
|
347 if (decision.isInline()) { |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
348 OptimizedCallTarget target = decision.getTarget(); |
18200
62de94d5cf73
Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
18199
diff
changeset
|
349 target.cancelInstalledTask(decision.getProfile().getCallNode(), "Inlining caller compiled."); |
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:
17191
diff
changeset
|
350 dequeueInlinedCallSites(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:
17191
diff
changeset
|
351 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
352 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
353 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
354 |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
355 protected final Object callProxy(VirtualFrame frame) { |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
356 try { |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
357 return getRootNode().execute(frame); |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
358 } finally { |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
359 // this assertion is needed to keep the values from being cleared as non-live locals |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
360 assert frame != null && this != null; |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
361 } |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
362 } |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
363 |
14984
a5bebb69dc78
Truffle: instead of redirecting the call method. inlining is now performed by ignoring @SlowPath.
Christian Humer <christian.humer@gmail.com>
parents:
14983
diff
changeset
|
364 public final int getKnownCallSiteCount() { |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
365 return callSitesKnown.get(); |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
366 } |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
367 |
15089
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
368 public final void incrementKnownCallSites() { |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
369 callSitesKnown.incrementAndGet(); |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
370 } |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
371 |
15089
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
372 public final void decrementKnownCallSites() { |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
373 callSitesKnown.decrementAndGet(); |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
374 } |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
375 |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
376 public final OptimizedCallTarget getSourceCallTarget() { |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
377 return sourceCallTarget; |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
378 } |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
379 |
13984
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
380 @Override |
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
381 public String toString() { |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
382 String superString = rootNode.toString(); |
15168
78530cbd8940
Truffle: Make OptimizedCallTarget itself an InstalledCode object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15167
diff
changeset
|
383 if (isValid()) { |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
384 superString += " <opt>"; |
13984
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
385 } |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
386 if (sourceCallTarget != null) { |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
387 superString += " <split-" + cloneIndex + "-" + argumentStamp.toStringShort() + ">"; |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
388 } |
13984
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
389 return superString; |
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
390 } |
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
391 |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
392 public CompilationProfile getCompilationProfile() { |
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
393 return compilationProfile; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
394 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
395 |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
396 @ExplodeLoop |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
397 private Object[] castArguments(Object[] originalArguments) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
398 Object[] castArguments = new Object[profiledArgumentTypes.length]; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
399 for (int i = 0; i < profiledArgumentTypes.length; i++) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
400 castArguments[i] = profiledArgumentTypes[i] != null ? CompilerDirectives.unsafeCast(originalArguments[i], profiledArgumentTypes[i], true, true) : originalArguments[i]; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
401 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
402 return castArguments; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
403 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
404 |
15231
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
405 private static Object castArrayFixedLength(Object[] args, @SuppressWarnings("unused") int length) { |
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
406 return args; |
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
407 } |
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
408 |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14984
diff
changeset
|
409 public static FrameWithoutBoxing createFrame(FrameDescriptor descriptor, Object[] args) { |
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14984
diff
changeset
|
410 return new FrameWithoutBoxing(descriptor, args); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
411 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
412 |
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:
17191
diff
changeset
|
413 public List<OptimizedDirectCallNode> getCallNodes() { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
414 return NodeUtil.findAllNodeInstances(getRootNode(), OptimizedDirectCallNode.class); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
415 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
416 |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
417 @Override |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
418 public void reportLoopCount(int count) { |
12709
d2d0c44662bb
Truffle: refactored CompilationProfile to separate the profile and the policy in separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
12708
diff
changeset
|
419 compilationProfile.reportLoopCount(count); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
420 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
421 |
10862
8c570011b86f
Truffle: when a node is replaced, notify optimized call target and delay compilation.
Andreas Woess <andreas.woess@jku.at>
parents:
10858
diff
changeset
|
422 @Override |
14584
6189c1983cd3
Truffle: make Node#replace accept any CharSequence as reason
Andreas Woess <andreas.woess@jku.at>
parents:
14569
diff
changeset
|
423 public void nodeReplaced(Node oldNode, Node newNode, CharSequence reason) { |
18275
ab4284c5b5b0
Truffle: minor cleanup
Christian Humer <christian.humer@gmail.com>
parents:
18210
diff
changeset
|
424 CompilerAsserts.neverPartOfCompilation(); |
18199
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
425 if (isValid()) { |
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
426 invalidate(newNode, reason); |
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
427 } |
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
428 /* Notify compiled method that have inlined this call target that the tree changed. */ |
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
429 nodeRewritingAssumption.invalidate(); |
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
430 |
12709
d2d0c44662bb
Truffle: refactored CompilationProfile to separate the profile and the policy in separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
12708
diff
changeset
|
431 compilationProfile.reportNodeReplaced(); |
18200
62de94d5cf73
Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
18199
diff
changeset
|
432 if (cancelInstalledTask(newNode, reason)) { |
18199
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
433 compilationProfile.reportInvalidated(); |
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
434 } |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
435 } |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
436 |
17399
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
437 public void accept(NodeVisitor visitor, boolean includeInlinedNodes) { |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
438 TruffleInlining inliner = getInlining(); |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
439 if (includeInlinedNodes && inliner != null) { |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
440 inlining.accept(this, visitor); |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
441 } else { |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
442 getRootNode().accept(visitor); |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
443 } |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
444 } |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
445 |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
446 public Stream<Node> nodeStream(boolean includeInlinedNodes) { |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
447 Iterator<Node> iterator; |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
448 TruffleInlining inliner = getInlining(); |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
449 if (includeInlinedNodes && inliner != null) { |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
450 iterator = inliner.makeNodeIterator(this); |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
451 } else { |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
452 iterator = NodeUtil.makeRecursiveIterator(this.getRootNode()); |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
453 } |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
454 return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, 0), false); |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
455 } |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
456 |
18206
35639ec046d7
Truffle: extract methods from OptimizedCallUtils and remove it.
Christian Humer <christian.humer@gmail.com>
parents:
18204
diff
changeset
|
457 public int countNonTrivialNodes(final boolean inlined) { |
35639ec046d7
Truffle: extract methods from OptimizedCallUtils and remove it.
Christian Humer <christian.humer@gmail.com>
parents:
18204
diff
changeset
|
458 return (int) nodeStream(inlined).filter(e -> e != null && !e.getCost().isTrivial()).count(); |
35639ec046d7
Truffle: extract methods from OptimizedCallUtils and remove it.
Christian Humer <christian.humer@gmail.com>
parents:
18204
diff
changeset
|
459 } |
35639ec046d7
Truffle: extract methods from OptimizedCallUtils and remove it.
Christian Humer <christian.humer@gmail.com>
parents:
18204
diff
changeset
|
460 |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
461 public Map<String, Object> getDebugProperties() { |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
462 Map<String, Object> properties = new LinkedHashMap<>(); |
18204
a1873eefea65
Truffle: refactor TraceTrufflePerformanceWarnings into separate class.
Christian Humer <christian.humer@gmail.com>
parents:
18200
diff
changeset
|
463 AbstractDebugCompilationListener.addASTSizeProperty(this, properties); |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
464 properties.putAll(getCompilationProfile().getDebugProperties()); |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
465 return properties; |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
466 } |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
467 |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
468 public static Method getCallDirectMethod() { |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
469 try { |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
470 return OptimizedCallTarget.class.getDeclaredMethod("callDirect", Object[].class); |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
471 } catch (NoSuchMethodException | SecurityException e) { |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
472 throw new GraalInternalError(e); |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
473 } |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
474 } |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
475 |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
476 public static Method getCallInlinedMethod() { |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
477 try { |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
478 return OptimizedCallTarget.class.getDeclaredMethod("callInlined", Object[].class); |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
479 } catch (NoSuchMethodException | SecurityException e) { |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
480 throw new GraalInternalError(e); |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
481 } |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
482 } |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
483 |
18386
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
484 private CompilerOptions getCompilerOptions() { |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
485 final ExecutionContext context = rootNode.getExecutionContext(); |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
486 |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
487 if (context == null) { |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
488 return DefaultCompilerOptions.INSTANCE; |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
489 } |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
490 |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
491 return context.getCompilerOptions(); |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
492 } |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
493 |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
494 } |