comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.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 1422f0bd55e3
comparison
equal deleted inserted replaced
14565:9c01fabfb167 14566:6681b9eb3f4c
34 * root node can be used to create a call target using 34 * root node can be used to create a call target using
35 * {@link TruffleRuntime#createCallTarget(RootNode)}. 35 * {@link TruffleRuntime#createCallTarget(RootNode)}.
36 */ 36 */
37 public abstract class RootNode extends Node { 37 public abstract class RootNode extends Node {
38 38
39 private CallTarget callTarget; 39 private RootCallTarget callTarget;
40 private final FrameDescriptor frameDescriptor; 40 private final FrameDescriptor frameDescriptor;
41 41
42 /* 42 /*
43 * Internal set to keep back-references to the call-sites. 43 * Internal set to keep back-references to the call-sites.
44 */ 44 */
59 } else { 59 } else {
60 this.frameDescriptor = frameDescriptor; 60 this.frameDescriptor = frameDescriptor;
61 } 61 }
62 } 62 }
63 63
64 /**
65 * Creates a split {@link RootNode} based on the current {@link RootNode}. This method should
66 * return an AST that was never executed and must not be shared with other {@link RootNode} or
67 * {@link CallTarget} instances. This method is intended to be overridden by a subclass.
68 *
69 * @return the split {@link RootNode}
70 */
64 public RootNode split() { 71 public RootNode split() {
65 return NodeUtil.cloneNode(this); 72 throw new UnsupportedOperationException();
66 } 73 }
67 74
75 /**
76 * Returns <code>true</code> if this {@link RootNode} can be split. A {@link RootNode} can be
77 * split inside of a {@link CallTarget} that is invoked using a {@link CallNode}. If this method
78 * returns <code>true</code> a proper implementation of {@link #split()} must also be provided.
79 * This method is intended to be overridden by a subclass.
80 *
81 * @return <code>true</code> if splittable else <code>false</code>.
82 */
68 public boolean isSplittable() { 83 public boolean isSplittable() {
69 return false; 84 return false;
70 } 85 }
71 86
72 /** 87 /**
73 * Reports the execution count of a loop that is a child of this node. The optimization 88 * Reports the execution count of a loop that is a child of this node. The optimization
74 * heuristics can use the loop count to guide compilation and inlining. 89 * heuristics can use the loop count to guide compilation and inlining.
75 */ 90 */
76 public void reportLoopCount(int count) { 91 public final void reportLoopCount(int count) {
77 if (getCallTarget() instanceof LoopCountReceiver) { 92 if (getCallTarget() instanceof LoopCountReceiver) {
78 ((LoopCountReceiver) getCallTarget()).reportLoopCount(count); 93 ((LoopCountReceiver) getCallTarget()).reportLoopCount(count);
79 } 94 }
80 } 95 }
81 96
85 * @param frame the frame of the currently executing guest language method 100 * @param frame the frame of the currently executing guest language method
86 * @return the value of the execution 101 * @return the value of the execution
87 */ 102 */
88 public abstract Object execute(VirtualFrame frame); 103 public abstract Object execute(VirtualFrame frame);
89 104
90 public CallTarget getCallTarget() { 105 public final RootCallTarget getCallTarget() {
91 return callTarget; 106 return callTarget;
92 } 107 }
93 108
94 public final FrameDescriptor getFrameDescriptor() { 109 public final FrameDescriptor getFrameDescriptor() {
95 return frameDescriptor; 110 return frameDescriptor;
96 } 111 }
97 112
98 public final void setCallTarget(CallTarget callTarget) { 113 public final void setCallTarget(RootCallTarget callTarget) {
99 this.callTarget = callTarget; 114 this.callTarget = callTarget;
100 } 115 }
101 116
102 /* Internal API. Do not use. */ 117 /* Internal API. Do not use. */
103 void addCachedCallNode(CallNode callSite) { 118 final void addCachedCallNode(CallNode callSite) {
104 this.cachedCallNodes.add(callSite); 119 this.cachedCallNodes.add(callSite);
105 } 120 }
106 121
107 /* Internal API. Do not use. */ 122 /* Internal API. Do not use. */
108 void removeCachedCallNode(CallNode callSite) { 123 final void removeCachedCallNode(CallNode callSite) {
109 this.cachedCallNodes.remove(callSite); 124 this.cachedCallNodes.remove(callSite);
110 } 125 }
111 126
112 /** 127 /**
113 * Returns a {@link Set} of {@link CallNode} nodes which are created to invoke this RootNode. 128 * Returns a {@link Set} of {@link CallNode} nodes which are created to invoke this RootNode.