Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java @ 13803:e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 24 Jan 2014 15:55:41 +0100 |
parents | ac5b0f31f7a2 |
children | 3840d61e0e68 |
comparison
equal
deleted
inserted
replaced
13750:a03cb658e68e | 13803:e076c87ab175 |
---|---|
53 this.frameDescriptor = frameDescriptor; | 53 this.frameDescriptor = frameDescriptor; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 /** | 57 /** |
58 * Creates a copy of the current {@link RootNode} for use as inlined AST. The default | |
59 * implementation copies this {@link RootNode} and all its children recursively. It is | |
60 * recommended to override this method to provide an implementation that copies an uninitialized | |
61 * version of this AST. An uninitialized version of an AST was usually never executed which | |
62 * means that it has not yet collected any profiling feedback. Please note that changes in the | |
63 * behavior of this method might also require changes in {@link #getInlineNodeCount()}. | |
64 * | |
65 * @see RootNode#getInlineNodeCount() | |
66 * @see RootNode#isInlinable() | |
67 * | |
68 * @return the copied RootNode for inlining | |
69 * @throws UnsupportedOperationException if {@link #isInlinable()} returns false | |
70 */ | |
71 public RootNode inline() { | |
72 if (!isInlinable()) { | |
73 throw new UnsupportedOperationException("Inlining is not enabled."); | |
74 } | |
75 return NodeUtil.cloneNode(this); | |
76 } | |
77 | |
78 /** | |
79 * Returns the number of nodes that would be returned if {@link #inline()} would get invoked. | |
80 * This node count may be used for the calculation of a smart inlining heuristic. | |
81 * | |
82 * @see RootNode#inline() | |
83 * @see RootNode#isInlinable() | |
84 * | |
85 * @return the number of nodes that will get inlined | |
86 * @throws UnsupportedOperationException if {@link #isInlinable()} returns false | |
87 */ | |
88 public int getInlineNodeCount() { | |
89 if (!isInlinable()) { | |
90 throw new UnsupportedOperationException("Inlining is not enabled."); | |
91 } | |
92 return NodeUtil.countNodes(this); | |
93 } | |
94 | |
95 /** | |
96 * Returns true if this RootNode can be inlined. If this method returns true proper | |
97 * implementations of {@link #inline()} and {@link #getInlineNodeCount()} must be provided. | |
98 * Returns true by default. | |
99 * | |
100 * @see RootNode#inline() | |
101 * @see RootNode#getInlineNodeCount() | |
102 * | |
103 * @return true if this RootNode can be inlined | |
104 */ | |
105 public boolean isInlinable() { | |
106 return true; | |
107 } | |
108 | |
109 /** | |
58 * Executes this function using the specified frame and returns the result value. | 110 * Executes this function using the specified frame and returns the result value. |
59 * | 111 * |
60 * @param frame the frame of the currently executing guest language method | 112 * @param frame the frame of the currently executing guest language method |
61 * @return the value of the execution | 113 * @return the value of the execution |
62 */ | 114 */ |
64 | 116 |
65 public CallTarget getCallTarget() { | 117 public CallTarget getCallTarget() { |
66 return callTarget; | 118 return callTarget; |
67 } | 119 } |
68 | 120 |
69 public FrameDescriptor getFrameDescriptor() { | 121 public final FrameDescriptor getFrameDescriptor() { |
70 return frameDescriptor; | 122 return frameDescriptor; |
71 } | 123 } |
72 | 124 |
73 public void setCallTarget(CallTarget callTarget) { | 125 public void setCallTarget(CallTarget callTarget) { |
74 this.callTarget = callTarget; | 126 this.callTarget = callTarget; |