Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java @ 13803:e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 24 Jan 2014 15:55:41 +0100 |
parents | 4281521dc39a |
children | 739194d1e813 |
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 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 import static com.oracle.graal.truffle.TruffleCompilerOptions.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 import java.io.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 import java.util.*; |
12592
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
29 import java.util.concurrent.*; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.api.code.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.debug.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.truffle.api.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.truffle.api.frame.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.truffle.api.impl.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.truffle.api.nodes.*; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 |
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 * 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
|
40 */ |
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
|
41 public final class OptimizedCallTarget extends DefaultCallTarget implements FrameFactory, LoopCountReceiver, ReplaceObserver { |
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 private 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
|
44 |
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 private InstalledCode installedCode; |
d2d0c44662bb
Truffle: refactored CompilationProfile to separate the profile and the policy in separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
12708
diff
changeset
|
46 private Future<InstalledCode> installedCodeTask; |
d2d0c44662bb
Truffle: refactored CompilationProfile to separate the profile and the policy in separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
12708
diff
changeset
|
47 private final TruffleCompiler compiler; |
d2d0c44662bb
Truffle: refactored CompilationProfile to separate the profile and the policy in separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
12708
diff
changeset
|
48 private final CompilationProfile compilationProfile; |
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 private final CompilationPolicy compilationPolicy; |
d2d0c44662bb
Truffle: refactored CompilationProfile to separate the profile and the policy in separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
12708
diff
changeset
|
50 private final TruffleInlining inlining; |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
51 private boolean compilationEnabled; |
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
|
52 private int callCount; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 |
13705
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
13703
diff
changeset
|
54 protected OptimizedCallTarget(RootNode rootNode, TruffleCompiler compiler, int invokeCounter, int compilationThreshold) { |
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
13703
diff
changeset
|
55 super(rootNode); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 this.compiler = compiler; |
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
|
57 this.compilationProfile = new CompilationProfile(compilationThreshold, invokeCounter, rootNode.toString()); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 this.rootNode.setCallTarget(this); |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
59 |
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
|
60 if (TruffleUseTimeForCompilationDecision.getValue()) { |
d2d0c44662bb
Truffle: refactored CompilationProfile to separate the profile and the policy in separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
12708
diff
changeset
|
61 compilationPolicy = new TimedCompilationPolicy(); |
d2d0c44662bb
Truffle: refactored CompilationProfile to separate the profile and the policy in separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
12708
diff
changeset
|
62 } else { |
d2d0c44662bb
Truffle: refactored CompilationProfile to separate the profile and the policy in separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
12708
diff
changeset
|
63 compilationPolicy = new DefaultCompilationPolicy(); |
d2d0c44662bb
Truffle: refactored CompilationProfile to separate the profile and the policy in separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
12708
diff
changeset
|
64 } |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
65 this.compilationEnabled = true; |
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
|
66 |
10844
3cf5f371dc9f
Truffle: print inlined call target and rename profiling option.
Andreas Woess <andreas.woess@jku.at>
parents:
10797
diff
changeset
|
67 if (TruffleCallTargetProfiling.getValue()) { |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
68 registerCallTarget(this); |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
69 } |
13703
03b42f0fb635
Truffle: extend inlining interface with custom reprofile counters.
Christian Humer <christian.humer@gmail.com>
parents:
13208
diff
changeset
|
70 this.inlining = new TruffleInliningImpl(); |
03b42f0fb635
Truffle: extend inlining interface with custom reprofile counters.
Christian Humer <christian.humer@gmail.com>
parents:
13208
diff
changeset
|
71 |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 |
13720
4281521dc39a
Truffle: fix non-local control flow using exceptions
Andreas Woess <andreas.woess@jku.at>
parents:
13705
diff
changeset
|
74 @CompilerDirectives.SlowPath |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 @Override |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 public Object call(PackedFrame caller, Arguments args) { |
12534
b34114019fd0
Re-add OptimizedCallTarget.callHelper - prevents frequent reinstallation of frame injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
12531
diff
changeset
|
77 return callHelper(caller, args); |
b34114019fd0
Re-add OptimizedCallTarget.callHelper - prevents frequent reinstallation of frame injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
12531
diff
changeset
|
78 } |
b34114019fd0
Re-add OptimizedCallTarget.callHelper - prevents frequent reinstallation of frame injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
12531
diff
changeset
|
79 |
b34114019fd0
Re-add OptimizedCallTarget.callHelper - prevents frequent reinstallation of frame injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
12531
diff
changeset
|
80 private Object callHelper(PackedFrame caller, Arguments args) { |
12601
48bc171026d1
Merge fixes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12599
diff
changeset
|
81 if (installedCode != null && installedCode.isValid()) { |
12529
23dc5dfdb9c7
Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
12488
diff
changeset
|
82 TruffleRuntime runtime = Truffle.getRuntime(); |
23dc5dfdb9c7
Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
12488
diff
changeset
|
83 if (runtime instanceof GraalTruffleRuntime) { |
13208
66d793d06465
print frame prologue reinstallation message only if TraceTruffleCompilation is enabled.
Andreas Woess <andreas.woess@jku.at>
parents:
12711
diff
changeset
|
84 if (TraceTruffleCompilation.getValue()) { |
66d793d06465
print frame prologue reinstallation message only if TraceTruffleCompilation is enabled.
Andreas Woess <andreas.woess@jku.at>
parents:
12711
diff
changeset
|
85 OUT.println("[truffle] reinstall OptimizedCallTarget.call code with frame prolog shortcut."); |
66d793d06465
print frame prologue reinstallation message only if TraceTruffleCompilation is enabled.
Andreas Woess <andreas.woess@jku.at>
parents:
12711
diff
changeset
|
86 } |
12531
7d5c3ffbee64
Refactoring of the frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
12529
diff
changeset
|
87 GraalTruffleRuntime.installOptimizedCallTargetCallMethod(); |
12529
23dc5dfdb9c7
Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
12488
diff
changeset
|
88 } |
23dc5dfdb9c7
Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
12488
diff
changeset
|
89 } |
10844
3cf5f371dc9f
Truffle: print inlined call target and rename profiling option.
Andreas Woess <andreas.woess@jku.at>
parents:
10797
diff
changeset
|
90 if (TruffleCallTargetProfiling.getValue()) { |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
91 callCount++; |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
92 } |
12591
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
93 if (CompilerDirectives.injectBranchProbability(CompilerDirectives.FASTPATH_PROBABILITY, installedCode != null)) { |
10654
d71c56c67921
Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10643
diff
changeset
|
94 try { |
12591
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
95 return installedCode.execute(this, caller, args); |
10654
d71c56c67921
Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10643
diff
changeset
|
96 } catch (InvalidInstalledCodeException ex) { |
10659
63083745d390
Clean up OptimizedCallTarget and HotSpotNmethod.execute.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10654
diff
changeset
|
97 return compiledCodeInvalidated(caller, args); |
10654
d71c56c67921
Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10643
diff
changeset
|
98 } |
d71c56c67921
Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10643
diff
changeset
|
99 } else { |
d71c56c67921
Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10643
diff
changeset
|
100 return interpreterCall(caller, args); |
d71c56c67921
Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10643
diff
changeset
|
101 } |
d71c56c67921
Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10643
diff
changeset
|
102 } |
d71c56c67921
Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10643
diff
changeset
|
103 |
12711
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
104 public CompilationProfile getCompilationProfile() { |
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
105 return compilationProfile; |
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
106 } |
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
107 |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
108 private Object compiledCodeInvalidated(PackedFrame caller, Arguments args) { |
12591
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
109 invalidate(); |
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
110 return call(caller, args); |
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
111 } |
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
112 |
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
113 private void invalidate() { |
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
114 InstalledCode m = this.installedCode; |
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
115 if (m != null) { |
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
116 CompilerAsserts.neverPartOfCompilation(); |
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
117 installedCode = null; |
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
|
118 compilationProfile.reportInvalidated(); |
12591
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
119 if (TraceTruffleCompilation.getValue()) { |
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
|
120 OUT.printf("[truffle] invalidated %-48s |Inv# %d |Replace# %d\n", rootNode, compilationProfile.getInvalidationCount(), |
d2d0c44662bb
Truffle: refactored CompilationProfile to separate the profile and the policy in separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
12708
diff
changeset
|
121 compilationProfile.getNodeReplaceCount()); |
12591
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
122 } |
10659
63083745d390
Clean up OptimizedCallTarget and HotSpotNmethod.execute.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10654
diff
changeset
|
123 } |
12592
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
124 |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
125 Future<InstalledCode> task = this.installedCodeTask; |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
126 if (task != null) { |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
127 task.cancel(true); |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
128 this.installedCodeTask = null; |
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
|
129 compilationProfile.reportInvalidated(); |
12592
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
130 } |
10659
63083745d390
Clean up OptimizedCallTarget and HotSpotNmethod.execute.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10654
diff
changeset
|
131 } |
63083745d390
Clean up OptimizedCallTarget and HotSpotNmethod.execute.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10654
diff
changeset
|
132 |
10654
d71c56c67921
Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10643
diff
changeset
|
133 private Object interpreterCall(PackedFrame caller, Arguments args) { |
10857
94cf5df0727f
Backout changeset 4c12d3756015; ensure compiledCodeInvalidated() is never inlined.
Andreas Woess <andreas.woess@jku.at>
parents:
10844
diff
changeset
|
134 CompilerAsserts.neverPartOfCompilation(); |
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
|
135 compilationProfile.reportInterpreterCall(); |
12711
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
136 if (compilationEnabled && shouldCompile()) { |
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
137 if (isCompiling()) { |
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
138 return waitForCompilation(caller, args); |
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
139 } |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
140 boolean inlined = shouldInline() && inline(); |
12711
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
141 if (!inlined) { |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
142 compile(); |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
143 } |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
144 } |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
145 return executeHelper(caller, args); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
146 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
147 |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
148 private boolean shouldCompile() { |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
149 return compilationPolicy.shouldCompile(compilationProfile); |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
150 } |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
151 |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
152 private static boolean shouldInline() { |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
153 return TruffleFunctionInlining.getValue(); |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
154 } |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
155 |
12711
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
156 private boolean isCompiling() { |
12592
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
157 if (installedCodeTask != null) { |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
158 if (installedCodeTask.isCancelled()) { |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
159 installedCodeTask = null; |
12711
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
160 return false; |
12592
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
161 } |
12711
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
162 return true; |
12592
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
163 } |
12711
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
164 return false; |
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
165 } |
12592
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
166 |
12711
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
167 public void compile() { |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
168 this.installedCodeTask = compiler.compile(this); |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
169 if (!TruffleBackgroundCompilation.getValue()) { |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
170 installedCode = receiveInstalledCode(); |
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
|
171 } |
8c570011b86f
Truffle: when a node is replaced, notify optimized call target and delay compilation.
Andreas Woess <andreas.woess@jku.at>
parents:
10858
diff
changeset
|
172 } |
8c570011b86f
Truffle: when a node is replaced, notify optimized call target and delay compilation.
Andreas Woess <andreas.woess@jku.at>
parents:
10858
diff
changeset
|
173 |
12711
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
174 private Object waitForCompilation(PackedFrame caller, Arguments args) { |
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
175 if (installedCodeTask.isDone()) { |
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
176 installedCode = receiveInstalledCode(); |
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
177 } |
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
178 return executeHelper(caller, args); |
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
179 } |
fb4658e16b5d
Truffle: some regression fixes to previous cleanup
Christian Humer <christian.humer@gmail.com>
parents:
12710
diff
changeset
|
180 |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
181 private InstalledCode receiveInstalledCode() { |
12592
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
182 try { |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
183 return installedCodeTask.get(); |
12592
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
184 } catch (InterruptedException | ExecutionException e) { |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
185 compilationEnabled = false; |
12592
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
186 OUT.printf("[truffle] opt failed %-48s %s\n", rootNode, e.getMessage()); |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
187 if (e.getCause() instanceof BailoutException) { |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
188 // Bailout => move on. |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
189 } else { |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
190 if (TraceTruffleCompilationExceptions.getValue()) { |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
191 e.printStackTrace(OUT); |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
192 } |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
193 if (TruffleCompilationExceptionsAreFatal.getValue()) { |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
194 System.exit(-1); |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
195 } |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
196 } |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
197 return null; |
12592
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
198 } |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
199 } |
42c8f76a98bf
Move Truffle compilations to background compilation thread.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12591
diff
changeset
|
200 |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
201 /** |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
202 * Forces inlining whether or not function inlining is enabled. |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
203 * |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
204 * @return true if an inlining was performed |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
205 */ |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
206 public boolean inline() { |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
207 boolean result = inlining.performInlining(this); |
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
208 if (result) { |
13703
03b42f0fb635
Truffle: extend inlining interface with custom reprofile counters.
Christian Humer <christian.humer@gmail.com>
parents:
13208
diff
changeset
|
209 compilationProfile.reportInliningPerformed(inlining); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
210 } |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
211 return result; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
212 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
214 public Object executeHelper(PackedFrame caller, Arguments args) { |
13705
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
13703
diff
changeset
|
215 VirtualFrame frame = createFrame(rootNode.getFrameDescriptor(), caller, args); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
216 return rootNode.execute(frame); |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
217 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 |
11934
dca16d6f9d65
TruffleRuntime.createVirtualFrame.
Chris Seaton <chris.seaton@oracle.com>
parents:
11722
diff
changeset
|
219 protected static FrameWithoutBoxing createFrame(FrameDescriptor descriptor, PackedFrame caller, Arguments args) { |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 return new FrameWithoutBoxing(descriptor, caller, args); |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
221 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
222 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
223 @Override |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
224 public VirtualFrame create(FrameDescriptor descriptor, PackedFrame caller, Arguments args) { |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
225 return createFrame(descriptor, caller, args); |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
226 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
227 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
228 @Override |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
229 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
|
230 compilationProfile.reportLoopCount(count); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
231 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
232 |
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
|
233 @Override |
8c570011b86f
Truffle: when a node is replaced, notify optimized call target and delay compilation.
Andreas Woess <andreas.woess@jku.at>
parents:
10858
diff
changeset
|
234 public void nodeReplaced() { |
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
|
235 compilationProfile.reportNodeReplaced(); |
12591
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
236 invalidate(); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
237 } |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
238 |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
239 private static void printProfiling() { |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
240 List<OptimizedCallTarget> sortedCallTargets = new ArrayList<>(OptimizedCallTarget.callTargets.keySet()); |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
241 Collections.sort(sortedCallTargets, new Comparator<OptimizedCallTarget>() { |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
242 |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
243 @Override |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
244 public int compare(OptimizedCallTarget o1, OptimizedCallTarget o2) { |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
245 return o2.callCount - o1.callCount; |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
246 } |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
247 }); |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
248 |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
249 int totalCallCount = 0; |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
250 int totalInlinedCallSiteCount = 0; |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
251 int totalNotInlinedCallSiteCount = 0; |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
252 int totalNodeCount = 0; |
10858
f2008a93ad54
Truffle: add invalidation count to call target profiling / trace compilation.
Andreas Woess <andreas.woess@jku.at>
parents:
10857
diff
changeset
|
253 int totalInvalidationCount = 0; |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
254 |
10794
3fe325c3f31c
Truffle: add InlinedCallSite interface and an InlinableCallSite method to query the inlined call target
Andreas Woess <andreas.woess@jku.at>
parents:
10752
diff
changeset
|
255 OUT.println(); |
10858
f2008a93ad54
Truffle: add invalidation count to call target profiling / trace compilation.
Andreas Woess <andreas.woess@jku.at>
parents:
10857
diff
changeset
|
256 OUT.printf("%-50s | %-10s | %s / %s | %s | %s\n", "Call Target", "Call Count", "Calls Sites Inlined", "Not Inlined", "Node Count", "Inv"); |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
257 for (OptimizedCallTarget callTarget : sortedCallTargets) { |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
258 if (callTarget.callCount == 0) { |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
259 continue; |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
260 } |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
261 |
12708
85bab2227295
Truffle: refactored inlining to a new class.
Christian Humer <christian.humer@gmail.com>
parents:
12601
diff
changeset
|
262 int notInlinedCallSiteCount = TruffleInliningImpl.getInlinableCallSites(callTarget).size(); |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
263 int nodeCount = NodeUtil.countNodes(callTarget.rootNode); |
13803
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13720
diff
changeset
|
264 int inlinedCallSiteCount = countInlinedNodes(callTarget.rootNode); |
12591
33fe56e68abd
Simplifications of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
12405
diff
changeset
|
265 String comment = callTarget.installedCode == null ? " int" : ""; |
12710
60142b15ed42
Truffle: fixed bug where invocation counter was decremented twice after inlining; cleanup of optimized call target and profile.
Christian Humer <christian.humer@gmail.com>
parents:
12709
diff
changeset
|
266 comment += callTarget.compilationEnabled ? "" : " fail"; |
10858
f2008a93ad54
Truffle: add invalidation count to call target profiling / trace compilation.
Andreas Woess <andreas.woess@jku.at>
parents:
10857
diff
changeset
|
267 OUT.printf("%-50s | %10d | %15d | %15d | %10d | %3d%s\n", callTarget.getRootNode(), callTarget.callCount, inlinedCallSiteCount, notInlinedCallSiteCount, nodeCount, |
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
|
268 callTarget.getCompilationProfile().getInvalidationCount(), comment); |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
269 |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
270 totalCallCount += callTarget.callCount; |
10794
3fe325c3f31c
Truffle: add InlinedCallSite interface and an InlinableCallSite method to query the inlined call target
Andreas Woess <andreas.woess@jku.at>
parents:
10752
diff
changeset
|
271 totalInlinedCallSiteCount += inlinedCallSiteCount; |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
272 totalNotInlinedCallSiteCount += notInlinedCallSiteCount; |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
273 totalNodeCount += nodeCount; |
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 totalInvalidationCount += callTarget.getCompilationProfile().getInvalidationCount(); |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
275 } |
10858
f2008a93ad54
Truffle: add invalidation count to call target profiling / trace compilation.
Andreas Woess <andreas.woess@jku.at>
parents:
10857
diff
changeset
|
276 OUT.printf("%-50s | %10d | %15d | %15d | %10d | %3d\n", "Total", totalCallCount, totalInlinedCallSiteCount, totalNotInlinedCallSiteCount, totalNodeCount, totalInvalidationCount); |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
277 } |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
278 |
13803
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13720
diff
changeset
|
279 private static int countInlinedNodes(Node rootNode) { |
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13720
diff
changeset
|
280 List<CallNode> callers = NodeUtil.findAllNodeInstances(rootNode, CallNode.class); |
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13720
diff
changeset
|
281 int count = 0; |
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13720
diff
changeset
|
282 for (CallNode callNode : callers) { |
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13720
diff
changeset
|
283 if (callNode.isInlined()) { |
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13720
diff
changeset
|
284 count++; |
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13720
diff
changeset
|
285 } |
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13720
diff
changeset
|
286 } |
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13720
diff
changeset
|
287 return count; |
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13720
diff
changeset
|
288 } |
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13720
diff
changeset
|
289 |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
290 private static void registerCallTarget(OptimizedCallTarget callTarget) { |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
291 callTargets.put(callTarget, 0); |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
292 } |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
293 |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
294 private static Map<OptimizedCallTarget, Integer> callTargets; |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
295 static { |
10844
3cf5f371dc9f
Truffle: print inlined call target and rename profiling option.
Andreas Woess <andreas.woess@jku.at>
parents:
10797
diff
changeset
|
296 if (TruffleCallTargetProfiling.getValue()) { |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
297 callTargets = new WeakHashMap<>(); |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
298 |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
299 Runtime.getRuntime().addShutdownHook(new Thread() { |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
300 |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
301 @Override |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
302 public void run() { |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
303 printProfiling(); |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
304 } |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
305 }); |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
306 } |
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
307 } |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
308 } |