diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java @ 13811:641f22b1c6b8

Truffle: further fixes to the new CallNode.
author Christian Humer <christian.humer@gmail.com>
date Wed, 29 Jan 2014 20:49:09 +0100
parents 3840d61e0e68
children 67e4e7f56911
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java	Wed Jan 29 12:19:03 2014 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java	Wed Jan 29 20:49:09 2014 +0100
@@ -25,6 +25,7 @@
 package com.oracle.truffle.api.nodes;
 
 import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.CompilerDirectives.*;
 import com.oracle.truffle.api.frame.*;
 
 /**
@@ -37,6 +38,12 @@
     private CallTarget callTarget;
     private final FrameDescriptor frameDescriptor;
 
+    /*
+     * Internal field to keep reference to the inlined call node. The inlined parent should not be
+     * the same as the Node parent to keep the same tree hierarchy if inlined vs not inlined.
+     */
+    @CompilationFinal private CallNode parentInlinedCall;
+
     protected RootNode() {
         this(null, null);
     }
@@ -125,4 +132,20 @@
     public void setCallTarget(CallTarget callTarget) {
         this.callTarget = callTarget;
     }
+
+    /* Internal API. Do not use. */
+    void setParentInlinedCall(CallNode inlinedParent) {
+        this.parentInlinedCall = inlinedParent;
+    }
+
+    /**
+     * Returns the {@link CallNode} that uses this {@link RootNode} for an inlined call. Returns
+     * <code>null</code> if this {@link RootNode} is not inlined into a caller. This method can be
+     * used to also traverse parent {@link CallTarget} that have been inlined into this call.
+     * 
+     * @return the responsible {@link CallNode} for inlining.
+     */
+    public final CallNode getParentInlinedCall() {
+        return parentInlinedCall;
+    }
 }