comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java @ 13983:f46cab39a9a2

Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
author Christian Humer <christian.humer@gmail.com>
date Thu, 20 Feb 2014 01:21:49 +0100
parents d6b340b757a2
children 989f58d6a0ca
comparison
equal deleted inserted replaced
13977:39076a984c33 13983:f46cab39a9a2
183 onReplace(newNode, reason); 183 onReplace(newNode, reason);
184 ((Node) newNode).parent = this.parent; 184 ((Node) newNode).parent = this.parent;
185 if (!NodeUtil.replaceChild(this.parent, this, newNode)) { 185 if (!NodeUtil.replaceChild(this.parent, this, newNode)) {
186 fixupTree(); 186 fixupTree();
187 } 187 }
188 reportReplace(); 188 reportReplace(this, newNode, reason);
189 return newNode; 189 return newNode;
190 } 190 }
191 191
192 /** 192 /**
193 * Rewrite has failed; the tree is likely inconsistent, so fix any stale parent references. 193 * Rewrite has failed; the tree is likely inconsistent, so fix any stale parent references.
243 } 243 }
244 } 244 }
245 return false; 245 return false;
246 } 246 }
247 247
248 private void reportReplace() { 248 private void reportReplace(Node oldNode, Node newNode, String reason) {
249 RootNode rootNode = NodeUtil.findOutermostRootNode(this); 249 Collection<CallTarget> targets = NodeUtil.findOutermostCallTargets(this);
250 if (rootNode != null) { 250 for (CallTarget target : targets) {
251 if (rootNode.getCallTarget() instanceof ReplaceObserver) { 251 if (target instanceof ReplaceObserver) {
252 ((ReplaceObserver) rootNode.getCallTarget()).nodeReplaced(); 252 ((ReplaceObserver) target).nodeReplaced(oldNode, newNode, reason);
253 } 253 }
254 } 254 }
255 } 255 }
256 256
257 /** 257 /**
393 /** 393 /**
394 * Get the root node of the tree a node belongs to. 394 * Get the root node of the tree a node belongs to.
395 * 395 *
396 * @return the {@link RootNode} or {@code null} if there is none. 396 * @return the {@link RootNode} or {@code null} if there is none.
397 */ 397 */
398 protected final RootNode getRootNode() { 398 public final RootNode getRootNode() {
399 Node rootNode = this; 399 Node rootNode = this;
400 while (rootNode.getParent() != null) { 400 while (rootNode.getParent() != null) {
401 assert !(rootNode instanceof RootNode) : "root node must not have a parent"; 401 assert !(rootNode instanceof RootNode) : "root node must not have a parent";
402 rootNode = rootNode.getParent(); 402 rootNode = rootNode.getParent();
403 } 403 }