changeset 15159:2ed720ce9273

Truffle: Change CallTarget from an abstract class to an interface. Allow varargs.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 15 Apr 2014 13:26:26 +0200
parents 083e9e4df58a
children a47e68e146a2
files graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotOptimizedCallTarget.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/RootNodeTest.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CallTarget.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/RootCallTarget.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultCallTarget.java
diffstat 6 files changed, 10 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotOptimizedCallTarget.java	Tue Apr 15 13:20:17 2014 +0200
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotOptimizedCallTarget.java	Tue Apr 15 13:26:26 2014 +0200
@@ -58,7 +58,7 @@
 
     @CompilerDirectives.SlowPath
     @Override
-    public Object call(Object[] args) {
+    public Object call(Object... args) {
         return CompilerDirectives.inInterpreter() ? callHelper(args) : executeHelper(args);
     }
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Tue Apr 15 13:20:17 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Tue Apr 15 13:26:26 2014 +0200
@@ -33,13 +33,12 @@
 import com.oracle.graal.debug.*;
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.impl.*;
 import com.oracle.truffle.api.nodes.*;
 
 /**
  * Call target that is optimized by Graal upon surpassing a specific invocation threshold.
  */
-public abstract class OptimizedCallTarget extends DefaultCallTarget implements LoopCountReceiver, ReplaceObserver {
+public abstract class OptimizedCallTarget extends RootCallTarget implements LoopCountReceiver, ReplaceObserver {
 
     protected static final PrintStream OUT = TTY.out().out();
 
@@ -99,7 +98,7 @@
     }
 
     @Override
-    public abstract Object call(Object[] args);
+    public abstract Object call(Object... args);
 
     public abstract InstalledCode compile();
 
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/RootNodeTest.java	Tue Apr 15 13:20:17 2014 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/RootNodeTest.java	Tue Apr 15 13:26:26 2014 +0200
@@ -30,7 +30,7 @@
 
 /**
  * <h3>Creating a Root Node</h3>
- * 
+ *
  * <p>
  * A Truffle root node is the entry point into a Truffle tree that represents a guest language
  * method. It contains a {@link RootNode#execute(VirtualFrame)} method that can return a
@@ -38,9 +38,9 @@
  * must however never be called directly. Instead, the Truffle runtime must be used to create a
  * {@link CallTarget} object from a root node using the
  * {@link TruffleRuntime#createCallTarget(RootNode)} method. This call target object can then be
- * executed using the {@link CallTarget#call()} method or one of its overloads.
+ * executed using the {@link CallTarget#call(Object...)} method or one of its overloads.
  * </p>
- * 
+ *
  * <p>
  * The next part of the Truffle API introduction is at
  * {@link com.oracle.truffle.api.test.ChildNodeTest}.
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CallTarget.java	Tue Apr 15 13:20:17 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CallTarget.java	Tue Apr 15 13:26:26 2014 +0200
@@ -27,7 +27,7 @@
 /**
  * Represents the target of a call.
  */
-public abstract class CallTarget {
+public interface CallTarget {
 
     public static final Object[] NO_ARGUMENTS = new Object[0];
 
@@ -37,9 +37,5 @@
      * @param arguments passed arguments as an object array
      * @return the return result of the call
      */
-    public abstract Object call(Object[] arguments);
-
-    public final Object call() {
-        return call(NO_ARGUMENTS);
-    }
+    Object call(Object... arguments);
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/RootCallTarget.java	Tue Apr 15 13:20:17 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/RootCallTarget.java	Tue Apr 15 13:26:26 2014 +0200
@@ -31,7 +31,7 @@
  * Represents the target of a call to a {@link RootNode}, i.e., to another tree of nodes. Instances
  * of this class can be created using {@link TruffleRuntime#createCallTarget(RootNode)}.
  */
-public abstract class RootCallTarget extends CallTarget {
+public abstract class RootCallTarget implements CallTarget {
 
     private final RootNode rootNode;
 
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultCallTarget.java	Tue Apr 15 13:20:17 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultCallTarget.java	Tue Apr 15 13:26:26 2014 +0200
@@ -39,7 +39,7 @@
     }
 
     @Override
-    public Object call(Object[] args) {
+    public Object call(Object... args) {
         VirtualFrame frame = new DefaultVirtualFrame(getRootNode().getFrameDescriptor(), args);
         return callProxy(frame);
     }