Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java @ 23380:d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Thu, 04 Feb 2016 14:14:16 +0100 |
parents | 90de09b99c79 |
children |
rev | line source |
---|---|
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
17422
89f801a9b4d4
Truffle: fix headers.
Christian Humer <christian.humer@gmail.com>
parents:
17420
diff
changeset
|
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.truffle; |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
22646
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
25 import static com.oracle.graal.truffle.TruffleCompilerOptions.TruffleArgumentTypeSpeculation; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
26 import static com.oracle.graal.truffle.TruffleCompilerOptions.TruffleBackgroundCompilation; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
27 import static com.oracle.graal.truffle.TruffleCompilerOptions.TruffleCallTargetProfiling; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
28 import static com.oracle.graal.truffle.TruffleCompilerOptions.TruffleCompilationExceptionsAreFatal; |
22705 | 29 import static com.oracle.graal.truffle.TruffleCompilerOptions.TruffleCompilationExceptionsArePrinted; |
22646
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
30 import static com.oracle.graal.truffle.TruffleCompilerOptions.TruffleCompilationExceptionsAreThrown; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
31 import static com.oracle.graal.truffle.TruffleCompilerOptions.TruffleReturnTypeSpeculation; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 |
22646
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
33 import java.io.PrintWriter; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
34 import java.io.StringWriter; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
35 import java.lang.reflect.Method; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
36 import java.util.ArrayList; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
37 import java.util.HashMap; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
38 import java.util.Iterator; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
39 import java.util.LinkedHashMap; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
40 import java.util.List; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
41 import java.util.Map; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
42 import java.util.Spliterators; |
23380
d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
Andreas Woess <andreas.woess@oracle.com>
parents:
23190
diff
changeset
|
43 import java.util.concurrent.Future; |
22646
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
44 import java.util.concurrent.atomic.AtomicInteger; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
45 import java.util.stream.Stream; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
46 import java.util.stream.StreamSupport; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 |
22790
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22705
diff
changeset
|
48 import jdk.vm.ci.code.BailoutException; |
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22705
diff
changeset
|
49 import jdk.vm.ci.code.InstalledCode; |
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22705
diff
changeset
|
50 import jdk.vm.ci.common.JVMCIError; |
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22705
diff
changeset
|
51 import jdk.vm.ci.meta.SpeculationLog; |
22054 | 52 |
22646
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
53 import com.oracle.graal.truffle.debug.AbstractDebugCompilationListener; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
54 import com.oracle.truffle.api.Assumption; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
55 import com.oracle.truffle.api.CompilerAsserts; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
56 import com.oracle.truffle.api.CompilerDirectives; |
15216
d59f48be0ed6
Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15215
diff
changeset
|
57 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; |
22646
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
58 import com.oracle.truffle.api.CompilerOptions; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
59 import com.oracle.truffle.api.LoopCountReceiver; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
60 import com.oracle.truffle.api.OptimizationFailedException; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
61 import com.oracle.truffle.api.ReplaceObserver; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
62 import com.oracle.truffle.api.RootCallTarget; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
63 import com.oracle.truffle.api.Truffle; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
64 import com.oracle.truffle.api.frame.FrameDescriptor; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
65 import com.oracle.truffle.api.frame.VirtualFrame; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
66 import com.oracle.truffle.api.impl.DefaultCompilerOptions; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
67 import com.oracle.truffle.api.nodes.ExplodeLoop; |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
68 import com.oracle.truffle.api.nodes.Node; |
22646
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
69 import com.oracle.truffle.api.nodes.NodeUtil; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
70 import com.oracle.truffle.api.nodes.NodeVisitor; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
71 import com.oracle.truffle.api.nodes.RootNode; |
23190
90de09b99c79
Implement TruffleRuntime#isProfilingEnabled; Add flag to enable/disable Truffle profiling in GraalTruffleRuntime (-G:-TruffleProfilingEnabled).
Christian Humer <christian.humer@oracle.com>
parents:
23139
diff
changeset
|
72 import com.oracle.truffle.api.profiles.ValueProfile; |
22646
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22466
diff
changeset
|
73 import com.oracle.truffle.api.utilities.CyclicAssumption; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 /** |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 * 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
|
77 */ |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
78 public class OptimizedCallTarget extends InstalledCode implements RootCallTarget, LoopCountReceiver, ReplaceObserver { |
22925
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
79 private static final RootNode UNINITIALIZED = RootNode.createConstantNode(null); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
81 protected final GraalTruffleRuntime runtime; |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
82 private SpeculationLog speculationLog; |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
83 protected final CompilationProfile compilationProfile; |
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
84 protected final CompilationPolicy compilationPolicy; |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
85 private final OptimizedCallTarget sourceCallTarget; |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
86 private final AtomicInteger callSitesKnown = new AtomicInteger(0); |
19750
2a21ea0ec141
Profile exceptions on OptimizeCallTarget#doInvoke.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19710
diff
changeset
|
87 private final ValueProfile exceptionProfile = ValueProfile.createClassProfile(); |
18276
1f3ab088d958
Truffle: implemented defer compilation.
Christian Humer <christian.humer@gmail.com>
parents:
18275
diff
changeset
|
88 |
15231
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
89 @CompilationFinal private Class<?>[] profiledArgumentTypes; |
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
90 @CompilationFinal private Assumption profiledArgumentTypesAssumption; |
15216
d59f48be0ed6
Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15215
diff
changeset
|
91 @CompilationFinal private Class<?> profiledReturnType; |
d59f48be0ed6
Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15215
diff
changeset
|
92 @CompilationFinal private Assumption profiledReturnTypeAssumption; |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
93 |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
94 private final RootNode rootNode; |
22925
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
95 private volatile RootNode uninitializedRootNode = UNINITIALIZED; |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
96 |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
97 /* Experimental fields for new splitting. */ |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
98 private final Map<TruffleStamp, OptimizedCallTarget> splitVersions = new HashMap<>(); |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
99 private TruffleStamp argumentStamp = DefaultTruffleStamp.getInstance(); |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
100 |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
101 private TruffleInlining inlining; |
19766
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
102 private int cachedNonTrivialNodeCount = -1; |
22925
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
103 private int cloneIndex; |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
104 |
17600
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
105 /** |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
106 * When this call target is inlined, the inlining {@link InstalledCode} registers this |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
107 * assumption. It gets invalidated when a node rewriting is performed. This ensures that all |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
108 * compiled methods that have this call target inlined are properly invalidated. |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
109 */ |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
110 private final CyclicAssumption nodeRewritingAssumption; |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
111 |
23380
d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
Andreas Woess <andreas.woess@oracle.com>
parents:
23190
diff
changeset
|
112 private volatile Future<?> compilationTask; |
d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
Andreas Woess <andreas.woess@oracle.com>
parents:
23190
diff
changeset
|
113 |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
114 public final RootNode getRootNode() { |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
115 return rootNode; |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
116 } |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
117 |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
118 public OptimizedCallTarget(OptimizedCallTarget sourceCallTarget, RootNode rootNode, GraalTruffleRuntime runtime, CompilationPolicy compilationPolicy, SpeculationLog speculationLog) { |
16401
347915b8cea8
Move name from HotSpotNmethod to InstalledCode to have a name again for truffle nmethods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16044
diff
changeset
|
119 super(rootNode.toString()); |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
120 this.sourceCallTarget = sourceCallTarget; |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
121 this.runtime = runtime; |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
122 this.speculationLog = speculationLog; |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
123 this.rootNode = rootNode; |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
124 this.compilationPolicy = compilationPolicy; |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
125 this.rootNode.adoptChildren(); |
18485
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
126 this.rootNode.applyInstrumentation(); |
10844
3cf5f371dc9f
Truffle: print inlined call target and rename profiling option.
Andreas Woess <andreas.woess@jku.at>
parents:
10797
diff
changeset
|
127 if (TruffleCallTargetProfiling.getValue()) { |
17420
e98150919577
Truffle: cleanup compilation profile fields.
Christian Humer <christian.humer@gmail.com>
parents:
17404
diff
changeset
|
128 this.compilationProfile = new TraceCompilationProfile(); |
17404
b725292b8a11
Truffle: updated TruffleCallTargetProfiling
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
129 } else { |
17420
e98150919577
Truffle: cleanup compilation profile fields.
Christian Humer <christian.humer@gmail.com>
parents:
17404
diff
changeset
|
130 this.compilationProfile = new CompilationProfile(); |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
131 } |
17600
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
132 this.nodeRewritingAssumption = new CyclicAssumption("nodeRewritingAssumption of " + rootNode.toString()); |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
133 } |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
134 |
21934
c493ec4605e9
Truffle: direct all log output to GraalTruffleRuntime#log
Christian Humer <christian.humer@gmail.com>
parents:
21629
diff
changeset
|
135 public final void log(String message) { |
c493ec4605e9
Truffle: direct all log output to GraalTruffleRuntime#log
Christian Humer <christian.humer@gmail.com>
parents:
21629
diff
changeset
|
136 runtime.log(message); |
c493ec4605e9
Truffle: direct all log output to GraalTruffleRuntime#log
Christian Humer <christian.humer@gmail.com>
parents:
21629
diff
changeset
|
137 } |
c493ec4605e9
Truffle: direct all log output to GraalTruffleRuntime#log
Christian Humer <christian.humer@gmail.com>
parents:
21629
diff
changeset
|
138 |
20095
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
139 public final boolean isCompiling() { |
23380
d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
Andreas Woess <andreas.woess@oracle.com>
parents:
23190
diff
changeset
|
140 return getCompilationTask() != null; |
20095
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
141 } |
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
142 |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
143 private static RootNode cloneRootNode(RootNode root) { |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
144 if (root == null || !root.isCloningAllowed()) { |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
145 return null; |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
146 } |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
147 return NodeUtil.cloneNode(root); |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
148 } |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
149 |
17600
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
150 public Assumption getNodeRewritingAssumption() { |
6388d789b1d0
Invalidate all compiled methods that have a call target inlined on tree rewriting.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17598
diff
changeset
|
151 return nodeRewritingAssumption.getAssumption(); |
13984
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
152 } |
13703
03b42f0fb635
Truffle: extend inlining interface with custom reprofile counters.
Christian Humer <christian.humer@gmail.com>
parents:
13208
diff
changeset
|
153 |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
154 public final void mergeArgumentStamp(TruffleStamp p) { |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
155 this.argumentStamp = this.argumentStamp.join(p); |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
156 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
157 |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
158 public final TruffleStamp getArgumentStamp() { |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
159 return argumentStamp; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
160 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
161 |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
162 public int getCloneIndex() { |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
163 return cloneIndex; |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
164 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
165 |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
166 public OptimizedCallTarget cloneUninitialized() { |
22925
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
167 ensureCloned(); |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
168 RootNode copiedRoot = cloneRootNode(uninitializedRootNode); |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
169 if (copiedRoot == null) { |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
170 return null; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
171 } |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
172 OptimizedCallTarget splitTarget = (OptimizedCallTarget) runtime.createClonedCallTarget(this, copiedRoot); |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
173 splitTarget.cloneIndex = cloneIndex++; |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
174 return splitTarget; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
175 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
176 |
22925
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
177 private void ensureCloned() { |
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
178 if (uninitializedRootNode == UNINITIALIZED) { |
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
179 synchronized (this) { |
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
180 if (uninitializedRootNode == UNINITIALIZED) { |
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
181 this.uninitializedRootNode = sourceCallTarget == null ? cloneRootNode(rootNode) : sourceCallTarget.uninitializedRootNode; |
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
182 } |
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
183 } |
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
184 } |
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
185 } |
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
186 |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
187 public Map<TruffleStamp, OptimizedCallTarget> getSplitVersions() { |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
188 return splitVersions; |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
189 } |
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
190 |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
191 public SpeculationLog getSpeculationLog() { |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
192 return speculationLog; |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
193 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
194 |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
195 @Override |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
196 public Object call(Object... args) { |
17404
b725292b8a11
Truffle: updated TruffleCallTargetProfiling
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
197 compilationProfile.reportIndirectCall(); |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
198 if (profiledArgumentTypesAssumption != null && profiledArgumentTypesAssumption.isValid()) { |
23139
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
199 // Argument profiling is not possible for targets of indirect calls. |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
200 CompilerDirectives.transferToInterpreterAndInvalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
201 profiledArgumentTypesAssumption.invalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
202 profiledArgumentTypes = null; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
203 } |
17191
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
204 return doInvoke(args); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
205 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
206 |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
207 public final Object callDirect(Object... args) { |
17404
b725292b8a11
Truffle: updated TruffleCallTargetProfiling
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
208 compilationProfile.reportDirectCall(); |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
209 profileArguments(args); |
20882
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
210 try { |
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
211 Object result = doInvoke(args); |
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
212 Class<?> klass = profiledReturnType; |
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
213 if (klass != null && CompilerDirectives.inCompiledCode() && profiledReturnTypeAssumption.isValid()) { |
22814
42c3911e6993
Truffle: make unsafe methods private
Andreas Woess <andreas.woess@oracle.com>
parents:
22790
diff
changeset
|
214 result = unsafeCast(result, klass, true, true); |
20882
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
215 } |
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
216 return result; |
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
217 } catch (Throwable t) { |
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
218 t = exceptionProfile.profile(t); |
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
219 if (t instanceof RuntimeException) { |
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
220 throw (RuntimeException) t; |
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
221 } else if (t instanceof Error) { |
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
222 throw (Error) t; |
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
223 } else { |
22052
1489392b6469
Truffle: Stop bytecode parsing on a call to CompilerAsserts.neverPartOfCompilation()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
21986
diff
changeset
|
224 CompilerDirectives.transferToInterpreter(); |
20882
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
225 throw new RuntimeException(t); |
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
226 } |
15224
735147ef0176
Truffle: Move direct call logic from call site to optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15222
diff
changeset
|
227 } |
735147ef0176
Truffle: Move direct call logic from call site to optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15222
diff
changeset
|
228 } |
735147ef0176
Truffle: Move direct call logic from call site to optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15222
diff
changeset
|
229 |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
230 public final Object callInlined(Object... arguments) { |
17404
b725292b8a11
Truffle: updated TruffleCallTargetProfiling
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
231 compilationProfile.reportInlinedCall(); |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
232 VirtualFrame frame = createFrame(getRootNode().getFrameDescriptor(), arguments); |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
233 return callProxy(frame); |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
234 } |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
235 |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
236 @ExplodeLoop |
20095
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
237 void profileArguments(Object[] args) { |
23139
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
238 Assumption typesAssumption = profiledArgumentTypesAssumption; |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
239 if (typesAssumption == null) { |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
240 CompilerDirectives.transferToInterpreterAndInvalidate(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
241 initializeProfiledArgumentTypes(args); |
23139
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
242 } else { |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
243 Class<?>[] types = profiledArgumentTypes; |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
244 if (types != null) { |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
245 if (types.length != args.length) { |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
246 CompilerDirectives.transferToInterpreterAndInvalidate(); |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
247 typesAssumption.invalidate(); |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
248 profiledArgumentTypes = null; |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
249 } else if (typesAssumption.isValid()) { |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
250 for (int i = 0; i < types.length; i++) { |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
251 Class<?> type = types[i]; |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
252 Object value = args[i]; |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
253 if (type != null && (value == null || value.getClass() != type)) { |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
254 CompilerDirectives.transferToInterpreterAndInvalidate(); |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
255 updateProfiledArgumentTypes(args, types); |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
256 break; |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
257 } |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
258 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
259 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
260 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
261 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
262 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
263 |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
264 private void initializeProfiledArgumentTypes(Object[] args) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
265 CompilerAsserts.neverPartOfCompilation(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
266 profiledArgumentTypesAssumption = Truffle.getRuntime().createAssumption("Profiled Argument Types"); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
267 if (TruffleArgumentTypeSpeculation.getValue()) { |
23139
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
268 Class<?>[] result = new Class<?>[args.length]; |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
269 for (int i = 0; i < args.length; i++) { |
23139
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
270 result[i] = classOf(args[i]); |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
271 } |
23139
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
272 |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
273 profiledArgumentTypes = result; |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
274 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
275 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
276 |
23139
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
277 private void updateProfiledArgumentTypes(Object[] args, Class<?>[] types) { |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
278 CompilerAsserts.neverPartOfCompilation(); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
279 profiledArgumentTypesAssumption.invalidate(); |
23139
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
280 for (int j = 0; j < types.length; j++) { |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
281 types[j] = joinTypes(types[j], classOf(args[j])); |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
282 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
283 profiledArgumentTypesAssumption = Truffle.getRuntime().createAssumption("Profiled Argument Types"); |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
284 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
285 |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
286 private static Class<?> classOf(Object arg) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
287 return arg != null ? arg.getClass() : null; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
288 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
289 |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
290 private static Class<?> joinTypes(Class<?> class1, Class<?> class2) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
291 if (class1 == class2) { |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
292 return class1; |
23139
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
293 } else { |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
294 return null; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
295 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
296 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
297 |
17191
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
298 protected Object doInvoke(Object[] args) { |
20882
e0b3dc6b025c
Truffle: profile exception type only for direct calls
Andreas Woess <andreas.woess@oracle.com>
parents:
20132
diff
changeset
|
299 return callBoundary(args); |
17191
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
300 } |
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
301 |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
302 @TruffleCallBoundary |
17191
be733832464d
Allow subclasses to intercept Truffle call boundaries
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17152
diff
changeset
|
303 protected final Object callBoundary(Object[] args) { |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
304 if (CompilerDirectives.inInterpreter()) { |
15215
ca250afc78ec
Simplification of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15212
diff
changeset
|
305 // We are called and we are still in Truffle interpreter mode. |
ca250afc78ec
Simplification of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15212
diff
changeset
|
306 interpreterCall(); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
307 } else { |
18276
1f3ab088d958
Truffle: implemented defer compilation.
Christian Humer <christian.humer@gmail.com>
parents:
18275
diff
changeset
|
308 // We come here from compiled code |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
309 } |
15216
d59f48be0ed6
Truffle: Speculate on the return type of calls.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15215
diff
changeset
|
310 |
17427
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
311 return callRoot(args); |
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
312 } |
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
313 |
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
314 public final Object callRoot(Object[] originalArguments) { |
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
315 Object[] args = originalArguments; |
23139
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
316 if (CompilerDirectives.inCompiledCode()) { |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
317 Assumption argumentTypesAssumption = this.profiledArgumentTypesAssumption; |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
318 if (argumentTypesAssumption != null && argumentTypesAssumption.isValid()) { |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
319 args = unsafeCast(castArrayFixedLength(args, profiledArgumentTypes.length), Object[].class, true, true); |
17427
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
320 args = castArguments(args); |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
321 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
322 } |
17427
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
323 |
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
324 VirtualFrame frame = createFrame(getRootNode().getFrameDescriptor(), args); |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
325 Object result = callProxy(frame); |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
326 |
20095
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
327 profileReturnType(result); |
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
328 |
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
329 return result; |
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
330 } |
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
331 |
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
332 void profileReturnType(Object result) { |
23139
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
333 Assumption returnTypeAssumption = profiledReturnTypeAssumption; |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
334 if (returnTypeAssumption == null) { |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
335 if (TruffleReturnTypeSpeculation.getValue()) { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
336 CompilerDirectives.transferToInterpreterAndInvalidate(); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
337 profiledReturnType = (result == null ? null : result.getClass()); |
17427
307b26f8b5d1
Truffle: fixed inlining performance regression.
Christian Humer <christian.humer@gmail.com>
parents:
17426
diff
changeset
|
338 profiledReturnTypeAssumption = Truffle.getRuntime().createAssumption("Profiled Return Type"); |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
339 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
340 } else if (profiledReturnType != null) { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
341 if (result == null || profiledReturnType != result.getClass()) { |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
342 CompilerDirectives.transferToInterpreterAndInvalidate(); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
343 profiledReturnType = null; |
23139
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
344 returnTypeAssumption.invalidate(); |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
345 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
346 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
347 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
348 |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
349 @Override |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
350 public void invalidate() { |
18199
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
351 invalidate(null, null); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
352 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
353 |
18798
f1e7e4f6d833
Truffle: improve invalidation messages for assumptions.
Christian Humer <christian.humer@gmail.com>
parents:
18485
diff
changeset
|
354 protected void invalidate(Object source, CharSequence reason) { |
18210
84e270aa1f47
Truffle: fixed invalidations were printed multiple times.
Christian Humer <christian.humer@gmail.com>
parents:
18206
diff
changeset
|
355 if (isValid()) { |
84e270aa1f47
Truffle: fixed invalidations were printed multiple times.
Christian Humer <christian.humer@gmail.com>
parents:
18206
diff
changeset
|
356 this.runtime.invalidateInstalledCode(this, source, reason); |
84e270aa1f47
Truffle: fixed invalidations were printed multiple times.
Christian Humer <christian.humer@gmail.com>
parents:
18206
diff
changeset
|
357 } |
19766
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
358 cachedNonTrivialNodeCount = -1; |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
359 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
360 |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
361 public TruffleInlining getInlining() { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
362 return inlining; |
16044
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
363 } |
2662fb9c37e2
Truffle: invalidate inlining decisions on rewrites.
Christian Humer <christian.humer@gmail.com>
parents:
15396
diff
changeset
|
364 |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
365 public void setInlining(TruffleInlining inliningDecision) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
366 this.inlining = inliningDecision; |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
367 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
368 |
18200
62de94d5cf73
Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
18199
diff
changeset
|
369 private boolean cancelInstalledTask(Node source, CharSequence reason) { |
62de94d5cf73
Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
18199
diff
changeset
|
370 return this.runtime.cancelInstalledTask(this, source, reason); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
371 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
372 |
15215
ca250afc78ec
Simplification of OptimizedCallTarget.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15212
diff
changeset
|
373 private void interpreterCall() { |
18386
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
374 if (isValid()) { |
15222
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
375 // Stubs were deoptimized => reinstall. |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
376 this.runtime.reinstallStubs(); |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
377 } else { |
22925
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
378 if (uninitializedRootNode == UNINITIALIZED) { |
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
379 ensureCloned(); |
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
380 } |
15222
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
381 compilationProfile.reportInterpreterCall(); |
20095
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
382 if (!isCompiling() && compilationPolicy.shouldCompile(compilationProfile, getCompilerOptions())) { |
15222
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
383 compile(); |
58d2c5bdb9cd
Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15216
diff
changeset
|
384 } |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
385 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
386 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
387 |
22684
f36a430db1c2
Make method final to improve code that has a MethodHandle to it
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22466
diff
changeset
|
388 public final void compile() { |
20095
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
389 if (!isCompiling()) { |
22925
7e4d254d6ff6
Truffle: lazily clone uninitialized root node
Andreas Woess <andreas.woess@oracle.com>
parents:
22815
diff
changeset
|
390 ensureCloned(); |
20095
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
391 runtime.compile(this, TruffleBackgroundCompilation.getValue() && !TruffleCompilationExceptionsAreThrown.getValue()); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
392 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
393 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
394 |
18198
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
395 public void notifyCompilationFailed(Throwable t) { |
19875
f803f49c9ec4
Truffle: fixed TruffleCompilationExceptionsAreThrown was ignored for non permanent bailouts.
Christian Humer <christian.humer@oracle.com>
parents:
19766
diff
changeset
|
396 if (t instanceof BailoutException && !((BailoutException) t).isPermanent()) { |
f803f49c9ec4
Truffle: fixed TruffleCompilationExceptionsAreThrown was ignored for non permanent bailouts.
Christian Humer <christian.humer@oracle.com>
parents:
19766
diff
changeset
|
397 /* |
f803f49c9ec4
Truffle: fixed TruffleCompilationExceptionsAreThrown was ignored for non permanent bailouts.
Christian Humer <christian.humer@oracle.com>
parents:
19766
diff
changeset
|
398 * Non permanent bailouts are expected cases. A non permanent bailout would be for |
f803f49c9ec4
Truffle: fixed TruffleCompilationExceptionsAreThrown was ignored for non permanent bailouts.
Christian Humer <christian.humer@oracle.com>
parents:
19766
diff
changeset
|
399 * example class redefinition during code installation. As opposed to permanent |
f803f49c9ec4
Truffle: fixed TruffleCompilationExceptionsAreThrown was ignored for non permanent bailouts.
Christian Humer <christian.humer@oracle.com>
parents:
19766
diff
changeset
|
400 * bailouts, non permanent bailouts will trigger recompilation and are not considered a |
f803f49c9ec4
Truffle: fixed TruffleCompilationExceptionsAreThrown was ignored for non permanent bailouts.
Christian Humer <christian.humer@oracle.com>
parents:
19766
diff
changeset
|
401 * failure state. |
f803f49c9ec4
Truffle: fixed TruffleCompilationExceptionsAreThrown was ignored for non permanent bailouts.
Christian Humer <christian.humer@oracle.com>
parents:
19766
diff
changeset
|
402 */ |
f803f49c9ec4
Truffle: fixed TruffleCompilationExceptionsAreThrown was ignored for non permanent bailouts.
Christian Humer <christian.humer@oracle.com>
parents:
19766
diff
changeset
|
403 } else { |
18198
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
404 compilationPolicy.recordCompilationFailure(t); |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
405 if (TruffleCompilationExceptionsAreThrown.getValue()) { |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
406 throw new OptimizationFailedException(t, this); |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
407 } |
22703
d5793a653996
Add new option TruffleCompilationExceptionsArePrinted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22684
diff
changeset
|
408 if (TruffleCompilationExceptionsArePrinted.getValue() || TruffleCompilationExceptionsAreFatal.getValue()) { |
21986
bd29bc210e33
Truffle: remove use of TTY print stream in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
21934
diff
changeset
|
409 printException(t); |
22703
d5793a653996
Add new option TruffleCompilationExceptionsArePrinted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22684
diff
changeset
|
410 if (TruffleCompilationExceptionsAreFatal.getValue()) { |
d5793a653996
Add new option TruffleCompilationExceptionsArePrinted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22684
diff
changeset
|
411 System.exit(-1); |
d5793a653996
Add new option TruffleCompilationExceptionsArePrinted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22684
diff
changeset
|
412 } |
19875
f803f49c9ec4
Truffle: fixed TruffleCompilationExceptionsAreThrown was ignored for non permanent bailouts.
Christian Humer <christian.humer@oracle.com>
parents:
19766
diff
changeset
|
413 } |
18198
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
414 } |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
415 } |
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
416 |
21986
bd29bc210e33
Truffle: remove use of TTY print stream in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
21934
diff
changeset
|
417 private void printException(Throwable e) { |
bd29bc210e33
Truffle: remove use of TTY print stream in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
21934
diff
changeset
|
418 StringWriter string = new StringWriter(); |
bd29bc210e33
Truffle: remove use of TTY print stream in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
21934
diff
changeset
|
419 e.printStackTrace(new PrintWriter(string)); |
bd29bc210e33
Truffle: remove use of TTY print stream in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
21934
diff
changeset
|
420 log(string.toString()); |
bd29bc210e33
Truffle: remove use of TTY print stream in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
21934
diff
changeset
|
421 } |
bd29bc210e33
Truffle: remove use of TTY print stream in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
21934
diff
changeset
|
422 |
20095
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
423 public void notifyCompilationFinished(boolean successful) { |
c7c799f40c1e
Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents:
19978
diff
changeset
|
424 if (successful && inlining != null) { |
18198
d7e40b20b030
Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
18162
diff
changeset
|
425 dequeueInlinedCallSites(inlining); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
426 } |
23380
d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
Andreas Woess <andreas.woess@oracle.com>
parents:
23190
diff
changeset
|
427 setCompilationTask(null); |
15212
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
428 } |
ea9d5b6044af
Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15211
diff
changeset
|
429 |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
430 private void dequeueInlinedCallSites(TruffleInlining parentDecision) { |
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
431 for (TruffleInliningDecision decision : parentDecision) { |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
432 if (decision.isInline()) { |
17400
e3dd05527c2f
Truffle: enabled context sensitive inlining by default. removed old inlining structures.
Christian Humer <christian.humer@gmail.com>
parents:
17399
diff
changeset
|
433 OptimizedCallTarget target = decision.getTarget(); |
18200
62de94d5cf73
Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
18199
diff
changeset
|
434 target.cancelInstalledTask(decision.getProfile().getCallNode(), "Inlining caller compiled."); |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
435 dequeueInlinedCallSites(decision); |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
436 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
437 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
438 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
439 |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
440 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
|
441 try { |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
442 return getRootNode().execute(frame); |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
443 } finally { |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
444 // 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
|
445 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
|
446 } |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
447 } |
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
448 |
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
|
449 public final int getKnownCallSiteCount() { |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
450 return callSitesKnown.get(); |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
451 } |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
452 |
15089
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
453 public final void incrementKnownCallSites() { |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
454 callSitesKnown.incrementAndGet(); |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
455 } |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
456 |
15089
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
457 public final void decrementKnownCallSites() { |
14983
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
458 callSitesKnown.decrementAndGet(); |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
459 } |
a31d807757ee
Truffle: made inlining fully context sensitive.
Christian Humer <christian.humer@gmail.com>
parents:
14911
diff
changeset
|
460 |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
461 public final OptimizedCallTarget getSourceCallTarget() { |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
462 return sourceCallTarget; |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
463 } |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
464 |
13984
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
465 @Override |
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
466 public String toString() { |
22466
e56b1fd502d8
Truffle: Ensure toString method is never compiled
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22054
diff
changeset
|
467 CompilerAsserts.neverPartOfCompilation(); |
15167
258e3e0b5e2e
Change RootCallTarget from an abstract class into an interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15162
diff
changeset
|
468 String superString = rootNode.toString(); |
15168
78530cbd8940
Truffle: Make OptimizedCallTarget itself an InstalledCode object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15167
diff
changeset
|
469 if (isValid()) { |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
470 superString += " <opt>"; |
13984
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
471 } |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
472 if (sourceCallTarget != null) { |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
18129
diff
changeset
|
473 superString += " <split-" + cloneIndex + "-" + argumentStamp.toStringShort() + ">"; |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
474 } |
13984
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
475 return superString; |
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
476 } |
1c9dbfc5b510
Truffle: New more reliable inlining strategy for the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
477 |
14866
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
478 public CompilationProfile getCompilationProfile() { |
a0185cd77565
Truffle: refactor ompilation related classes for SubstrateVM
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14715
diff
changeset
|
479 return compilationProfile; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
480 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
481 |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
482 @ExplodeLoop |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
483 private Object[] castArguments(Object[] originalArguments) { |
23139
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
484 Class<?>[] types = profiledArgumentTypes; |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
485 Object[] castArguments = new Object[types.length]; |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
486 for (int i = 0; i < types.length; i++) { |
661e2d8a7316
Simplify Truffle argument profiling code. Profile only for exact concrete class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
23012
diff
changeset
|
487 castArguments[i] = types[i] != null ? unsafeCast(originalArguments[i], types[i], true, true) : originalArguments[i]; |
16470
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
488 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
489 return castArguments; |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
490 } |
efbf9195dfcb
Truffle: add argument type speculation
Andreas Woess <andreas.woess@jku.at>
parents:
16410
diff
changeset
|
491 |
15231
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
492 private static Object castArrayFixedLength(Object[] args, @SuppressWarnings("unused") int length) { |
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
493 return args; |
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
494 } |
babe13eb6118
Truffle: Speculate on the exact length of the arguments array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15224
diff
changeset
|
495 |
19441
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18950
diff
changeset
|
496 public static VirtualFrame createFrame(FrameDescriptor descriptor, Object[] args) { |
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18950
diff
changeset
|
497 if (TruffleCompilerOptions.TruffleUseFrameWithoutBoxing.getValue()) { |
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18950
diff
changeset
|
498 return new FrameWithoutBoxing(descriptor, args); |
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18950
diff
changeset
|
499 } else { |
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18950
diff
changeset
|
500 return new FrameWithBoxing(descriptor, args); |
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18950
diff
changeset
|
501 } |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
502 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
503 |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
504 public List<OptimizedDirectCallNode> getCallNodes() { |
20132
b91ba8932cb6
Truffle: use visitor for getCallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
20095
diff
changeset
|
505 final List<OptimizedDirectCallNode> callNodes = new ArrayList<>(); |
b91ba8932cb6
Truffle: use visitor for getCallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
20095
diff
changeset
|
506 getRootNode().accept(new NodeVisitor() { |
b91ba8932cb6
Truffle: use visitor for getCallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
20095
diff
changeset
|
507 public boolean visit(Node node) { |
b91ba8932cb6
Truffle: use visitor for getCallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
20095
diff
changeset
|
508 if (node instanceof OptimizedDirectCallNode) { |
b91ba8932cb6
Truffle: use visitor for getCallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
20095
diff
changeset
|
509 callNodes.add((OptimizedDirectCallNode) node); |
b91ba8932cb6
Truffle: use visitor for getCallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
20095
diff
changeset
|
510 } |
b91ba8932cb6
Truffle: use visitor for getCallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
20095
diff
changeset
|
511 return true; |
b91ba8932cb6
Truffle: use visitor for getCallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
20095
diff
changeset
|
512 } |
b91ba8932cb6
Truffle: use visitor for getCallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
20095
diff
changeset
|
513 }); |
b91ba8932cb6
Truffle: use visitor for getCallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
20095
diff
changeset
|
514 return callNodes; |
17256
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
515 } |
88d5fd9e1a6c
Truffle: implemented context sensitive inlining; implemented basic partial evaluation caching for call targets (disabled by default).
Christian Humer <christian.humer@gmail.com>
parents:
17191
diff
changeset
|
516 |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
517 @Override |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
518 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
|
519 compilationProfile.reportLoopCount(count); |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
520 } |
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
521 |
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
|
522 @Override |
21204
4a5df5570b7f
Truffle: make ReplaceObserver return a boolean in order to consume replace events. It can be useful for nodes to consume all replace events if they are always executed behind a @TruffleBoundary.
Christian Humer <christian.humer@gmail.com>
parents:
20882
diff
changeset
|
523 public boolean nodeReplaced(Node oldNode, Node newNode, CharSequence reason) { |
18275
ab4284c5b5b0
Truffle: minor cleanup
Christian Humer <christian.humer@gmail.com>
parents:
18210
diff
changeset
|
524 CompilerAsserts.neverPartOfCompilation(); |
18199
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
525 if (isValid()) { |
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
526 invalidate(newNode, reason); |
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
527 } |
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
528 /* Notify compiled method that have inlined this call target that the tree changed. */ |
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
529 nodeRewritingAssumption.invalidate(); |
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
530 |
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
|
531 compilationProfile.reportNodeReplaced(); |
18200
62de94d5cf73
Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
18199
diff
changeset
|
532 if (cancelInstalledTask(newNode, reason)) { |
18199
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
533 compilationProfile.reportInvalidated(); |
c5c80abc3fc6
Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents:
18198
diff
changeset
|
534 } |
21204
4a5df5570b7f
Truffle: make ReplaceObserver return a boolean in order to consume replace events. It can be useful for nodes to consume all replace events if they are always executed behind a @TruffleBoundary.
Christian Humer <christian.humer@gmail.com>
parents:
20882
diff
changeset
|
535 return false; |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
536 } |
10752
e2f5ae9afdc5
Truffle: introduce profiling option
Andreas Woess <andreas.woess@jku.at>
parents:
10751
diff
changeset
|
537 |
17399
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
538 public void accept(NodeVisitor visitor, boolean includeInlinedNodes) { |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
539 TruffleInlining inliner = getInlining(); |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
540 if (includeInlinedNodes && inliner != null) { |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
541 inlining.accept(this, visitor); |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
542 } else { |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
543 getRootNode().accept(visitor); |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
544 } |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
545 } |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
546 |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
547 public Stream<Node> nodeStream(boolean includeInlinedNodes) { |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
548 Iterator<Node> iterator; |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
549 TruffleInlining inliner = getInlining(); |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
550 if (includeInlinedNodes && inliner != null) { |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
551 iterator = inliner.makeNodeIterator(this); |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
552 } else { |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
553 iterator = NodeUtil.makeRecursiveIterator(this.getRootNode()); |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
554 } |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
555 return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, 0), false); |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
556 } |
5787218bad91
Truffle: implemented recursive node iterator and node streams for the graal runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17341
diff
changeset
|
557 |
19978
4cd28f6e3485
Truffle: refactor trivial node count calculation and expose and API that enables to use it for Node subtrees.
Christian Humer <christian.humer@oracle.com>
parents:
19875
diff
changeset
|
558 public final int getNonTrivialNodeCount() { |
19766
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
559 if (cachedNonTrivialNodeCount == -1) { |
19978
4cd28f6e3485
Truffle: refactor trivial node count calculation and expose and API that enables to use it for Node subtrees.
Christian Humer <christian.humer@oracle.com>
parents:
19875
diff
changeset
|
560 cachedNonTrivialNodeCount = calculateNonTrivialNodes(getRootNode()); |
19766
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
561 } |
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
562 return cachedNonTrivialNodeCount; |
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
563 } |
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
564 |
19978
4cd28f6e3485
Truffle: refactor trivial node count calculation and expose and API that enables to use it for Node subtrees.
Christian Humer <christian.humer@oracle.com>
parents:
19875
diff
changeset
|
565 public static int calculateNonTrivialNodes(Node node) { |
19766
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
566 NonTrivialNodeCountVisitor visitor = new NonTrivialNodeCountVisitor(); |
19978
4cd28f6e3485
Truffle: refactor trivial node count calculation and expose and API that enables to use it for Node subtrees.
Christian Humer <christian.humer@oracle.com>
parents:
19875
diff
changeset
|
567 node.accept(visitor); |
19766
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
568 return visitor.nodeCount; |
18206
35639ec046d7
Truffle: extract methods from OptimizedCallUtils and remove it.
Christian Humer <christian.humer@gmail.com>
parents:
18204
diff
changeset
|
569 } |
35639ec046d7
Truffle: extract methods from OptimizedCallUtils and remove it.
Christian Humer <christian.humer@gmail.com>
parents:
18204
diff
changeset
|
570 |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
571 public Map<String, Object> getDebugProperties() { |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
572 Map<String, Object> properties = new LinkedHashMap<>(); |
18204
a1873eefea65
Truffle: refactor TraceTrufflePerformanceWarnings into separate class.
Christian Humer <christian.humer@gmail.com>
parents:
18200
diff
changeset
|
573 AbstractDebugCompilationListener.addASTSizeProperty(this, properties); |
13996
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
574 properties.putAll(getCompilationProfile().getDebugProperties()); |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
575 return properties; |
c7ac129e17e9
Truffle: further tweaks to the inlinig/split heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
13988
diff
changeset
|
576 } |
16410
7f862f0ab1bc
Truffle: added new experimental splitting heuristic.
Christian Humer <christian.humer@gmail.com>
parents:
16401
diff
changeset
|
577 |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
578 public static Method getCallDirectMethod() { |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
579 try { |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
580 return OptimizedCallTarget.class.getDeclaredMethod("callDirect", Object[].class); |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
581 } catch (NoSuchMethodException | SecurityException e) { |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21204
diff
changeset
|
582 throw new JVMCIError(e); |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
583 } |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
584 } |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
585 |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
586 public static Method getCallInlinedMethod() { |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
587 try { |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
588 return OptimizedCallTarget.class.getDeclaredMethod("callInlined", Object[].class); |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
589 } catch (NoSuchMethodException | SecurityException e) { |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21204
diff
changeset
|
590 throw new JVMCIError(e); |
17310
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
591 } |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
592 } |
4bea75e99249
Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
17256
diff
changeset
|
593 |
18386
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
594 private CompilerOptions getCompilerOptions() { |
22815
eb1a8652f8e6
Truffle: take CompilerOptions from RootNode, not ExecutionContext
Andreas Woess <andreas.woess@oracle.com>
parents:
22814
diff
changeset
|
595 final CompilerOptions options = rootNode.getCompilerOptions(); |
eb1a8652f8e6
Truffle: take CompilerOptions from RootNode, not ExecutionContext
Andreas Woess <andreas.woess@oracle.com>
parents:
22814
diff
changeset
|
596 if (options != null) { |
eb1a8652f8e6
Truffle: take CompilerOptions from RootNode, not ExecutionContext
Andreas Woess <andreas.woess@oracle.com>
parents:
22814
diff
changeset
|
597 return options; |
18386
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
598 } |
22815
eb1a8652f8e6
Truffle: take CompilerOptions from RootNode, not ExecutionContext
Andreas Woess <andreas.woess@oracle.com>
parents:
22814
diff
changeset
|
599 return DefaultCompilerOptions.INSTANCE; |
18386
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
600 } |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18276
diff
changeset
|
601 |
22814
42c3911e6993
Truffle: make unsafe methods private
Andreas Woess <andreas.woess@oracle.com>
parents:
22790
diff
changeset
|
602 @SuppressWarnings({"unchecked", "unused"}) |
42c3911e6993
Truffle: make unsafe methods private
Andreas Woess <andreas.woess@oracle.com>
parents:
22790
diff
changeset
|
603 private static <T> T unsafeCast(Object value, Class<T> type, boolean condition, boolean nonNull) { |
42c3911e6993
Truffle: make unsafe methods private
Andreas Woess <andreas.woess@oracle.com>
parents:
22790
diff
changeset
|
604 return (T) value; |
42c3911e6993
Truffle: make unsafe methods private
Andreas Woess <andreas.woess@oracle.com>
parents:
22790
diff
changeset
|
605 } |
42c3911e6993
Truffle: make unsafe methods private
Andreas Woess <andreas.woess@oracle.com>
parents:
22790
diff
changeset
|
606 |
19766
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
607 private static final class NonTrivialNodeCountVisitor implements NodeVisitor { |
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
608 public int nodeCount; |
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
609 |
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
610 public boolean visit(Node node) { |
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
611 if (!node.getCost().isTrivial()) { |
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
612 nodeCount++; |
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
613 } |
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
614 return true; |
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
615 } |
39315508f1b6
Truffle: cache trivial node counts per call target.
Christian Humer <christian.humer@gmail.com>
parents:
19751
diff
changeset
|
616 } |
23012
a8bab192d632
Move Truffle compile queue to VM-independent baseclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22925
diff
changeset
|
617 |
a8bab192d632
Move Truffle compile queue to VM-independent baseclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22925
diff
changeset
|
618 @Override |
a8bab192d632
Move Truffle compile queue to VM-independent baseclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22925
diff
changeset
|
619 public final boolean equals(Object obj) { |
a8bab192d632
Move Truffle compile queue to VM-independent baseclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22925
diff
changeset
|
620 return obj == this; |
a8bab192d632
Move Truffle compile queue to VM-independent baseclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22925
diff
changeset
|
621 } |
a8bab192d632
Move Truffle compile queue to VM-independent baseclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22925
diff
changeset
|
622 |
a8bab192d632
Move Truffle compile queue to VM-independent baseclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22925
diff
changeset
|
623 @Override |
a8bab192d632
Move Truffle compile queue to VM-independent baseclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22925
diff
changeset
|
624 public final int hashCode() { |
a8bab192d632
Move Truffle compile queue to VM-independent baseclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22925
diff
changeset
|
625 return System.identityHashCode(this); |
a8bab192d632
Move Truffle compile queue to VM-independent baseclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22925
diff
changeset
|
626 } |
23380
d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
Andreas Woess <andreas.woess@oracle.com>
parents:
23190
diff
changeset
|
627 |
d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
Andreas Woess <andreas.woess@oracle.com>
parents:
23190
diff
changeset
|
628 Future<?> getCompilationTask() { |
d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
Andreas Woess <andreas.woess@oracle.com>
parents:
23190
diff
changeset
|
629 return compilationTask; |
d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
Andreas Woess <andreas.woess@oracle.com>
parents:
23190
diff
changeset
|
630 } |
d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
Andreas Woess <andreas.woess@oracle.com>
parents:
23190
diff
changeset
|
631 |
d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
Andreas Woess <andreas.woess@oracle.com>
parents:
23190
diff
changeset
|
632 void setCompilationTask(Future<?> compilationTask) { |
d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
Andreas Woess <andreas.woess@oracle.com>
parents:
23190
diff
changeset
|
633 this.compilationTask = compilationTask; |
d7e25fa8bc3e
Truffle: compilation queue should weakly reference call targets
Andreas Woess <andreas.woess@oracle.com>
parents:
23190
diff
changeset
|
634 } |
10484
0097fb11c16f
Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
635 } |