changeset 22436:46a6d3eb790c

Adopt TCK and Polyglot after changes to execute and invoke message
author Matthias Grimmer <grimmer@ssw.jku.at>
date Mon, 30 Nov 2015 10:24:00 +0100
parents 5e2dd9c3fa7d
children 0ca502f898ec
files truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/JavaFunctionTest.java truffle/com.oracle.truffle.api.interop.java/src/com/oracle/truffle/api/interop/java/JavaInterop.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ImplicitExplicitExportTest.java truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java truffle/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugTest.java truffle/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/instrument/SLInstrumentTestRunner.java truffle/com.oracle.truffle.sl.tools/src/com/oracle/truffle/sl/tools/SLCoverage.java truffle/com.oracle.truffle.sl.tools/src/com/oracle/truffle/sl/tools/debug/SLREPLHandler.java truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/SLForeignToSLTypeNode.java truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionForeignAccess.java truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLObjectType.java truffle/com.oracle.truffle.tck/src/com/oracle/truffle/tck/TruffleTCK.java
diffstat 14 files changed, 230 insertions(+), 72 deletions(-) [+]
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/JavaFunctionTest.java	Thu Nov 26 14:22:48 2015 +0100
+++ b/truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/JavaFunctionTest.java	Mon Nov 30 10:24:00 2015 +0100
@@ -41,7 +41,7 @@
                 called[0] = true;
             }
         })).build();
-        engine.findGlobalSymbol("test").invoke(null);
+        engine.findGlobalSymbol("test").execute();
 
         assertTrue("Runnable has been called", called[0]);
     }
--- a/truffle/com.oracle.truffle.api.interop.java/src/com/oracle/truffle/api/interop/java/JavaInterop.java	Thu Nov 26 14:22:48 2015 +0100
+++ b/truffle/com.oracle.truffle.api.interop.java/src/com/oracle/truffle/api/interop/java/JavaInterop.java	Mon Nov 30 10:24:00 2015 +0100
@@ -408,7 +408,7 @@
                         throw new IllegalArgumentException(attr + " cannot be invoked with " + args.length + " parameters");
                     }
                     List<Object> callArgs = new ArrayList<>(args.length + 1);
-                    // callArgs.add(attr);
+                    callArgs.add(attr);
                     callArgs.addAll(Arrays.asList(args));
                     ret = message(Message.createExecute(callArgs.size()), attr, callArgs.toArray());
                 }
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ImplicitExplicitExportTest.java	Thu Nov 26 14:22:48 2015 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ImplicitExplicitExportTest.java	Mon Nov 30 10:24:00 2015 +0100
@@ -126,7 +126,7 @@
         ).get();
         // @formatter:on
         assertEquals("Explicit import from L2 is used", "43", ret);
-        assertEquals("Global symbol is also 43", "43", vm.findGlobalSymbol("ahoj").invoke(null).get());
+        assertEquals("Global symbol is also 43", "43", vm.findGlobalSymbol("ahoj").execute().get());
     }
 
     static final class Ctx {
--- a/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java	Thu Nov 26 14:22:48 2015 +0100
+++ b/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java	Mon Nov 30 10:24:00 2015 +0100
@@ -667,7 +667,23 @@
          *         <code>null</code>
          * @throws IOException signals problem during execution
          */
+        @Deprecated
         public Value invoke(final Object thiz, final Object... args) throws IOException {
+            return execute(args);
+        }
+
+        /**
+         * Executes the symbol. If the symbol represents a function, then it should be invoked with
+         * provided arguments. If the symbol represents a field, then first argument (if provided)
+         * should set the value to the field; the return value should be the actual value of the
+         * field when the <code>invoke</code> method returns.
+         *
+         * @param args arguments to pass when invoking the symbol
+         * @return symbol wrapper around the value returned by invoking the symbol, never
+         *         <code>null</code>
+         * @throws IOException signals problem during execution
+         */
+        public Value execute(final Object... args) throws IOException {
             get();
             ComputeInExecutor<Object> invokeCompute = new ComputeInExecutor<Object>(executor) {
                 @SuppressWarnings("try")
@@ -675,16 +691,6 @@
                 protected Object compute() throws IOException {
                     try (final Closeable c = SPI.executionStart(PolyglotEngine.this, -1, debugger, null)) {
                         List<Object> arr = new ArrayList<>();
-                        if (thiz == null) {
-                            if (language[0] != null) {
-                                Object global = SPI.languageGlobal(SPI.findLanguage(PolyglotEngine.this, language[0].getClass()));
-                                if (global != null) {
-                                    arr.add(global);
-                                }
-                            }
-                        } else {
-                            arr.add(thiz);
-                        }
                         arr.addAll(Arrays.asList(args));
                         for (;;) {
                             try {
--- a/truffle/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugTest.java	Thu Nov 26 14:22:48 2015 +0100
+++ b/truffle/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugTest.java	Mon Nov 30 10:24:00 2015 +0100
@@ -168,7 +168,7 @@
         });
 
         PolyglotEngine.Value main = engine.findGlobalSymbol("main");
-        value = main.invoke(null);
+        value = main.execute();
 
         assertExecutedOK();
 
--- a/truffle/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/instrument/SLInstrumentTestRunner.java	Thu Nov 26 14:22:48 2015 +0100
+++ b/truffle/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/instrument/SLInstrumentTestRunner.java	Mon Nov 30 10:24:00 2015 +0100
@@ -257,7 +257,7 @@
                 }
 
                 PolyglotEngine.Value main = vm.findGlobalSymbol("main");
-                main.invoke(null);
+                main.execute();
             } else {
                 notifier.fireTestFailure(new Failure(testCase.name, new UnsupportedOperationException("No instrumentation found.")));
             }
--- a/truffle/com.oracle.truffle.sl.tools/src/com/oracle/truffle/sl/tools/SLCoverage.java	Thu Nov 26 14:22:48 2015 +0100
+++ b/truffle/com.oracle.truffle.sl.tools/src/com/oracle/truffle/sl/tools/SLCoverage.java	Mon Nov 30 10:24:00 2015 +0100
@@ -81,7 +81,7 @@
             throw new IOException("No function main() defined in SL source file.");
         }
         while (repeats-- > 0) {
-            main.invoke(null);
+            main.execute();
         }
         coverageTracker.print(System.out);
     }
--- a/truffle/com.oracle.truffle.sl.tools/src/com/oracle/truffle/sl/tools/debug/SLREPLHandler.java	Thu Nov 26 14:22:48 2015 +0100
+++ b/truffle/com.oracle.truffle.sl.tools/src/com/oracle/truffle/sl/tools/debug/SLREPLHandler.java	Mon Nov 30 10:24:00 2015 +0100
@@ -132,7 +132,7 @@
             vm.eval(Source.fromFileName(file.getPath()));
             PolyglotEngine.Value main = vm.findGlobalSymbol("main");
             if (main != null) {
-                main.invoke(null);
+                main.execute();
             }
             final String path = file.getCanonicalPath();
             reply.put(REPLMessage.FILE_PATH, path);
--- a/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java	Thu Nov 26 14:22:48 2015 +0100
+++ b/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java	Mon Nov 30 10:24:00 2015 +0100
@@ -192,7 +192,7 @@
  */
 
 /*
- * 
+ *
  * <p> <b>Tools:</b><br> The use of some of Truffle's support for developer tools (based on the
  * Truffle {@linkplain Instrumenter Instrumentation Framework}) are demonstrated in this file, for
  * example: <ul> <li>a {@linkplain NodeExecCounter counter for node executions}, tabulated by node
@@ -259,7 +259,7 @@
             throw new SLException("No function main() defined in SL source file.");
         }
         while (repeats-- > 0) {
-            main.invoke(null);
+            main.execute();
         }
         reportToolDemos();
     }
@@ -307,7 +307,7 @@
                 long start = System.nanoTime();
                 /* Call the main entry point, without any arguments. */
                 try {
-                    result = main.invoke(null).get();
+                    result = main.execute().get();
                     if (result != null) {
                         out.println(result);
                     }
--- a/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/SLForeignToSLTypeNode.java	Thu Nov 26 14:22:48 2015 +0100
+++ b/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/SLForeignToSLTypeNode.java	Mon Nov 30 10:24:00 2015 +0100
@@ -60,22 +60,27 @@
         super(src);
     }
 
+    @Specialization
+    public Object fromObject(Number value) {
+        return SLContext.fromForeignValue(value);
+    }
+
+    @Specialization
+    public Object fromString(String value) {
+        return value;
+    }
+
     @Specialization(guards = "isBoxedPrimitive(frame, value)")
     public Object unbox(VirtualFrame frame, TruffleObject value) {
         Object unboxed = doUnbox(frame, value);
         return SLContext.fromForeignValue(unboxed);
     }
 
-    @Specialization
-    public Object fromTruffleObject(TruffleObject value) {
+    @Specialization(guards = "!isBoxedPrimitive(frame, value)")
+    public Object fromTruffleObject(@SuppressWarnings("unused") VirtualFrame frame, TruffleObject value) {
         return value;
     }
 
-    @Specialization
-    public Object fromObject(Object value) {
-        return SLContext.fromForeignValue(value);
-    }
-
     @Child private Node isBoxed;
 
     protected final boolean isBoxedPrimitive(VirtualFrame frame, TruffleObject object) {
--- a/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java	Thu Nov 26 14:22:48 2015 +0100
+++ b/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java	Mon Nov 30 10:24:00 2015 +0100
@@ -240,6 +240,8 @@
             return ((Number) a).longValue();
         } else if (a instanceof TruffleObject) {
             return a;
+        } else if (a instanceof SLContext) {
+            return a;
         }
         throw new IllegalStateException(a + " is not a Truffle value");
     }
@@ -252,7 +254,7 @@
      * Goes through the other registered languages to find an exported global symbol of the
      * specified name. The expected return type is either <code>TruffleObject</code>, or one of
      * wrappers of Java primitive types ({@link Integer}, {@link Double}).
-     * 
+     *
      * @param name the name of the symbol to search for
      * @return object representing the symbol or <code>null</code>
      */
--- a/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionForeignAccess.java	Thu Nov 26 14:22:48 2015 +0100
+++ b/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionForeignAccess.java	Mon Nov 30 10:24:00 2015 +0100
@@ -40,6 +40,10 @@
  */
 package com.oracle.truffle.sl.runtime;
 
+import static com.oracle.truffle.sl.runtime.SLContext.fromForeignValue;
+
+import java.util.List;
+
 import com.oracle.truffle.api.CallTarget;
 import com.oracle.truffle.api.Truffle;
 import com.oracle.truffle.api.frame.VirtualFrame;
@@ -50,8 +54,6 @@
 import com.oracle.truffle.sl.SLLanguage;
 import com.oracle.truffle.sl.nodes.call.SLDispatchNode;
 import com.oracle.truffle.sl.nodes.call.SLDispatchNodeGen;
-import static com.oracle.truffle.sl.runtime.SLContext.fromForeignValue;
-import java.util.List;
 
 /**
  * Implementation of foreign access for {@link SLFunction}.
@@ -77,6 +79,8 @@
             return Truffle.getRuntime().createCallTarget(new SLForeignNullCheckNode());
         } else if (Message.IS_EXECUTABLE.equals(tree)) {
             return Truffle.getRuntime().createCallTarget(new SLForeignExecutableCheckNode());
+        } else if (Message.IS_BOXED.equals(tree)) {
+            return Truffle.getRuntime().createCallTarget(RootNode.createConstantNode(false));
         } else {
             throw new IllegalArgumentException(tree.toString() + " not supported");
         }
@@ -92,16 +96,8 @@
         @Override
         public Object execute(VirtualFrame frame) {
             SLFunction function = (SLFunction) ForeignAccess.getReceiver(frame);
-            // the calling convention of interop passes the receiver of a
-            // function call (the this object)
-            // as an implicit 1st argument; we need to ignore this argument for SL
             List<Object> args = ForeignAccess.getArguments(frame);
-            Object[] arr;
-            if (args.size() > 0 && args.get(0) instanceof SLContext) {
-                arr = args.subList(1, args.size()).toArray();
-            } else {
-                arr = args.toArray();
-            }
+            Object[] arr = args.toArray();
             for (int i = 0; i < arr.length; i++) {
                 arr[i] = fromForeignValue(arr[i]);
             }
--- a/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLObjectType.java	Thu Nov 26 14:22:48 2015 +0100
+++ b/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLObjectType.java	Mon Nov 30 10:24:00 2015 +0100
@@ -40,14 +40,22 @@
  */
 package com.oracle.truffle.sl.runtime;
 
+import static com.oracle.truffle.sl.runtime.SLContext.fromForeignValue;
+
+import java.util.List;
+
 import com.oracle.truffle.api.CallTarget;
 import com.oracle.truffle.api.Truffle;
+import com.oracle.truffle.api.frame.VirtualFrame;
 import com.oracle.truffle.api.interop.ForeignAccess;
 import com.oracle.truffle.api.interop.Message;
 import com.oracle.truffle.api.interop.TruffleObject;
 import com.oracle.truffle.api.nodes.RootNode;
 import com.oracle.truffle.api.object.DynamicObject;
 import com.oracle.truffle.api.object.ObjectType;
+import com.oracle.truffle.sl.SLLanguage;
+import com.oracle.truffle.sl.nodes.call.SLDispatchNode;
+import com.oracle.truffle.sl.nodes.call.SLDispatchNodeGen;
 import com.oracle.truffle.sl.nodes.interop.SLForeignReadNode;
 import com.oracle.truffle.sl.nodes.interop.SLForeignWriteNode;
 
@@ -110,7 +118,7 @@
 
     @Override
     public CallTarget accessInvoke(int argumentsLength) {
-        return null;
+        return Truffle.getRuntime().createCallTarget(new SLForeignInvokeRootNode());
     }
 
     @Override
@@ -128,4 +136,26 @@
         return SLContext.isSLObject(obj);
     }
 
+    private static class SLForeignInvokeRootNode extends RootNode {
+        @Child private SLDispatchNode dispatch = SLDispatchNodeGen.create();
+
+        public SLForeignInvokeRootNode() {
+            super(SLLanguage.class, null, null);
+        }
+
+        @Override
+        public Object execute(VirtualFrame frame) {
+            DynamicObject receiver = (DynamicObject) ForeignAccess.getReceiver(frame);
+            String name = (String) ForeignAccess.getArguments(frame).get(0);
+            SLFunction function = (SLFunction) receiver.get(name);
+            List<Object> args = ForeignAccess.getArguments(frame);
+            Object[] arr = new Object[args.size() - 1];
+            for (int i = 1; i < args.size(); i++) {
+                arr[i - 1] = fromForeignValue(args.get(i));
+            }
+            Object result = dispatch.executeDispatch(frame, function, arr);
+            return result;
+        }
+    }
+
 }
--- a/truffle/com.oracle.truffle.tck/src/com/oracle/truffle/tck/TruffleTCK.java	Thu Nov 26 14:22:48 2015 +0100
+++ b/truffle/com.oracle.truffle.tck/src/com/oracle/truffle/tck/TruffleTCK.java	Mon Nov 30 10:24:00 2015 +0100
@@ -208,7 +208,7 @@
     /**
      * Name of a function that returns a compound object with members representing certain
      * operations. In the JavaScript the object should look like:
-     * 
+     *
      * <pre>
      * <b>var</b> obj = {
      *   'fourtyTwo': function {@link #fourtyTwo()},
@@ -218,7 +218,7 @@
      * };
      * <b>return</b> obj;
      * </pre>
-     * 
+     *
      * The returned object shall have three functions that will be obtained and used exactly as
      * described in their Javadoc - e.g. {@link #fourtyTwo()}, {@link #plusInt()} and
      * {@link #returnsNull()}. In addition to that there should be one more function
@@ -245,7 +245,7 @@
     public void testFortyTwo() throws Exception {
         PolyglotEngine.Value fourtyTwo = findGlobalSymbol(fourtyTwo());
 
-        Object res = fourtyTwo.invoke(null).get();
+        Object res = fourtyTwo.execute().get();
 
         assert res instanceof Number : "should yield a number, but was: " + res;
 
@@ -268,7 +268,7 @@
     public void testNull() throws Exception {
         PolyglotEngine.Value retNull = findGlobalSymbol(returnsNull());
 
-        Object res = retNull.invoke(null).get();
+        Object res = retNull.execute().get();
 
         assertNull("Should yield real Java null", res);
     }
@@ -277,7 +277,7 @@
     public void testNullCanBeCastToAnything() throws Exception {
         PolyglotEngine.Value retNull = findGlobalSymbol(returnsNull());
 
-        Object res = retNull.invoke(null).as(CompoundObject.class);
+        Object res = retNull.execute().as(CompoundObject.class);
 
         assertNull("Should yield real Java null", res);
     }
@@ -299,7 +299,7 @@
 
         PolyglotEngine.Value plus = findGlobalSymbol(plus(int.class, int.class));
 
-        Number n = plus.invoke(null, a, b).as(Number.class);
+        Number n = plus.execute(a, b).as(Number.class);
         assert a + b == n.intValue() : "The value is correct: (" + a + " + " + b + ") =  " + n.intValue();
     }
 
@@ -310,7 +310,7 @@
 
         PolyglotEngine.Value plus = findGlobalSymbol(plus(byte.class, byte.class));
 
-        Number n = plus.invoke(null, (byte) a, (byte) b).as(Number.class);
+        Number n = plus.execute((byte) a, (byte) b).as(Number.class);
         assert a + b == n.intValue() : "The value is correct: (" + a + " + " + b + ") =  " + n.intValue();
     }
 
@@ -321,7 +321,7 @@
 
         PolyglotEngine.Value plus = findGlobalSymbol(plus(short.class, short.class));
 
-        Number n = plus.invoke(null, (short) a, (short) b).as(Number.class);
+        Number n = plus.execute((short) a, (short) b).as(Number.class);
         assert a + b == n.intValue() : "The value is correct: (" + a + " + " + b + ") =  " + n.intValue();
     }
 
@@ -332,7 +332,7 @@
 
         PolyglotEngine.Value plus = findGlobalSymbol(plus(long.class, long.class));
 
-        Number n = plus.invoke(null, a, b).as(Number.class);
+        Number n = plus.execute(a, b).as(Number.class);
         assert a + b == n.longValue() : "The value is correct: (" + a + " + " + b + ") =  " + n.longValue();
     }
 
@@ -343,7 +343,7 @@
 
         PolyglotEngine.Value plus = findGlobalSymbol(plus(float.class, float.class));
 
-        Number n = plus.invoke(null, a, b).as(Number.class);
+        Number n = plus.execute(a, b).as(Number.class);
         assertEquals("Correct value computed", a + b, n.floatValue(), 0.01f);
     }
 
@@ -354,7 +354,7 @@
 
         PolyglotEngine.Value plus = findGlobalSymbol(plus(float.class, float.class));
 
-        Number n = plus.invoke(null, a, b).as(Number.class);
+        Number n = plus.execute(a, b).as(Number.class);
         assertEquals("Correct value computed", a + b, n.doubleValue(), 0.01);
     }
 
@@ -385,7 +385,7 @@
         PolyglotEngine.Value apply = findGlobalSymbol(applyNumbers());
 
         TruffleObject fn = JavaInterop.asTruffleFunction(LongBinaryOperation.class, new MaxMinObject(true));
-        Object res = apply.invoke(null, fn).get();
+        Object res = apply.execute(fn).get();
 
         assert res instanceof Number : "result should be a number: " + res;
 
@@ -399,7 +399,7 @@
         PolyglotEngine.Value apply = findGlobalSymbol(applyNumbers());
 
         TruffleObject fn = JavaInterop.asTruffleFunction(LongBinaryOperation.class, new MaxMinObject(false));
-        final PolyglotEngine.Value result = apply.invoke(null, fn);
+        final PolyglotEngine.Value result = apply.execute(fn);
 
         try {
             Boolean res = result.as(Boolean.class);
@@ -419,7 +419,7 @@
         byte value = (byte) RANDOM.nextInt(100);
 
         TruffleObject fn = JavaInterop.asTruffleFunction(ObjectBinaryOperation.class, new ConstantFunction(value));
-        Number n = apply.invoke(null, fn).as(Number.class);
+        Number n = apply.execute(fn).as(Number.class);
         assertEquals("The same value returned", value + 10, n.byteValue());
     }
 
@@ -430,7 +430,7 @@
         short value = (short) RANDOM.nextInt(100);
 
         TruffleObject fn = JavaInterop.asTruffleFunction(ObjectBinaryOperation.class, new ConstantFunction(value));
-        Number n = apply.invoke(null, fn).as(Number.class);
+        Number n = apply.execute(fn).as(Number.class);
         assertEquals("The same value returned", value + 10, n.shortValue());
     }
 
@@ -441,7 +441,7 @@
         int value = RANDOM.nextInt(100);
 
         TruffleObject fn = JavaInterop.asTruffleFunction(ObjectBinaryOperation.class, new ConstantFunction(value));
-        Number n = apply.invoke(null, fn).as(Number.class);
+        Number n = apply.execute(fn).as(Number.class);
         assertEquals("The same value returned", value + 10, n.intValue());
     }
 
@@ -452,7 +452,7 @@
         long value = RANDOM.nextInt(1000);
 
         TruffleObject fn = JavaInterop.asTruffleFunction(ObjectBinaryOperation.class, new ConstantFunction(value));
-        Number n = apply.invoke(null, fn).as(Number.class);
+        Number n = apply.execute(fn).as(Number.class);
         assertEquals("The same value returned", value + 10, n.longValue());
     }
 
@@ -463,7 +463,7 @@
         float value = RANDOM.nextInt(1000) + RANDOM.nextFloat();
 
         TruffleObject fn = JavaInterop.asTruffleFunction(ObjectBinaryOperation.class, new ConstantFunction(value));
-        Number n = apply.invoke(null, fn).as(Number.class);
+        Number n = apply.execute(fn).as(Number.class);
         assertEquals("The same value returned", value + 10, n.floatValue(), 0.01);
     }
 
@@ -474,7 +474,7 @@
         double value = RANDOM.nextInt(1000) + RANDOM.nextDouble();
 
         TruffleObject fn = JavaInterop.asTruffleFunction(ObjectBinaryOperation.class, new ConstantFunction(value));
-        Number n = apply.invoke(null, fn).as(Number.class);
+        Number n = apply.execute(fn).as(Number.class);
         assertEquals("The same value returned", value + 10, n.doubleValue(), 0.01);
     }
 
@@ -488,7 +488,22 @@
 
         byte value = (byte) RANDOM.nextInt(100);
 
-        Number n = (Number) apply.invoke(null, value).get();
+        Number n = (Number) apply.execute(value).get();
+        assertEquals("The same value returned", value, n.byteValue());
+    }
+
+    @Test
+    public void testPrimitiveidentityBoxedByte() throws Exception {
+        String id = identity();
+        if (id == null) {
+            return;
+        }
+        PolyglotEngine.Value apply = findGlobalSymbol(id);
+
+        byte value = (byte) RANDOM.nextInt(100);
+        BoxedValue boxed = new BoxedValue(value);
+
+        Number n = (Number) apply.execute(boxed).get();
         assertEquals("The same value returned", value, n.byteValue());
     }
 
@@ -501,7 +516,22 @@
         PolyglotEngine.Value apply = findGlobalSymbol(id);
 
         short value = (short) RANDOM.nextInt(100);
-        Number n = (Number) apply.invoke(null, value).get();
+        Number n = (Number) apply.execute(value).get();
+        assertEquals("The same value returned", value, n.shortValue());
+    }
+
+    @Test
+    public void testPrimitiveidentityBoxedShort() throws Exception {
+        String id = identity();
+        if (id == null) {
+            return;
+        }
+        PolyglotEngine.Value apply = findGlobalSymbol(id);
+
+        short value = (short) RANDOM.nextInt(100);
+        BoxedValue boxed = new BoxedValue(value);
+
+        Number n = (Number) apply.execute(boxed).get();
         assertEquals("The same value returned", value, n.shortValue());
     }
 
@@ -515,7 +545,22 @@
 
         int value = RANDOM.nextInt(100);
 
-        Number n = (Number) apply.invoke(null, value).get();
+        Number n = (Number) apply.execute(value).get();
+        assertEquals("The same value returned", value, n.intValue());
+    }
+
+    @Test
+    public void testPrimitiveidentityBoxedInt() throws Exception {
+        String id = identity();
+        if (id == null) {
+            return;
+        }
+        PolyglotEngine.Value apply = findGlobalSymbol(id);
+
+        int value = RANDOM.nextInt(100);
+        BoxedValue boxed = new BoxedValue(value);
+
+        Number n = (Number) apply.execute(boxed).get();
         assertEquals("The same value returned", value, n.intValue());
     }
 
@@ -529,7 +574,22 @@
 
         long value = RANDOM.nextInt(1000);
 
-        Number n = (Number) apply.invoke(null, value).get();
+        Number n = (Number) apply.execute(value).get();
+        assertEquals("The same value returned", value, n.longValue());
+    }
+
+    @Test
+    public void testPrimitiveidentityBoxedLong() throws Exception {
+        String id = identity();
+        if (id == null) {
+            return;
+        }
+        PolyglotEngine.Value apply = findGlobalSymbol(id);
+
+        long value = RANDOM.nextInt(1000);
+        BoxedValue boxed = new BoxedValue(value);
+
+        Number n = (Number) apply.execute(boxed).get();
         assertEquals("The same value returned", value, n.longValue());
     }
 
@@ -543,7 +603,22 @@
 
         float value = RANDOM.nextInt(1000) + RANDOM.nextFloat();
 
-        Number n = (Number) apply.invoke(null, value).get();
+        Number n = (Number) apply.execute(value).get();
+        assertEquals("The same value returned", value, n.floatValue(), 0.01);
+    }
+
+    @Test
+    public void testPrimitiveidentityBoxedFloat() throws Exception {
+        String id = identity();
+        if (id == null) {
+            return;
+        }
+        PolyglotEngine.Value apply = findGlobalSymbol(id);
+
+        float value = RANDOM.nextInt(1000) + RANDOM.nextFloat();
+        BoxedValue boxed = new BoxedValue(value);
+
+        Number n = (Number) apply.execute(boxed).get();
         assertEquals("The same value returned", value, n.floatValue(), 0.01);
     }
 
@@ -557,11 +632,55 @@
 
         double value = RANDOM.nextInt(1000) + RANDOM.nextDouble();
 
-        Number n = (Number) apply.invoke(null, value).get();
+        Number n = (Number) apply.execute(value).get();
+        assertEquals("The same value returned", value, n.doubleValue(), 0.01);
+    }
+
+    @Test
+    public void testPrimitiveidentityBoxedDouble() throws Exception {
+        String id = identity();
+        if (id == null) {
+            return;
+        }
+        PolyglotEngine.Value apply = findGlobalSymbol(id);
+
+        double value = RANDOM.nextInt(1000) + RANDOM.nextDouble();
+        BoxedValue boxed = new BoxedValue(value);
+
+        Number n = (Number) apply.execute(boxed).get();
         assertEquals("The same value returned", value, n.doubleValue(), 0.01);
     }
 
     @Test
+    public void testPrimitiveidentityString() throws Exception {
+        String id = identity();
+        if (id == null) {
+            return;
+        }
+        PolyglotEngine.Value apply = findGlobalSymbol(id);
+
+        String value = "Value" + RANDOM.nextInt(1000) + RANDOM.nextDouble();
+
+        String ret = (String) apply.execute(value).get();
+        assertEquals("The same value returned", value, ret);
+    }
+
+    @Test
+    public void testPrimitiveidentityBoxedString() throws Exception {
+        String id = identity();
+        if (id == null) {
+            return;
+        }
+        PolyglotEngine.Value apply = findGlobalSymbol(id);
+
+        String value = "Value" + RANDOM.nextInt(1000) + RANDOM.nextDouble();
+        BoxedValue boxed = new BoxedValue(value);
+
+        String ret = (String) apply.execute(boxed).get();
+        assertEquals("The same value returned", value, ret);
+    }
+
+    @Test
     public void testPrimitiveIdentityForeignObject() throws Exception {
         String id = identity();
         if (id == null) {
@@ -571,7 +690,7 @@
 
         TruffleObject fn = JavaInterop.asTruffleFunction(LongBinaryOperation.class, new MaxMinObject(true));
 
-        Object ret = apply.invoke(null, fn).get();
+        Object ret = apply.execute(fn).get();
         assertSameTruffleObject("The same value returned", fn, ret);
     }
 
@@ -591,13 +710,13 @@
         for (int i = 0; i < 10; i++) {
             int quantum = RANDOM.nextInt(10);
             for (int j = 0; j < quantum; j++) {
-                Object res = count1.invoke(null).get();
+                Object res = count1.execute().get();
                 assert res instanceof Number : "expecting number: " + res;
                 ++prev1;
                 assert ((Number) res).intValue() == prev1 : "expecting " + prev1 + " but was " + res;
             }
             for (int j = 0; j < quantum; j++) {
-                Object res = count2.invoke(null).get();
+                Object res = count2.execute().get();
                 assert res instanceof Number : "expecting number: " + res;
                 ++prev2;
                 assert ((Number) res).intValue() == prev2 : "expecting " + prev2 + " but was " + res;
@@ -617,7 +736,7 @@
         assertNotNull("Langugage for " + mimeType() + " found", language);
 
         PolyglotEngine.Value function = vm().findGlobalSymbol(globalObjectFunction);
-        Object global = function.invoke(null).get();
+        Object global = function.execute().get();
         assertEquals("Global from the language same with Java obtained one", language.getGlobalObject().get(), global);
     }
 
@@ -630,7 +749,7 @@
         assertNotNull(evaluateSource() + " found", function);
 
         double expect = Math.floor(RANDOM.nextDouble() * 100000.0) / 10.0;
-        Object parsed = function.invoke(null, "application/x-tck", "" + expect).get();
+        Object parsed = function.execute("application/x-tck", "" + expect).get();
         assertTrue("Expecting numeric result, was:" + expect, parsed instanceof Number);
         double value = ((Number) parsed).doubleValue();
         assertEquals("Gets the double", expect, value, 0.01);
@@ -643,7 +762,7 @@
         String mulCode = multiplyCode(firstVar, secondVar);
         Source source = Source.fromText("TCK42:" + mimeType() + ":" + mulCode, "evaluate " + firstVar + " * " + secondVar).withMimeType("application/x-tck");
         final PolyglotEngine.Value evalSource = vm().eval(source);
-        final PolyglotEngine.Value invokeMul = evalSource.invoke(null, firstVar, secondVar);
+        final PolyglotEngine.Value invokeMul = evalSource.execute(firstVar, secondVar);
         Object result = invokeMul.get();
         assertTrue("Expecting numeric result, was:" + result, result instanceof Number);
         assertEquals("Right value", 42, ((Number) result).intValue());
@@ -659,7 +778,7 @@
         final String compoundObjectName = compoundObject();
         PolyglotEngine.Value s = vm().findGlobalSymbol(compoundObjectName);
         assert s != null : "Symbol " + compoundObjectName + " is not found!";
-        final PolyglotEngine.Value value = s.invoke(null);
+        final PolyglotEngine.Value value = s.execute();
         CompoundObject obj = value.as(CompoundObject.class);
         assertNotNull("Compound object for " + value + " found", obj);
         int traverse = RANDOM.nextInt(10);