changeset 15224:735147ef0176

Truffle: Move direct call logic from call site to optimized call target.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 18 Apr 2014 02:13:14 +0200
parents 7d6c2a0e60a8
children aee7eeb554ad df724f63f776
files graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedDirectCallNode.java
diffstat 2 files changed, 10 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Fri Apr 18 02:00:35 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Fri Apr 18 02:13:14 2014 +0200
@@ -60,17 +60,6 @@
         return rootNode;
     }
 
-    public Class<?> getProfiledReturnType() {
-        Class<?> result = profiledReturnType;
-        if (result != null) {
-            try {
-                profiledReturnTypeAssumption.check();
-            } catch (InvalidAssumptionException e) {
-            }
-        }
-        return result;
-    }
-
     public OptimizedCallTarget(RootNode rootNode, GraalTruffleRuntime runtime, int invokeCounter, int compilationThreshold, CompilationPolicy compilationPolicy, SpeculationLog speculationLog) {
         this.runtime = runtime;
         this.speculationLog = speculationLog;
@@ -93,6 +82,15 @@
         return callBoundary(args);
     }
 
+    public Object callDirect(Object... args) {
+        Object result = callBoundary(args);
+        Class<?> klass = profiledReturnType;
+        if (klass != null && profiledReturnTypeAssumption.isValid()) {
+            result = CompilerDirectives.unsafeCast(result, klass, true, true);
+        }
+        return result;
+    }
+
     @TruffleCallBoundary
     private Object callBoundary(Object[] args) {
         if (CompilerDirectives.inInterpreter()) {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedDirectCallNode.java	Fri Apr 18 02:00:35 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedDirectCallNode.java	Fri Apr 18 02:13:14 2014 +0200
@@ -62,12 +62,7 @@
             if (inlined) {
                 return ((OptimizedCallTarget) callTarget).callInlined(arguments);
             } else if (direct) {
-                Object result = ((OptimizedCallTarget) callTarget).call(arguments);
-                Class<?> klass = ((OptimizedCallTarget) callTarget).getProfiledReturnType();
-                if (klass != null) {
-                    result = CompilerDirectives.unsafeCast(result, klass, true, true);
-                }
-                return result;
+                return ((OptimizedCallTarget) callTarget).callDirect(arguments);
             } else {
                 return callTarget.call(arguments);
             }