Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java @ 17256:88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 29 Sep 2014 18:46:38 +0200 |
parents | be733832464d |
children | 4bea75e99249 |
rev | line source |
---|---|
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
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 |
15090
07e7aae05983
Truffle: context sensitive inlining cleanup
Christian Humer <christian.humer@gmail.com>
parents:
15089
diff
changeset
|
25 import static com.oracle.graal.truffle.OptimizedCallTargetLog.*; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 import static com.oracle.graal.truffle.TruffleCompilerOptions.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 import java.io.*; |
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.*; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.api.code.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.debug.*; |
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
|
34 import com.oracle.graal.truffle.ContextSensitiveInlining.InliningDecision; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 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
|
36 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
|
37 import com.oracle.truffle.api.frame.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.truffle.api.nodes.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 /** |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 * 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
|
42 */ |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
43 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
|
44 |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
45 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
|
46 |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
47 protected final GraalTruffleRuntime runtime; |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
48 private SpeculationLog speculationLog; |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
49 protected int callCount; |
15089
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
50 protected boolean inliningPerformed; |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
51 protected final CompilationProfile compilationProfile; |
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
52 protected final CompilationPolicy compilationPolicy; |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
53 private OptimizedCallTarget splitSource; |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
54 private final AtomicInteger callSitesKnown = new AtomicInteger(0); |
15231
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
55 @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
|
56 @CompilationFinal private Assumption profiledArgumentTypesAssumption; |
15216
d59f48be0ed6
Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15215
diff
changeset
|
57 @CompilationFinal private Class<?> profiledReturnType; |
d59f48be0ed6
Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15215
diff
changeset
|
58 @CompilationFinal private Assumption profiledReturnTypeAssumption; |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
59 |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
60 private final RootNode rootNode; |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
61 |
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
|
62 /* Experimental fields for new splitting. */ |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
63 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
|
64 private TruffleStamp argumentStamp = DefaultTruffleStamp.getInstance(); |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
65 |
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
|
66 /* Experimental field for context sensitive inlining. */ |
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 private ContextSensitiveInlining inliningDecision; |
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
|
68 |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
69 public final RootNode getRootNode() { |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
70 return rootNode; |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
71 } |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
72 |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
73 public OptimizedCallTarget(RootNode rootNode, GraalTruffleRuntime runtime, int invokeCounter, int compilationThreshold, 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
|
74 super(rootNode.toString()); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
75 this.runtime = runtime; |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
76 this.speculationLog = speculationLog; |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
77 this.rootNode = rootNode; |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
78 this.rootNode.adoptChildren(); |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
79 this.rootNode.setCallTarget(this); |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
80 this.compilationPolicy = compilationPolicy; |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
81 this.compilationProfile = new CompilationProfile(compilationThreshold, invokeCounter); |
10844
3cf5f371dc9f
Truffle: print inlined call target and rename profiling option.
Andreas Woess <andreas.woess@jku.at>
parents:
10797
diff
changeset
|
82 if (TruffleCallTargetProfiling.getValue()) { |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
83 registerCallTarget(this); |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
84 } |
13984
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
85 } |
13703
03b42f0fb635
Truffle: extend inlining interface with custom reprofile counters.
Christian Humer <christian.humer@gmail.com>
parents:
13208
diff
changeset
|
86 |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
87 public final void mergeArgumentStamp(TruffleStamp p) { |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
88 this.argumentStamp = this.argumentStamp.join(p); |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
89 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
90 |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
91 public final TruffleStamp getArgumentStamp() { |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
92 return argumentStamp; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
93 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
94 |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
95 private int splitIndex; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
96 |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
97 public int getSplitIndex() { |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
98 return splitIndex; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
99 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
100 |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
101 public OptimizedCallTarget split() { |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
102 if (!getRootNode().isSplittable()) { |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
103 return null; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
104 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
105 OptimizedCallTarget splitTarget = (OptimizedCallTarget) Truffle.getRuntime().createCallTarget(getRootNode().split()); |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
106 splitTarget.splitSource = this; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
107 splitTarget.splitIndex = splitIndex++; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
108 return splitTarget; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
109 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
110 |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
111 public Map<TruffleStamp, OptimizedCallTarget> getSplitVersions() { |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
112 return splitVersions; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
113 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
114 |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
115 public SpeculationLog getSpeculationLog() { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
116 return speculationLog; |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
117 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
118 |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
119 @Override |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
120 public Object call(Object... args) { |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
121 if (profiledArgumentTypesAssumption != null && profiledArgumentTypesAssumption.isValid()) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
122 CompilerDirectives.transferToInterpreterAndInvalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
123 profiledArgumentTypesAssumption.invalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
124 profiledArgumentTypes = null; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
125 } |
17191
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
126 return doInvoke(args); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
127 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
128 |
15224
735147ef0176
Truffle: Move direct call logic from call site to optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15222
diff
changeset
|
129 public Object callDirect(Object... args) { |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
130 profileArguments(args); |
17191
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
131 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
|
132 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
|
133 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
|
134 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
|
135 } |
735147ef0176
Truffle: Move direct call logic from call site to optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15222
diff
changeset
|
136 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
|
137 } |
735147ef0176
Truffle: Move direct call logic from call site to optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15222
diff
changeset
|
138 |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
139 @ExplodeLoop |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
140 private void profileArguments(Object[] args) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
141 if (profiledArgumentTypesAssumption == null) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
142 CompilerDirectives.transferToInterpreterAndInvalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
143 initializeProfiledArgumentTypes(args); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
144 } else if (profiledArgumentTypes != null) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
145 if (profiledArgumentTypes.length != args.length) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
146 CompilerDirectives.transferToInterpreterAndInvalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
147 profiledArgumentTypesAssumption.invalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
148 profiledArgumentTypes = null; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
149 } else if (TruffleArgumentTypeSpeculation.getValue() && profiledArgumentTypesAssumption.isValid()) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
150 for (int i = 0; i < profiledArgumentTypes.length; i++) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
151 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
|
152 CompilerDirectives.transferToInterpreterAndInvalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
153 updateProfiledArgumentTypes(args); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
154 break; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
155 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
156 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
157 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
158 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
159 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
160 |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
161 private void initializeProfiledArgumentTypes(Object[] args) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
162 CompilerAsserts.neverPartOfCompilation(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
163 profiledArgumentTypesAssumption = Truffle.getRuntime().createAssumption("Profiled Argument Types"); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
164 profiledArgumentTypes = new Class<?>[args.length]; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
165 if (TruffleArgumentTypeSpeculation.getValue()) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
166 for (int i = 0; i < args.length; i++) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
167 profiledArgumentTypes[i] = classOf(args[i]); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
168 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
169 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
170 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
171 |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
172 private void updateProfiledArgumentTypes(Object[] args) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
173 CompilerAsserts.neverPartOfCompilation(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
174 profiledArgumentTypesAssumption.invalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
175 for (int j = 0; j < profiledArgumentTypes.length; j++) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
176 profiledArgumentTypes[j] = joinTypes(profiledArgumentTypes[j], classOf(args[j])); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
177 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
178 profiledArgumentTypesAssumption = Truffle.getRuntime().createAssumption("Profiled Argument Types"); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
179 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
180 |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
181 private static Class<?> classOf(Object arg) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
182 return arg != null ? arg.getClass() : null; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
183 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
184 |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
185 private static Class<?> joinTypes(Class<?> class1, Class<?> class2) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
186 if (class1 == class2) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
187 return class1; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
188 } else if (class1 == null || class2 == null) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
189 return null; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
190 } else if (class1.isAssignableFrom(class2)) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
191 return class1; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
192 } else if (class2.isAssignableFrom(class1)) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
193 return class2; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
194 } else { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
195 return Object.class; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
196 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
197 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
198 |
17191
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
199 protected Object doInvoke(Object[] args) { |
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
200 return callBoundary(args); |
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
201 } |
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
202 |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
203 @TruffleCallBoundary |
17191
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
204 protected final Object callBoundary(Object[] args) { |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
205 if (CompilerDirectives.inInterpreter()) { |
15215
ca250afc78ec
Simplification of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15212
diff
changeset
|
206 // 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
|
207 interpreterCall(); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
208 } else { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
209 // We come here from compiled code (i.e., we have been inlined). |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
210 } |
15216
d59f48be0ed6
Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15215
diff
changeset
|
211 |
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
|
212 Object[] args1 = args; |
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
|
213 if (this.profiledArgumentTypesAssumption != null && CompilerDirectives.inCompiledCode() && profiledArgumentTypesAssumption.isValid()) { |
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
|
214 args1 = CompilerDirectives.unsafeCast(castArrayFixedLength(args1, profiledArgumentTypes.length), Object[].class, true, true); |
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
|
215 if (TruffleArgumentTypeSpeculation.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
|
216 args1 = castArguments(args1); |
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
|
217 } |
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
|
218 } |
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
|
219 Object result = callRoot(args1); |
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
|
220 |
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
|
221 // 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
|
222 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
|
223 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
|
224 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
|
225 profiledReturnType = (result == null ? null : 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
|
226 profiledReturnTypeAssumption = runtime.createAssumption("Profiled 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
|
227 } |
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
|
228 } 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
|
229 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
|
230 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
|
231 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
|
232 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
|
233 } |
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
|
234 } |
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
|
235 |
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
|
236 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
|
237 } |
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
|
238 |
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
|
239 private Object callRoot(Object[] args) { |
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
|
240 VirtualFrame frame = createFrame(getRootNode().getFrameDescriptor(), args); |
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
|
241 return callProxy(frame); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
242 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
243 |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
244 @Override |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
245 public void invalidate() { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
246 this.runtime.invalidateInstalledCode(this); |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
247 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
248 |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
249 protected void invalidate(Node oldNode, Node newNode, CharSequence reason) { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
250 if (isValid()) { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
251 CompilerAsserts.neverPartOfCompilation(); |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
252 invalidate(); |
17049
b4866d4484d1
Truffle: fixed potential non determinism in the invalidation of inlining.
Christian Humer <christian.humer@gmail.com>
parents:
16999
diff
changeset
|
253 invalidateInlining(); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
254 compilationProfile.reportInvalidated(); |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
255 logOptimizedInvalidated(this, oldNode, newNode, reason); |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
256 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
257 cancelInstalledTask(oldNode, newNode, reason); |
16711
c68da2397fcb
Truffle: temporarily disable inlining invalidations
Andreas Woess <andreas.woess@jku.at>
parents:
16558
diff
changeset
|
258 // invalidateInlining(); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
259 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
260 |
16044
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
261 public void invalidateInlining() { |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
262 if (inliningPerformed) { |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
263 inliningPerformed = false; |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
264 getRootNode().accept(new NodeVisitor() { |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
265 public boolean visit(Node node) { |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
266 if (node instanceof OptimizedDirectCallNode) { |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
267 OptimizedDirectCallNode callNode = (OptimizedDirectCallNode) node; |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
268 if (callNode.isInlined()) { |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
269 callNode.resetInlining(); |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
270 } |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
271 } |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
272 return true; |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
273 } |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
274 }); |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
275 } |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
276 } |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
277 |
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
|
278 public ContextSensitiveInlining getInliningDecision() { |
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 return inliningDecision; |
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
|
280 } |
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
|
281 |
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
|
282 public void setInliningDecision(ContextSensitiveInlining inliningDecision) { |
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
|
283 this.inliningDecision = inliningDecision; |
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
|
284 } |
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
|
285 |
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
|
286 public boolean isInlined(List<OptimizedDirectCallNode> callNodeTrace) { |
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
|
287 if (TruffleCompilerOptions.TruffleContextSensitiveInlining.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
|
288 if (inliningDecision == 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
|
289 return false; |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
290 } else { |
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
|
291 return inliningDecision.isInlined(callNodeTrace); |
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
|
292 } |
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
|
293 } else { |
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
|
294 return callNodeTrace.get(callNodeTrace.size() - 1).isInlined(); |
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
|
295 } |
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
|
296 } |
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 |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
298 private void cancelInstalledTask(Node oldNode, Node newNode, CharSequence reason) { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
299 if (this.runtime.cancelInstalledTask(this)) { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
300 logOptimizingUnqueued(this, oldNode, newNode, reason); |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
301 compilationProfile.reportInvalidated(); |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
302 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
303 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
304 |
15215
ca250afc78ec
Simplification of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15212
diff
changeset
|
305 private void interpreterCall() { |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
306 CompilerAsserts.neverPartOfCompilation(); |
15222
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
307 if (this.isValid()) { |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
308 // Stubs were deoptimized => reinstall. |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
309 this.runtime.reinstallStubs(); |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
310 } else { |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
311 compilationProfile.reportInterpreterCall(); |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
312 if (TruffleCallTargetProfiling.getValue()) { |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
313 callCount++; |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
314 } |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
315 if (compilationPolicy.shouldCompile(compilationProfile)) { |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
316 compile(); |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
317 } |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
318 } |
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 public void compile() { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
322 if (!runtime.isCompiling(this)) { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
323 performInlining(); |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
324 logOptimizingQueued(this); |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
325 runtime.compile(this, TruffleBackgroundCompilation.getValue()); |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
326 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
327 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
328 |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
329 public void compilationFinished(Throwable t) { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
330 if (t == null) { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
331 // Compilation was successful. |
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
|
332 if (inliningDecision != 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
|
333 dequeueInlinedCallSites(inliningDecision); |
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
|
334 } |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
335 } else { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
336 compilationPolicy.recordCompilationFailure(t); |
17152
d48738c27e7d
Truffle: restore "opt fail" message on compilation failure
Andreas Woess <andreas.woess@jku.at>
parents:
17079
diff
changeset
|
337 |
d48738c27e7d
Truffle: restore "opt fail" message on compilation failure
Andreas Woess <andreas.woess@jku.at>
parents:
17079
diff
changeset
|
338 if (TruffleCompilationExceptionsAreThrown.getValue()) { |
d48738c27e7d
Truffle: restore "opt fail" message on compilation failure
Andreas Woess <andreas.woess@jku.at>
parents:
17079
diff
changeset
|
339 throw new OptimizationFailedException(t, rootNode); |
d48738c27e7d
Truffle: restore "opt fail" message on compilation failure
Andreas Woess <andreas.woess@jku.at>
parents:
17079
diff
changeset
|
340 } |
d48738c27e7d
Truffle: restore "opt fail" message on compilation failure
Andreas Woess <andreas.woess@jku.at>
parents:
17079
diff
changeset
|
341 logOptimizingFailed(this, t.getMessage()); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
342 if (t instanceof BailoutException) { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
343 // Bailout => move on. |
17078
c4b1cf38002b
Truffle: TruffleCompilationExceptionsAreThrown option to get OptimizationFailedException on compiler error.
Chris Seaton <chris.seaton@oracle.com>
parents:
17049
diff
changeset
|
344 } else if (TruffleCompilationExceptionsAreFatal.getValue()) { |
c4b1cf38002b
Truffle: TruffleCompilationExceptionsAreThrown option to get OptimizationFailedException on compiler error.
Chris Seaton <chris.seaton@oracle.com>
parents:
17049
diff
changeset
|
345 t.printStackTrace(OUT); |
c4b1cf38002b
Truffle: TruffleCompilationExceptionsAreThrown option to get OptimizationFailedException on compiler error.
Chris Seaton <chris.seaton@oracle.com>
parents:
17049
diff
changeset
|
346 System.exit(-1); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
347 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
348 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
349 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
350 |
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
|
351 private void dequeueInlinedCallSites(ContextSensitiveInlining parentDecision) { |
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 for (InliningDecision decision : parentDecision) { |
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 if (decision.isInline()) { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
354 OptimizedCallTarget target = decision.getProfile().getCallNode().getCurrentCallTarget(); |
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
|
355 if (runtime.cancelInstalledTask(target)) { |
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
|
356 logOptimizingUnqueued(target, null, null, "Inlining caller compiled."); |
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
|
357 } |
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
|
358 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
|
359 } |
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
|
360 } |
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
|
361 } |
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
|
362 |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
363 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
|
364 try { |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
365 return getRootNode().execute(frame); |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
366 } finally { |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
367 // 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
|
368 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
|
369 } |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
370 } |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
371 |
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
|
372 public final int getKnownCallSiteCount() { |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
373 return callSitesKnown.get(); |
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 |
15089
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
376 public final void incrementKnownCallSites() { |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
377 callSitesKnown.incrementAndGet(); |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
378 } |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
379 |
15089
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
380 public final void decrementKnownCallSites() { |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
381 callSitesKnown.decrementAndGet(); |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
382 } |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
383 |
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
|
384 public final OptimizedCallTarget getSplitSource() { |
14073
c5411233cdf8
Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents:
13996
diff
changeset
|
385 return splitSource; |
c5411233cdf8
Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents:
13996
diff
changeset
|
386 } |
c5411233cdf8
Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents:
13996
diff
changeset
|
387 |
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
|
388 public final void setSplitSource(OptimizedCallTarget splitSource) { |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
389 this.splitSource = splitSource; |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
390 } |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
391 |
13984
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
392 @Override |
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
393 public String toString() { |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
394 String superString = rootNode.toString(); |
15168
78530cbd8940
Truffle: Make OptimizedCallTarget itself an InstalledCode object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15167
diff
changeset
|
395 if (isValid()) { |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
396 superString += " <opt>"; |
13984
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
397 } |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
398 if (splitSource != null) { |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
399 superString += " <split-" + splitIndex + "-" + argumentStamp.toStringShort() + ">"; |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
400 } |
13984
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
401 return superString; |
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
402 } |
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
403 |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
404 public CompilationProfile getCompilationProfile() { |
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
405 return compilationProfile; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
406 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
407 |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14984
diff
changeset
|
408 public final Object callInlined(Object[] arguments) { |
14715
4ea4db3f23ba
Truffle: fixed call count profile; added leaf check for inlining; inline tracing now shows dispatched calls.
Christian Humer <christian.humer@gmail.com>
parents:
14618
diff
changeset
|
409 if (CompilerDirectives.inInterpreter()) { |
4ea4db3f23ba
Truffle: fixed call count profile; added leaf check for inlining; inline tracing now shows dispatched calls.
Christian Humer <christian.humer@gmail.com>
parents:
14618
diff
changeset
|
410 compilationProfile.reportInlinedCall(); |
4ea4db3f23ba
Truffle: fixed call count profile; added leaf check for inlining; inline tracing now shows dispatched calls.
Christian Humer <christian.humer@gmail.com>
parents:
14618
diff
changeset
|
411 } |
15216
d59f48be0ed6
Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15215
diff
changeset
|
412 VirtualFrame frame = createFrame(getRootNode().getFrameDescriptor(), arguments); |
d59f48be0ed6
Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15215
diff
changeset
|
413 return callProxy(frame); |
14715
4ea4db3f23ba
Truffle: fixed call count profile; added leaf check for inlining; inline tracing now shows dispatched calls.
Christian Humer <christian.humer@gmail.com>
parents:
14618
diff
changeset
|
414 } |
4ea4db3f23ba
Truffle: fixed call count profile; added leaf check for inlining; inline tracing now shows dispatched calls.
Christian Humer <christian.humer@gmail.com>
parents:
14618
diff
changeset
|
415 |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
416 public final void performInlining() { |
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
|
417 if (!TruffleFunctionInlining.getValue() || TruffleContextSensitiveInlining.getValue()) { |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
418 return; |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
419 } |
15089
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
420 if (inliningPerformed) { |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
421 return; |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
422 } |
15089
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
423 TruffleInliningHandler handler = new TruffleInliningHandler(new DefaultInliningPolicy()); |
16044
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
424 TruffleInliningDecision result = handler.decideInlining(this, 0); |
15089
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
425 performInlining(result); |
15090
07e7aae05983
Truffle: context sensitive inlining cleanup
Christian Humer <christian.humer@gmail.com>
parents:
15089
diff
changeset
|
426 logInliningDecision(result); |
12711
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
427 } |
12592
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
428 |
16044
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
429 private static void performInlining(TruffleInliningDecision result) { |
15339
265c47be2308
Truffle: fix inlining recursions
Christian Humer <christian.humer@gmail.com>
parents:
15312
diff
changeset
|
430 if (result.getCallTarget().inliningPerformed) { |
265c47be2308
Truffle: fix inlining recursions
Christian Humer <christian.humer@gmail.com>
parents:
15312
diff
changeset
|
431 return; |
265c47be2308
Truffle: fix inlining recursions
Christian Humer <christian.humer@gmail.com>
parents:
15312
diff
changeset
|
432 } |
265c47be2308
Truffle: fix inlining recursions
Christian Humer <christian.humer@gmail.com>
parents:
15312
diff
changeset
|
433 result.getCallTarget().inliningPerformed = true; |
15089
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
434 for (TruffleInliningProfile profile : result) { |
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
435 profile.getCallNode().inline(); |
16044
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
436 TruffleInliningDecision recursiveResult = profile.getRecursiveResult(); |
15089
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
437 if (recursiveResult != null) { |
15312
7f5c9079e24a
Truffle: fixes to the inlining heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
15231
diff
changeset
|
438 performInlining(recursiveResult); |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
439 } |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
440 } |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
441 } |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
442 |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
443 @ExplodeLoop |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
444 private Object[] castArguments(Object[] originalArguments) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
445 Object[] castArguments = new Object[profiledArgumentTypes.length]; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
446 for (int i = 0; i < profiledArgumentTypes.length; i++) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
447 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
|
448 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
449 return castArguments; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
450 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
451 |
15231
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
452 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
|
453 return args; |
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
454 } |
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
455 |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14984
diff
changeset
|
456 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
|
457 return new FrameWithoutBoxing(descriptor, args); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
458 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
459 |
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
|
460 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
|
461 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
|
462 } |
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
|
463 |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
464 @Override |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
465 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
|
466 compilationProfile.reportLoopCount(count); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
467 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
468 |
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
|
469 @Override |
14584
6189c1983cd3
Truffle: make Node#replace accept any CharSequence as reason
Andreas Woess <andreas.woess@jku.at>
parents:
14569
diff
changeset
|
470 public void nodeReplaced(Node oldNode, Node newNode, CharSequence reason) { |
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
|
471 compilationProfile.reportNodeReplaced(); |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
472 invalidate(oldNode, newNode, reason); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
473 } |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
474 |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
475 public Map<String, Object> getDebugProperties() { |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
476 Map<String, Object> properties = new LinkedHashMap<>(); |
15089
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
477 addASTSizeProperty(this, properties); |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
478 properties.putAll(getCompilationProfile().getDebugProperties()); |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
479 return properties; |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
480 |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
481 } |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
482 |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
483 } |