comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java @ 17389:763a34f283f9

make Truffle Node parent @CompilationFinal, let getEncapsulatingSourceSection evaluate at compile time
author Lukas Stadler <lukas.stadler@oracle.com>
date Thu, 09 Oct 2014 13:26:17 +0200
parents e1da729b3e4e
children 65a160d9d259
comparison
equal deleted inserted replaced
17388:9e5abd0e7916 17389:763a34f283f9
36 /** 36 /**
37 * Abstract base class for all Truffle nodes. 37 * Abstract base class for all Truffle nodes.
38 */ 38 */
39 public abstract class Node implements Cloneable { 39 public abstract class Node implements Cloneable {
40 40
41 private Node parent; 41 @CompilationFinal private Node parent;
42 42
43 @CompilationFinal private SourceSection sourceSection; 43 @CompilationFinal private SourceSection sourceSection;
44 44
45 /** 45 /**
46 * Marks array fields that are children of this node. 46 * Marks array fields that are children of this node.
122 /** 122 /**
123 * Retrieves the guest language source code section that is currently assigned to this node. 123 * Retrieves the guest language source code section that is currently assigned to this node.
124 * 124 *
125 * @return the assigned source code section 125 * @return the assigned source code section
126 */ 126 */
127 @CompilerDirectives.SlowPath 127 @ExplodeLoop
128 public final SourceSection getEncapsulatingSourceSection() { 128 public final SourceSection getEncapsulatingSourceSection() {
129 if (sourceSection == null && getParent() != null) { 129 Node current = this;
130 return getParent().getEncapsulatingSourceSection(); 130 while (current != null) {
131 } 131 if (current.sourceSection != null) {
132 return sourceSection; 132 return current.sourceSection;
133 }
134 current = current.parent;
135 }
136 return null;
133 } 137 }
134 138
135 /** 139 /**
136 * Method that updates the link to the parent in the array of specified new child nodes to this 140 * Method that updates the link to the parent in the array of specified new child nodes to this
137 * node. 141 * node.