annotate graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java @ 17420:e98150919577

Truffle: cleanup compilation profile fields.
author Christian Humer <christian.humer@gmail.com>
date Mon, 13 Oct 2014 17:44:15 +0200
parents b725292b8a11
children 89f801a9b4d4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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.*;
17310
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
29 import java.lang.reflect.*;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 import java.util.*;
14983
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
31 import java.util.concurrent.atomic.*;
17400
e3dd05527c2f Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents: 17399
diff changeset
32 import java.util.stream.*;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.api.code.*;
17310
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
35 import com.oracle.graal.compiler.common.*;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 import com.oracle.graal.debug.*;
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 import com.oracle.truffle.api.*;
15216
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
38 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 import com.oracle.truffle.api.frame.*;
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 import com.oracle.truffle.api.nodes.*;
17400
e3dd05527c2f Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents: 17399
diff changeset
41 import com.oracle.truffle.api.nodes.Node;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
43 /**
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44 * 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
45 */
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
46 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
47
14866
a0185cd77565 Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14715
diff changeset
48 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
49
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
50 protected final GraalTruffleRuntime runtime;
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
51 private SpeculationLog speculationLog;
15089
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
52 protected boolean inliningPerformed;
14866
a0185cd77565 Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14715
diff changeset
53 protected final CompilationProfile compilationProfile;
a0185cd77565 Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14715
diff changeset
54 protected final CompilationPolicy compilationPolicy;
13996
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
55 private OptimizedCallTarget splitSource;
14983
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
56 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
57 @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
58 @CompilationFinal private Assumption profiledArgumentTypesAssumption;
15216
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
59 @CompilationFinal private Class<?> profiledReturnType;
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
60 @CompilationFinal private Assumption profiledReturnTypeAssumption;
14983
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
61
15167
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
62 private final RootNode rootNode;
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
63
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
64 /* Experimental fields for new splitting. */
16410
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
65 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
66 private TruffleStamp argumentStamp = DefaultTruffleStamp.getInstance();
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
67
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
68 /* Experimental field for context sensitive inlining. */
17400
e3dd05527c2f Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents: 17399
diff changeset
69 private TruffleInlining inlining;
17256
88d5fd9e1a6c Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents: 17191
diff changeset
70
15167
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
71 public final RootNode getRootNode() {
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
72 return rootNode;
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
73 }
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
74
17420
e98150919577 Truffle: cleanup compilation profile fields.
Christian Humer <christian.humer@gmail.com>
parents: 17404
diff changeset
75 public OptimizedCallTarget(RootNode rootNode, GraalTruffleRuntime runtime, CompilationPolicy compilationPolicy, SpeculationLog speculationLog) {
16401
347915b8cea8 Move name from HotSpotNmethod to InstalledCode to have a name again for truffle nmethods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16044
diff changeset
76 super(rootNode.toString());
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
77 this.runtime = runtime;
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
78 this.speculationLog = speculationLog;
15167
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
79 this.rootNode = rootNode;
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
80 this.rootNode.adoptChildren();
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
81 this.rootNode.setCallTarget(this);
14866
a0185cd77565 Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14715
diff changeset
82 this.compilationPolicy = compilationPolicy;
10844
3cf5f371dc9f Truffle: print inlined call target and rename profiling option.
Andreas Woess <andreas.woess@jku.at>
parents: 10797
diff changeset
83 if (TruffleCallTargetProfiling.getValue()) {
17420
e98150919577 Truffle: cleanup compilation profile fields.
Christian Humer <christian.humer@gmail.com>
parents: 17404
diff changeset
84 this.compilationProfile = new TraceCompilationProfile();
17404
b725292b8a11 Truffle: updated TruffleCallTargetProfiling
Christian Humer <christian.humer@gmail.com>
parents: 17400
diff changeset
85 } else {
17420
e98150919577 Truffle: cleanup compilation profile fields.
Christian Humer <christian.humer@gmail.com>
parents: 17404
diff changeset
86 this.compilationProfile = new CompilationProfile();
10752
e2f5ae9afdc5 Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents: 10751
diff changeset
87 }
13984
1c9dbfc5b510 Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13915
diff changeset
88 }
13703
03b42f0fb635 Truffle: extend inlining interface with custom reprofile counters.
Christian Humer <christian.humer@gmail.com>
parents: 13208
diff changeset
89
16410
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
90 public final void mergeArgumentStamp(TruffleStamp p) {
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
91 this.argumentStamp = this.argumentStamp.join(p);
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
92 }
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 public final TruffleStamp getArgumentStamp() {
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
95 return argumentStamp;
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
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
98 private int 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 public int getSplitIndex() {
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
101 return splitIndex;
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
102 }
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
103
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
104 public OptimizedCallTarget split() {
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
105 if (!getRootNode().isSplittable()) {
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
106 return null;
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
107 }
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
108 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
109 splitTarget.splitSource = this;
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
110 splitTarget.splitIndex = splitIndex++;
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
111 return splitTarget;
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
112 }
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 public Map<TruffleStamp, OptimizedCallTarget> getSplitVersions() {
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
115 return splitVersions;
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
116 }
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
117
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
118 public SpeculationLog getSpeculationLog() {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
119 return speculationLog;
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
120 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
121
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
122 @Override
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
123 public Object call(Object... args) {
17404
b725292b8a11 Truffle: updated TruffleCallTargetProfiling
Christian Humer <christian.humer@gmail.com>
parents: 17400
diff changeset
124 compilationProfile.reportIndirectCall();
16470
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
125 if (profiledArgumentTypesAssumption != null && profiledArgumentTypesAssumption.isValid()) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
126 CompilerDirectives.transferToInterpreterAndInvalidate();
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
127 profiledArgumentTypesAssumption.invalidate();
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
128 profiledArgumentTypes = null;
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
129 }
17191
be733832464d Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17152
diff changeset
130 return doInvoke(args);
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
131 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
132
17310
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
133 public final Object callDirect(Object... args) {
17404
b725292b8a11 Truffle: updated TruffleCallTargetProfiling
Christian Humer <christian.humer@gmail.com>
parents: 17400
diff changeset
134 compilationProfile.reportDirectCall();
16470
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
135 profileArguments(args);
17191
be733832464d Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17152
diff changeset
136 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
137 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
138 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
139 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
140 }
735147ef0176 Truffle: Move direct call logic from call site to optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15222
diff changeset
141 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
142 }
735147ef0176 Truffle: Move direct call logic from call site to optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15222
diff changeset
143
17310
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
144 public final Object callInlined(Object... arguments) {
17404
b725292b8a11 Truffle: updated TruffleCallTargetProfiling
Christian Humer <christian.humer@gmail.com>
parents: 17400
diff changeset
145 compilationProfile.reportInlinedCall();
17310
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
146 VirtualFrame frame = createFrame(getRootNode().getFrameDescriptor(), arguments);
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
147 return callProxy(frame);
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
148 }
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
149
16470
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
150 @ExplodeLoop
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
151 private void profileArguments(Object[] args) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
152 if (profiledArgumentTypesAssumption == null) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
153 CompilerDirectives.transferToInterpreterAndInvalidate();
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
154 initializeProfiledArgumentTypes(args);
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
155 } else if (profiledArgumentTypes != null) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
156 if (profiledArgumentTypes.length != args.length) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
157 CompilerDirectives.transferToInterpreterAndInvalidate();
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
158 profiledArgumentTypesAssumption.invalidate();
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
159 profiledArgumentTypes = null;
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
160 } else if (TruffleArgumentTypeSpeculation.getValue() && profiledArgumentTypesAssumption.isValid()) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
161 for (int i = 0; i < profiledArgumentTypes.length; i++) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
162 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
163 CompilerDirectives.transferToInterpreterAndInvalidate();
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
164 updateProfiledArgumentTypes(args);
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
165 break;
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
166 }
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
167 }
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 initializeProfiledArgumentTypes(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 = Truffle.getRuntime().createAssumption("Profiled Argument Types");
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
175 profiledArgumentTypes = new Class<?>[args.length];
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
176 if (TruffleArgumentTypeSpeculation.getValue()) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
177 for (int i = 0; i < args.length; i++) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
178 profiledArgumentTypes[i] = classOf(args[i]);
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 }
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
182
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
183 private void updateProfiledArgumentTypes(Object[] args) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
184 CompilerAsserts.neverPartOfCompilation();
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
185 profiledArgumentTypesAssumption.invalidate();
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
186 for (int j = 0; j < profiledArgumentTypes.length; j++) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
187 profiledArgumentTypes[j] = joinTypes(profiledArgumentTypes[j], classOf(args[j]));
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
188 }
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
189 profiledArgumentTypesAssumption = Truffle.getRuntime().createAssumption("Profiled Argument Types");
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
190 }
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
191
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
192 private static Class<?> classOf(Object arg) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
193 return arg != null ? arg.getClass() : null;
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
194 }
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
195
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
196 private static Class<?> joinTypes(Class<?> class1, Class<?> class2) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
197 if (class1 == class2) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
198 return class1;
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
199 } else if (class1 == null || class2 == null) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
200 return null;
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
201 } else if (class1.isAssignableFrom(class2)) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
202 return class1;
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
203 } else if (class2.isAssignableFrom(class1)) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
204 return class2;
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
205 } else {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
206 return Object.class;
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
207 }
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
208 }
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
209
17191
be733832464d Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17152
diff changeset
210 protected Object doInvoke(Object[] args) {
be733832464d Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17152
diff changeset
211 return callBoundary(args);
be733832464d Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17152
diff changeset
212 }
be733832464d Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17152
diff changeset
213
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
214 @TruffleCallBoundary
17191
be733832464d Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17152
diff changeset
215 protected final Object callBoundary(Object[] args) {
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
216 if (CompilerDirectives.inInterpreter()) {
15215
ca250afc78ec Simplification of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15212
diff changeset
217 // 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
218 interpreterCall();
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
219 } else {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
220 // 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
221 }
15216
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
222
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
223 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
224 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
225 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
226 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
227 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
228 }
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 }
17315
979bf76f0fe3 Truffle: fixed passed wrong arguments to the frame in callBoundary.
Christian Humer <christian.humer@gmail.com>
parents: 17310
diff changeset
230 VirtualFrame frame = createFrame(getRootNode().getFrameDescriptor(), args1);
17310
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
231 Object result = callProxy(frame);
17256
88d5fd9e1a6c Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents: 17191
diff changeset
232
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 // 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
234 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
235 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
236 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
237 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
238 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
239 }
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 } 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
241 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
242 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
243 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
244 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
245 }
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
246 }
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
247
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
248 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
249 }
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
250
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
251 @Override
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
252 public void invalidate() {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
253 this.runtime.invalidateInstalledCode(this);
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
254 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
255
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
256 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
257 if (isValid()) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
258 CompilerAsserts.neverPartOfCompilation();
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
259 invalidate();
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
260 compilationProfile.reportInvalidated();
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
261 logOptimizedInvalidated(this, oldNode, newNode, reason);
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
262 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
263 cancelInstalledTask(oldNode, newNode, reason);
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
264 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
265
17400
e3dd05527c2f Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents: 17399
diff changeset
266 public TruffleInlining getInlining() {
e3dd05527c2f Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents: 17399
diff changeset
267 return inlining;
16044
2662fb9c37e2 Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents: 15396
diff changeset
268 }
2662fb9c37e2 Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents: 15396
diff changeset
269
17400
e3dd05527c2f Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents: 17399
diff changeset
270 public void setInlining(TruffleInlining inliningDecision) {
e3dd05527c2f Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents: 17399
diff changeset
271 this.inlining = inliningDecision;
17256
88d5fd9e1a6c Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents: 17191
diff changeset
272 }
88d5fd9e1a6c Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents: 17191
diff changeset
273
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
274 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
275 if (this.runtime.cancelInstalledTask(this)) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
276 logOptimizingUnqueued(this, oldNode, newNode, reason);
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
277 compilationProfile.reportInvalidated();
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
278 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
279 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
280
15215
ca250afc78ec Simplification of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15212
diff changeset
281 private void interpreterCall() {
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
282 CompilerAsserts.neverPartOfCompilation();
15222
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15216
diff changeset
283 if (this.isValid()) {
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15216
diff changeset
284 // Stubs were deoptimized => reinstall.
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15216
diff changeset
285 this.runtime.reinstallStubs();
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15216
diff changeset
286 } else {
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15216
diff changeset
287 compilationProfile.reportInterpreterCall();
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15216
diff changeset
288 if (compilationPolicy.shouldCompile(compilationProfile)) {
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15216
diff changeset
289 compile();
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15216
diff changeset
290 }
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
291 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
292 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
293
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
294 public void compile() {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
295 if (!runtime.isCompiling(this)) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
296 logOptimizingQueued(this);
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
297 runtime.compile(this, TruffleBackgroundCompilation.getValue());
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
298 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
299 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
300
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
301 public void compilationFinished(Throwable t) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
302 if (t == null) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
303 // Compilation was successful.
17400
e3dd05527c2f Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents: 17399
diff changeset
304 if (inlining != null) {
e3dd05527c2f Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents: 17399
diff changeset
305 dequeueInlinedCallSites(inlining);
17256
88d5fd9e1a6c Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents: 17191
diff changeset
306 }
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
307 } else {
17341
e3f3233ec6cd refactor BailoutException to include information about non-permanent errors
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17315
diff changeset
308 if (!(t instanceof BailoutException) || ((BailoutException) t).isPermanent()) {
e3f3233ec6cd refactor BailoutException to include information about non-permanent errors
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17315
diff changeset
309 compilationPolicy.recordCompilationFailure(t);
e3f3233ec6cd refactor BailoutException to include information about non-permanent errors
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17315
diff changeset
310 }
17152
d48738c27e7d Truffle: restore "opt fail" message on compilation failure
Andreas Woess <andreas.woess@jku.at>
parents: 17079
diff changeset
311
d48738c27e7d Truffle: restore "opt fail" message on compilation failure
Andreas Woess <andreas.woess@jku.at>
parents: 17079
diff changeset
312 if (TruffleCompilationExceptionsAreThrown.getValue()) {
d48738c27e7d Truffle: restore "opt fail" message on compilation failure
Andreas Woess <andreas.woess@jku.at>
parents: 17079
diff changeset
313 throw new OptimizationFailedException(t, rootNode);
d48738c27e7d Truffle: restore "opt fail" message on compilation failure
Andreas Woess <andreas.woess@jku.at>
parents: 17079
diff changeset
314 }
17400
e3dd05527c2f Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents: 17399
diff changeset
315 logOptimizingFailed(this, t.toString());
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
316 if (t instanceof BailoutException) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
317 // Bailout => move on.
17078
c4b1cf38002b Truffle: TruffleCompilationExceptionsAreThrown option to get OptimizationFailedException on compiler error.
Chris Seaton <chris.seaton@oracle.com>
parents: 17049
diff changeset
318 } else if (TruffleCompilationExceptionsAreFatal.getValue()) {
c4b1cf38002b Truffle: TruffleCompilationExceptionsAreThrown option to get OptimizationFailedException on compiler error.
Chris Seaton <chris.seaton@oracle.com>
parents: 17049
diff changeset
319 t.printStackTrace(OUT);
c4b1cf38002b Truffle: TruffleCompilationExceptionsAreThrown option to get OptimizationFailedException on compiler error.
Chris Seaton <chris.seaton@oracle.com>
parents: 17049
diff changeset
320 System.exit(-1);
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
321 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
322 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
323 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
324
17400
e3dd05527c2f Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents: 17399
diff changeset
325 private void dequeueInlinedCallSites(TruffleInlining parentDecision) {
e3dd05527c2f Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents: 17399
diff changeset
326 for (TruffleInliningDecision decision : parentDecision) {
17256
88d5fd9e1a6c Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents: 17191
diff changeset
327 if (decision.isInline()) {
17400
e3dd05527c2f Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents: 17399
diff changeset
328 OptimizedCallTarget target = decision.getTarget();
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
329 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
330 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
331 }
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 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
333 }
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 }
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
335 }
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
336
15167
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
337 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
338 try {
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
339 return getRootNode().execute(frame);
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
340 } finally {
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
341 // 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
342 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
343 }
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
344 }
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
345
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
346 public final int getKnownCallSiteCount() {
14983
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
347 return callSitesKnown.get();
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
348 }
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
349
15089
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
350 public final void incrementKnownCallSites() {
14983
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
351 callSitesKnown.incrementAndGet();
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
352 }
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
353
15089
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
354 public final void decrementKnownCallSites() {
14983
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
355 callSitesKnown.decrementAndGet();
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
356 }
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
357
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
358 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
359 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
360 }
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
361
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
362 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
363 this.splitSource = splitSource;
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
364 }
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
365
13984
1c9dbfc5b510 Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13915
diff changeset
366 @Override
1c9dbfc5b510 Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13915
diff changeset
367 public String toString() {
15167
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
368 String superString = rootNode.toString();
15168
78530cbd8940 Truffle: Make OptimizedCallTarget itself an InstalledCode object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15167
diff changeset
369 if (isValid()) {
16410
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
370 superString += " <opt>";
13984
1c9dbfc5b510 Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13915
diff changeset
371 }
13996
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
372 if (splitSource != null) {
16410
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
373 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
374 }
13984
1c9dbfc5b510 Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13915
diff changeset
375 return superString;
1c9dbfc5b510 Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13915
diff changeset
376 }
1c9dbfc5b510 Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13915
diff changeset
377
14866
a0185cd77565 Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14715
diff changeset
378 public CompilationProfile getCompilationProfile() {
a0185cd77565 Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14715
diff changeset
379 return compilationProfile;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
380 }
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
381
16470
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
382 @ExplodeLoop
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
383 private Object[] castArguments(Object[] originalArguments) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
384 Object[] castArguments = new Object[profiledArgumentTypes.length];
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
385 for (int i = 0; i < profiledArgumentTypes.length; i++) {
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
386 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
387 }
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
388 return castArguments;
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
389 }
efbf9195dfcb Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents: 16410
diff changeset
390
15231
babe13eb6118 Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15224
diff changeset
391 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
392 return args;
babe13eb6118 Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15224
diff changeset
393 }
babe13eb6118 Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15224
diff changeset
394
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14984
diff changeset
395 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
396 return new FrameWithoutBoxing(descriptor, args);
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
397 }
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
398
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
399 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
400 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
401 }
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
402
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
403 @Override
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
404 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
405 compilationProfile.reportLoopCount(count);
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
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
408 @Override
14584
6189c1983cd3 Truffle: make Node#replace accept any CharSequence as reason
Andreas Woess <andreas.woess@jku.at>
parents: 14569
diff changeset
409 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
410 compilationProfile.reportNodeReplaced();
13996
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
411 invalidate(oldNode, newNode, reason);
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
412 }
10752
e2f5ae9afdc5 Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents: 10751
diff changeset
413
17399
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
414 public void accept(NodeVisitor visitor, boolean includeInlinedNodes) {
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
415 TruffleInlining inliner = getInlining();
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
416 if (includeInlinedNodes && inliner != null) {
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
417 inlining.accept(this, visitor);
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
418 } else {
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
419 getRootNode().accept(visitor);
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
420 }
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
421 }
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
422
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
423 public Stream<Node> nodeStream(boolean includeInlinedNodes) {
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
424 Iterator<Node> iterator;
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
425 TruffleInlining inliner = getInlining();
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
426 if (includeInlinedNodes && inliner != null) {
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
427 iterator = inliner.makeNodeIterator(this);
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
428 } else {
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
429 iterator = NodeUtil.makeRecursiveIterator(this.getRootNode());
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
430 }
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
431 return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, 0), false);
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
432 }
5787218bad91 Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17341
diff changeset
433
13996
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
434 public Map<String, Object> getDebugProperties() {
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
435 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
436 addASTSizeProperty(this, properties);
13996
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
437 properties.putAll(getCompilationProfile().getDebugProperties());
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
438 return properties;
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
439 }
16410
7f862f0ab1bc Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 16401
diff changeset
440
17310
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
441 public static Method getCallDirectMethod() {
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
442 try {
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
443 return OptimizedCallTarget.class.getDeclaredMethod("callDirect", Object[].class);
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
444 } catch (NoSuchMethodException | SecurityException e) {
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
445 throw new GraalInternalError(e);
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
446 }
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
447 }
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
448
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
449 public static Method getCallInlinedMethod() {
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
450 try {
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
451 return OptimizedCallTarget.class.getDeclaredMethod("callInlined", Object[].class);
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
452 } catch (NoSuchMethodException | SecurityException e) {
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
453 throw new GraalInternalError(e);
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
454 }
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
455 }
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17256
diff changeset
456
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
457 }