annotate graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java @ 15216:d59f48be0ed6

Truffle: Speculate on the return type of calls.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 17 Apr 2014 23:16:21 +0200
parents ca250afc78ec
children 58d2c5bdb9cd
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.*;
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.*;
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 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
35 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
36 import com.oracle.truffle.api.frame.*;
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 import com.oracle.truffle.api.nodes.*;
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38
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 * 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
41 */
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
42 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
43
14866
a0185cd77565 Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14715
diff changeset
44 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
45
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
46 protected final GraalTruffleRuntime runtime;
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
47 private SpeculationLog speculationLog;
14866
a0185cd77565 Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14715
diff changeset
48 protected int callCount;
15089
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
49 protected boolean inliningPerformed;
14866
a0185cd77565 Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14715
diff changeset
50 protected final CompilationProfile compilationProfile;
a0185cd77565 Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14715
diff changeset
51 protected final CompilationPolicy compilationPolicy;
13996
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
52 private OptimizedCallTarget splitSource;
14983
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
53 private final AtomicInteger callSitesKnown = new AtomicInteger(0);
15216
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
54 @CompilationFinal private Class<?> profiledReturnType;
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
55 @CompilationFinal private Assumption profiledReturnTypeAssumption;
14983
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
56
15167
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
57 private final RootNode rootNode;
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
58
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
59 public final RootNode getRootNode() {
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
60 return rootNode;
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
61 }
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
62
15216
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
63 public Class<?> getProfiledReturnType() {
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
64 Class<?> result = profiledReturnType;
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
65 if (result != null) {
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
66 try {
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
67 profiledReturnTypeAssumption.check();
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
68 } catch (InvalidAssumptionException e) {
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
69 }
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
70 }
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
71 return result;
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
72 }
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
73
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
74 public OptimizedCallTarget(RootNode rootNode, GraalTruffleRuntime runtime, int invokeCounter, int compilationThreshold, CompilationPolicy compilationPolicy, SpeculationLog speculationLog) {
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
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
87 public SpeculationLog getSpeculationLog() {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
88 return speculationLog;
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
89 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
90
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
91 @Override
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
92 public Object call(Object... args) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
93 return callBoundary(args);
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
94 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
95
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
96 @TruffleCallBoundary
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
97 private Object callBoundary(Object[] args) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
98 if (CompilerDirectives.inInterpreter()) {
15215
ca250afc78ec Simplification of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15212
diff changeset
99 // We are called and we are still in Truffle interpreter mode.
15216
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
100 CompilerDirectives.transferToInterpreter();
15215
ca250afc78ec Simplification of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15212
diff changeset
101 interpreterCall();
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
102 } else {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
103 // 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
104 }
15216
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
105
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
106 return callRoot(args);
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
107 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
108
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
109 @Override
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
110 public void invalidate() {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
111 this.runtime.invalidateInstalledCode(this);
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
112 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
113
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
114 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
115 if (isValid()) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
116 CompilerAsserts.neverPartOfCompilation();
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
117 invalidate();
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
118 compilationProfile.reportInvalidated();
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
119 logOptimizedInvalidated(this, oldNode, newNode, reason);
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 cancelInstalledTask(oldNode, newNode, reason);
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
122 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
123
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
124 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
125 if (this.runtime.cancelInstalledTask(this)) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
126 logOptimizingUnqueued(this, oldNode, newNode, reason);
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
127 compilationProfile.reportInvalidated();
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
128 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
129 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
130
15215
ca250afc78ec Simplification of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15212
diff changeset
131 private void interpreterCall() {
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
132 CompilerAsserts.neverPartOfCompilation();
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
133 compilationProfile.reportInterpreterCall();
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
134 if (TruffleCallTargetProfiling.getValue()) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
135 callCount++;
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
136 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
137
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
138 if (compilationPolicy.shouldCompile(compilationProfile)) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
139 compile();
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
140 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
141 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
142
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
143 public void compile() {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
144 if (!runtime.isCompiling(this)) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
145 performInlining();
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
146 logOptimizingQueued(this);
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
147 runtime.compile(this, TruffleBackgroundCompilation.getValue());
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
148 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
149 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
150
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
151 public void compilationFinished(Throwable t) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
152 if (t == null) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
153 // Compilation was successful.
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
154 } else {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
155 compilationPolicy.recordCompilationFailure(t);
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
156 logOptimizingFailed(this, t.getMessage());
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
157 if (t instanceof BailoutException) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
158 // Bailout => move on.
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
159 } else {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
160 if (TruffleCompilationExceptionsAreFatal.getValue()) {
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
161 t.printStackTrace(OUT);
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
162 System.exit(-1);
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
163 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
164 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
165 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
166 }
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
167
15167
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
168 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
169 try {
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
170 return getRootNode().execute(frame);
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
171 } finally {
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
172 // 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
173 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
174 }
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
175 }
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
176
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
177 public final int getKnownCallSiteCount() {
14983
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
178 return callSitesKnown.get();
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
179 }
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
180
15089
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
181 public final void incrementKnownCallSites() {
14983
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
182 callSitesKnown.incrementAndGet();
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
183 }
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
184
15089
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
185 public final void decrementKnownCallSites() {
14983
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
186 callSitesKnown.decrementAndGet();
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
187 }
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
188
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
189 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
190 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
191 }
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
192
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
193 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
194 this.splitSource = splitSource;
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
195 }
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
196
13984
1c9dbfc5b510 Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13915
diff changeset
197 @Override
1c9dbfc5b510 Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13915
diff changeset
198 public String toString() {
15167
258e3e0b5e2e Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
199 String superString = rootNode.toString();
15168
78530cbd8940 Truffle: Make OptimizedCallTarget itself an InstalledCode object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15167
diff changeset
200 if (isValid()) {
13984
1c9dbfc5b510 Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13915
diff changeset
201 superString += " <compiled>";
1c9dbfc5b510 Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13915
diff changeset
202 }
13996
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
203 if (splitSource != null) {
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
204 superString += " <split>";
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
205 }
13984
1c9dbfc5b510 Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13915
diff changeset
206 return superString;
1c9dbfc5b510 Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13915
diff changeset
207 }
1c9dbfc5b510 Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13915
diff changeset
208
14866
a0185cd77565 Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14715
diff changeset
209 public CompilationProfile getCompilationProfile() {
a0185cd77565 Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14715
diff changeset
210 return compilationProfile;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
211 }
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
212
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14984
diff changeset
213 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
214 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
215 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
216 }
15216
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
217 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
218 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
219 }
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
220
14983
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
221 public final void performInlining() {
15089
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
222 if (!TruffleFunctionInlining.getValue()) {
13996
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
223 return;
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
224 }
15089
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
225 if (inliningPerformed) {
14983
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
226 return;
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
227 }
15089
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
228 TruffleInliningHandler handler = new TruffleInliningHandler(new DefaultInliningPolicy());
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
229 TruffleInliningResult result = handler.decideInlining(this, 0);
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
230 performInlining(result);
15090
07e7aae05983 Truffle: context sensitive inlining cleanup
Christian Humer <christian.humer@gmail.com>
parents: 15089
diff changeset
231 logInliningDecision(result);
12711
fb4658e16b5d Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents: 12710
diff changeset
232 }
12592
42c8f76a98bf Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 12591
diff changeset
233
15089
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
234 private void performInlining(TruffleInliningResult result) {
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
235 if (inliningPerformed) {
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
236 return;
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
237 }
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
238 inliningPerformed = true;
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
239 for (TruffleInliningProfile profile : result) {
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
240 profile.getCallNode().inline();
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
241 TruffleInliningResult recursiveResult = profile.getRecursiveResult();
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
242 if (recursiveResult != null) {
448338c9ce96 Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
243 recursiveResult.getCallTarget().performInlining(recursiveResult);
14983
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
244 }
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
245 }
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
246 }
a31d807757ee Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents: 14911
diff changeset
247
15216
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
248 public final Object callRoot(Object[] args) {
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14984
diff changeset
249 VirtualFrame frame = createFrame(getRootNode().getFrameDescriptor(), args);
15216
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
250 Object result = callProxy(frame);
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
251
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
252 // Profile call return type
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
253 if (profiledReturnTypeAssumption == null) {
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
254 CompilerDirectives.transferToInterpreter();
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
255 profiledReturnType = result.getClass();
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
256 profiledReturnTypeAssumption = Truffle.getRuntime().createAssumption("Profiled Return Type");
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
257 } else if (profiledReturnType != null) {
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
258 if (result == null || profiledReturnType != result.getClass()) {
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
259 CompilerDirectives.transferToInterpreter();
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
260 profiledReturnType = null;
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
261 profiledReturnTypeAssumption.invalidate();
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
262 }
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
263 }
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
264
d59f48be0ed6 Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15215
diff changeset
265 return result;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266 }
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14984
diff changeset
268 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
269 return new FrameWithoutBoxing(descriptor, args);
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
270 }
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
271
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
272 @Override
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
273 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
274 compilationProfile.reportLoopCount(count);
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
275 }
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
276
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
277 @Override
14584
6189c1983cd3 Truffle: make Node#replace accept any CharSequence as reason
Andreas Woess <andreas.woess@jku.at>
parents: 14569
diff changeset
278 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
279 compilationProfile.reportNodeReplaced();
13996
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
280 invalidate(oldNode, newNode, reason);
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281 }
10752
e2f5ae9afdc5 Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents: 10751
diff changeset
282
13996
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
283 public Map<String, Object> getDebugProperties() {
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
284 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
285 addASTSizeProperty(this, properties);
13996
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
286 properties.putAll(getCompilationProfile().getDebugProperties());
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
287 return properties;
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
288
c7ac129e17e9 Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents: 13988
diff changeset
289 }
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
290 }