annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/CallNode.java @ 14566:6681b9eb3f4c

Truffle: API cleanup and javadoc for CallNodes.
author Christian Humer <christian.humer@gmail.com>
date Mon, 17 Mar 2014 14:29:45 +0100
parents 9c01fabfb167
children 6189c1983cd3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
1 /*
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
4 *
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
7 * published by the Free Software Foundation. Oracle designates this
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
8 * particular file as subject to the "Classpath" exception as provided
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
10 *
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
11 * This code is distributed in the hope that it will be useful, but WITHOUT
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
14 * version 2 for more details (a copy is included in the LICENSE file that
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
15 * accompanied this code).
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
16 *
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License version
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
18 * 2 along with this work; if not, write to the Free Software Foundation,
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
20 *
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
22 * or visit www.oracle.com if you need additional information or have any
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
23 * questions.
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
24 */
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
25 package com.oracle.truffle.api.nodes;
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
26
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
27 import com.oracle.truffle.api.*;
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
28 import com.oracle.truffle.api.frame.*;
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
29
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
30 /**
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
31 * Represents a call to a {@link CallTarget} in the Truffle AST. Addtionally to calling the
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
32 * {@link CallTarget} this {@link Node} enables the runtime system to implement further
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
33 * optimizations. Optimizations that can possibly applied to a {@link CallNode} are inlining and
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
34 * splitting. Inlining inlines this call site into the call graph of the parent {@link CallTarget}.
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
35 * Splitting duplicates the {@link CallTarget} using {@link RootNode#split()} to collect call site
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
36 * sensitive profiling information.
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
37 *
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
38 * Please note: This class is not intended to be subclassed by guest language implementations.
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
39 *
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
40 * @see TruffleRuntime#createCallNode(CallTarget)
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
41 * @see #inline()
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
42 * @see #split()
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
43 */
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
44 public abstract class CallNode extends Node {
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
45
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
46 protected final CallTarget callTarget;
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
47
13983
f46cab39a9a2 Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13847
diff changeset
48 protected CallNode(CallTarget callTarget) {
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
49 this.callTarget = callTarget;
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
50 }
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
51
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
52 /**
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
53 * Calls the inner {@link CallTarget} returned by {@link #getCurrentCallTarget()}.
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
54 *
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
55 * @param caller the caller frame
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
56 * @param arguments the arguments that should be passed to the callee
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
57 * @return the return result of the call
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
58 */
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
59 public abstract Object call(PackedFrame caller, Arguments arguments);
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
60
14073
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
61 /**
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
62 * Returns the originally supplied {@link CallTarget} when this call node was created. Please
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
63 * note that the returned {@link CallTarget} is not necessarily the {@link CallTarget} that is
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
64 * called. For that use {@link #getCurrentCallTarget()} instead.
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
65 *
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
66 * @return the {@link CallTarget} provided.
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
67 */
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
68 public CallTarget getCallTarget() {
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
69 return callTarget;
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
70 }
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
71
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
72 /**
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
73 * Returns <code>true</code> if the underlying runtime system supports inlining for the
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
74 * {@link CallTarget} in this {@link CallNode}.
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
75 *
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
76 * @return true if inlining is supported.
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
77 */
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
78 public abstract boolean isInlinable();
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
79
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
80 /**
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
81 * Returns <code>true</code> if the {@link CallTarget} in this {@link CallNode} is inlined. A
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
82 * {@link CallNode} can either be inlined manually by invoking {@link #inline()} or by the
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
83 * runtime system which may at any point decide to inline.
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
84 *
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
85 * @return true if this method was inlined else false.
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
86 */
13804
Christian Humer <christian.humer@gmail.com>
parents: 13803
diff changeset
87 public abstract boolean isInlined();
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
88
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
89 /**
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
90 * Enforces the runtime system to inline the {@link CallTarget} at this call site. If the
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
91 * runtime system does not support inlining or it is already inlined this method has no effect.
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
92 */
13983
f46cab39a9a2 Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13847
diff changeset
93 public abstract void inline();
f46cab39a9a2 Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13847
diff changeset
94
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
95 /**
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
96 * Returns <code>true</code> if this {@link CallNode} can be split. A {@link CallNode} can only
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
97 * be split if the runtime system supports splitting and if the {@link RootNode} contained the
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
98 * {@link CallTarget} returns <code>true</code> for {@link RootNode#isSplittable()}.
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
99 *
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
100 * @return <code>true</code> if the target can be split
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
101 */
13983
f46cab39a9a2 Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13847
diff changeset
102 public abstract boolean isSplittable();
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
103
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
104 /**
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
105 * Enforces the runtime system to split the {@link CallTarget}. If the {@link CallNode} is not
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
106 * splittable this methods has no effect.
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
107 */
13983
f46cab39a9a2 Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13847
diff changeset
108 public abstract boolean split();
f46cab39a9a2 Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13847
diff changeset
109
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
110 /**
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
111 * Returns <code>true</code> if the target of the {@link CallNode} was split.
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
112 *
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
113 * @return if the target was split
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
114 */
14073
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
115 public final boolean isSplit() {
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
116 return getSplitCallTarget() != null;
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
117 }
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
118
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
119 /**
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
120 * Returns the splitted {@link CallTarget} if this method is split.
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
121 *
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
122 * @return the split {@link CallTarget}
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
123 */
13983
f46cab39a9a2 Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13847
diff changeset
124 public abstract CallTarget getSplitCallTarget();
f46cab39a9a2 Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13847
diff changeset
125
14073
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
126 /**
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
127 * Returns the used call target when {@link #call(PackedFrame, Arguments)} is invoked. If the
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
128 * {@link CallTarget} was split this method returns the {@link CallTarget} returned by
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
129 * {@link #getSplitCallTarget()}.
14073
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
130 *
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
131 * @return the used {@link CallTarget} when node is called
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
132 */
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
133 public CallTarget getCurrentCallTarget() {
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
134 CallTarget split = getSplitCallTarget();
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
135 if (split != null) {
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
136 return split;
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
137 } else {
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
138 return getCallTarget();
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
139 }
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
140 }
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
141
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
142 /**
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
143 * Returns the {@link RootNode} associated with {@link CallTarget} returned by
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
144 * {@link #getCurrentCallTarget()}. If the stored {@link CallTarget} does not contain a
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
145 * {@link RootNode} this method returns <code>null</code>.
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
146 *
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
147 * @see #getCurrentCallTarget()
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
148 * @return the root node of the used call target
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
149 */
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
150 public final RootNode getCurrentRootNode() {
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
151 CallTarget target = getCurrentCallTarget();
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
152 if (target instanceof RootCallTarget) {
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
153 return ((RootCallTarget) target).getRootNode();
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
154 }
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
155 return null;
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
156 }
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
157
14073
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
158 @Override
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
159 protected void onReplace(Node newNode, String reason) {
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
160 super.onReplace(newNode, reason);
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
161
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
162 /*
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
163 * Old call nodes are removed in the old target root node.
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
164 */
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
165 CallNode oldCall = this;
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
166 RootNode oldRoot = getCurrentRootNode();
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
167 if (oldRoot != null) {
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
168 oldRoot.removeCachedCallNode(oldCall);
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
169 }
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
170
14079
ca92db718c74 Truffle: refined split/inlining heuristics.
Christian Humer <christian.humer@gmail.com>
parents: 14078
diff changeset
171 registerCallTarget((CallNode) newNode);
ca92db718c74 Truffle: refined split/inlining heuristics.
Christian Humer <christian.humer@gmail.com>
parents: 14078
diff changeset
172 }
ca92db718c74 Truffle: refined split/inlining heuristics.
Christian Humer <christian.humer@gmail.com>
parents: 14078
diff changeset
173
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
174 /**
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
175 * Internal API for the runtime system.
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
176 */
14080
cd4595e8a685 Truffle: added notification from callee to callers in the CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 14079
diff changeset
177 protected static final void registerCallTarget(CallNode newNode) {
14079
ca92db718c74 Truffle: refined split/inlining heuristics.
Christian Humer <christian.humer@gmail.com>
parents: 14078
diff changeset
178 RootNode newRoot = newNode.getCurrentRootNode();
14073
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
179 if (newRoot != null) {
14079
ca92db718c74 Truffle: refined split/inlining heuristics.
Christian Humer <christian.humer@gmail.com>
parents: 14078
diff changeset
180 newRoot.addCachedCallNode(newNode);
14073
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
181 }
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
182 }
c5411233cdf8 Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents: 13983
diff changeset
183
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
184 }