changeset 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 9e5abd0e7916
children 5949340cc50e
files graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java	Thu Oct 09 14:51:39 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java	Thu Oct 09 13:26:17 2014 +0200
@@ -38,7 +38,7 @@
  */
 public abstract class Node implements Cloneable {
 
-    private Node parent;
+    @CompilationFinal private Node parent;
 
     @CompilationFinal private SourceSection sourceSection;
 
@@ -124,12 +124,16 @@
      *
      * @return the assigned source code section
      */
-    @CompilerDirectives.SlowPath
+    @ExplodeLoop
     public final SourceSection getEncapsulatingSourceSection() {
-        if (sourceSection == null && getParent() != null) {
-            return getParent().getEncapsulatingSourceSection();
+        Node current = this;
+        while (current != null) {
+            if (current.sourceSection != null) {
+                return current.sourceSection;
+            }
+            current = current.parent;
         }
-        return sourceSection;
+        return null;
     }
 
     /**