changeset 21024:e4a8c886515f

Merge
author Stefan Anzinger <stefan.anzinger@oracle.com>
date Mon, 20 Apr 2015 15:31:36 +0200
parents 3ceda1f37dcc (current diff) 81e91799d6a1 (diff)
children 3fe33ec624ea
files
diffstat 31 files changed, 1032 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.directives/src/com/oracle/graal/api/directives/GraalDirectives.java	Mon Apr 20 14:58:45 2015 +0200
+++ b/graal/com.oracle.graal.api.directives/src/com/oracle/graal/api/directives/GraalDirectives.java	Mon Apr 20 15:31:36 2015 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.api.directives;
 
+// JaCoCo Exclude
+
 /**
  * Directives that influence the compilation of methods by Graal. They don't influence the semantics
  * of the code, but they are useful for unit testing and benchmarking.
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/LocationIdentity.java	Mon Apr 20 14:58:45 2015 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/LocationIdentity.java	Mon Apr 20 15:31:36 2015 +0200
@@ -24,6 +24,8 @@
 
 import java.util.*;
 
+// JaCoCo Exclude
+
 /**
  * Marker interface for location identities. Apart from the special values {@link #ANY_LOCATION} and
  * {@link #FINAL_LOCATION}, a different location identity of two memory accesses guarantees that the
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AESCryptSubstitutions.java	Mon Apr 20 14:58:45 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AESCryptSubstitutions.java	Mon Apr 20 15:31:36 2015 +0200
@@ -36,6 +36,8 @@
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.word.*;
 
+// JaCoCo Exclude
+
 /**
  * Substitutions for {@code com.sun.crypto.provider.AESCrypt} methods.
  */
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java	Mon Apr 20 14:58:45 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java	Mon Apr 20 15:31:36 2015 +0200
@@ -36,6 +36,8 @@
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.word.*;
 
+// JaCoCo Exclude
+
 /**
  * Substitutions for {@code com.sun.crypto.provider.CipherBlockChaining} methods.
  */
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectSubstitutions.java	Mon Apr 20 14:58:45 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectSubstitutions.java	Mon Apr 20 15:31:36 2015 +0200
@@ -24,6 +24,8 @@
 
 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
 
+// JaCoCo Exclude
+
 /**
  * Substitutions for {@link java.lang.Object} methods.
  */
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LocationMarker.java	Mon Apr 20 14:58:45 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LocationMarker.java	Mon Apr 20 15:31:36 2015 +0200
@@ -30,7 +30,6 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.common.cfg.*;
 import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.LIRInstruction.OperandFlag;
 import com.oracle.graal.lir.LIRInstruction.OperandMode;
@@ -292,17 +291,9 @@
                 info.initDebugInfo(frameMap, !op.destroysCallerSavedRegisters() || !frameMap.getRegisterConfig().areAllAllocatableRegistersCallerSaved());
             }
 
-            try (Scope s = Debug.scope("markLocation", op)) {
-                ReferenceMap refMap = info.debugInfo().getReferenceMap();
-                for (Value v : values) {
-                    try (Scope x = Debug.scope("loop", v)) {
-                        frameMap.setReference(v, refMap);
-                    } catch (Throwable e) {
-                        throw Debug.handle(e);
-                    }
-                }
-            } catch (Throwable e) {
-                throw Debug.handle(e);
+            ReferenceMap refMap = info.debugInfo().getReferenceMap();
+            for (Value v : values) {
+                frameMap.setReference(v, refMap);
             }
         }
 
--- a/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64MathSubstitutions.java	Mon Apr 20 14:58:45 2015 +0200
+++ b/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64MathSubstitutions.java	Mon Apr 20 15:31:36 2015 +0200
@@ -30,6 +30,8 @@
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.replacements.amd64.AMD64MathIntrinsicNode.Operation;
 
+// JaCoCo Exclude
+
 /**
  * Substitutions for some {@link java.lang.Math} methods that leverage AMD64 instructions for
  * selected input values.
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java	Mon Apr 20 14:58:45 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java	Mon Apr 20 15:31:36 2015 +0200
@@ -28,6 +28,8 @@
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.java.*;
 
+// JaCoCo Exclude
+
 /**
  * Substitutions for {@link java.lang.reflect.Array} methods.
  */
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraysSubstitutions.java	Mon Apr 20 14:58:45 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraysSubstitutions.java	Mon Apr 20 15:31:36 2015 +0200
@@ -24,6 +24,8 @@
 
 import com.oracle.graal.replacements.nodes.*;
 
+// JaCoCo Exclude
+
 /**
  * Substitutions for {@link java.util.Arrays} methods.
  */
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/LongSubstitutions.java	Mon Apr 20 14:58:45 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/LongSubstitutions.java	Mon Apr 20 15:31:36 2015 +0200
@@ -24,6 +24,8 @@
 
 import com.oracle.graal.replacements.nodes.*;
 
+// JaCoCo Exclude
+
 public class LongSubstitutions {
 
     public static int numberOfLeadingZeros(long i) {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StringSubstitutions.java	Mon Apr 20 14:58:45 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StringSubstitutions.java	Mon Apr 20 15:31:36 2015 +0200
@@ -28,6 +28,8 @@
 
 import edu.umd.cs.findbugs.annotations.*;
 
+// JaCoCo Exclude
+
 /**
  * Substitutions for {@link java.lang.String} methods.
  */
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ArrayEqualsNode.java	Mon Apr 20 14:58:45 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ArrayEqualsNode.java	Mon Apr 20 15:31:36 2015 +0200
@@ -32,6 +32,8 @@
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.util.*;
 
+// JaCoCo Exclude
+
 /**
  * Compares two arrays with the same length.
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/ForeignAccessArguments.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop;
+
+import com.oracle.truffle.api.*;
+
+public final class ForeignAccessArguments {
+    public static final Object[] EMPTY_ARGUMENTS_ARRAY = new Object[0];
+    public static final int RECEIVER_INDEX = 0;
+    public static final int RUNTIME_ARGUMENT_COUNT = 1;
+
+    public static Object[] create(Object receiver) {
+        return new Object[]{receiver};
+    }
+
+    public static Object[] create(Object receiver, Object[] arguments) {
+        Object[] objectArguments = new Object[RUNTIME_ARGUMENT_COUNT + arguments.length];
+        objectArguments[RECEIVER_INDEX] = receiver;
+        arraycopy(arguments, 0, objectArguments, RUNTIME_ARGUMENT_COUNT, arguments.length);
+        return objectArguments;
+    }
+
+    public static Object getArgument(Object[] arguments, int index) {
+        return arguments[RUNTIME_ARGUMENT_COUNT + index];
+    }
+
+    public static Object getReceiver(Object[] arguments) {
+        return arguments[RECEIVER_INDEX];
+    }
+
+    public static Object[] extractUserArguments(Object[] arguments) {
+        return copyOfRange(arguments, RUNTIME_ARGUMENT_COUNT, arguments.length);
+    }
+
+    public static int getUserArgumentCount(Object[] arguments) {
+        return arguments.length - RUNTIME_ARGUMENT_COUNT;
+    }
+
+    private static Object[] copyOfRange(Object[] original, int from, int to) {
+        int newLength = to - from;
+        if (newLength < 0) {
+            CompilerDirectives.transferToInterpreter();
+            throw new IllegalArgumentException(from + " > " + to);
+        }
+        Object[] copy = new Object[newLength];
+        arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength));
+        return copy;
+    }
+
+    private static void arraycopy(Object[] src, int srcPos, Object[] dest, int destPos, int length) {
+        for (int i = 0; i < length; i++) {
+            dest[destPos + i] = src[srcPos + i];
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/TruffleLanguage.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop;
+
+import com.oracle.truffle.api.interop.*;
+
+public interface TruffleLanguage {
+    String getLanguageName();
+
+    TruffleObject getLanguageContext();
+
+    void setGlobalContext(TruffleObject context);
+
+    boolean hasGlobalProperty(String name);
+
+    Object run(String[] arguments);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/messages/Argument.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop.messages;
+
+public final class Argument {
+    private Argument() {
+    }
+
+    public static Argument create() {
+        return new Argument();
+    }
+
+    @Override
+    public String toString() {
+        return String.format("Argument");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/messages/Execute.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop.messages;
+
+import com.oracle.truffle.api.interop.messages.*;
+
+public final class Execute implements Message {
+    private final Object receiver;
+    private final int arity;
+
+    public static Execute create(Receiver receiver, int arity) {
+        return new Execute(receiver, arity);
+    }
+
+    public static Execute create(Message receiver, int arity) {
+        return new Execute(receiver, arity);
+    }
+
+    private Execute(Object receiver, int arity) {
+        this.receiver = receiver;
+        this.arity = arity;
+    }
+
+    public Object getReceiver() {
+        return receiver;
+    }
+
+    public int getArity() {
+        return arity;
+    }
+
+    public boolean matchStructure(Object message) {
+        if (!(message instanceof Execute)) {
+            return false;
+        }
+        Execute m1 = this;
+        Execute m2 = (Execute) message;
+        return MessageUtil.compareMessage(m1.getReceiver(), m2.getReceiver());
+    }
+
+    @Override
+    public String toString() {
+        return String.format("Execute(%s)", receiver.toString());
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/messages/GetSize.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop.messages;
+
+import com.oracle.truffle.api.interop.messages.*;
+
+public final class GetSize extends UnaryMessage {
+
+    public static GetSize create(Receiver receiver) {
+        return new GetSize(receiver);
+    }
+
+    public static GetSize create(Message receiver) {
+        return new GetSize(receiver);
+    }
+
+    private GetSize(Object receiver) {
+        super(receiver);
+    }
+
+    @Override
+    public String toString() {
+        return String.format("GetSize(%s)", receiver.toString());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/messages/HasSize.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop.messages;
+
+import com.oracle.truffle.api.interop.messages.*;
+
+public final class HasSize extends UnaryMessage {
+    public static HasSize create(Receiver receiver) {
+        return new HasSize(receiver);
+    }
+
+    public static HasSize create(Message receiver) {
+        return new HasSize(receiver);
+    }
+
+    private HasSize(Object receiver) {
+        super(receiver);
+    }
+
+    @Override
+    public String toString() {
+        return String.format("HasSize(%s)", receiver.toString());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/messages/IsBoxed.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop.messages;
+
+import com.oracle.truffle.api.interop.messages.*;
+
+public final class IsBoxed extends UnaryMessage {
+    public static IsBoxed create(Receiver receiver) {
+        return new IsBoxed(receiver);
+    }
+
+    public static IsBoxed create(Message receiver) {
+        return new IsBoxed(receiver);
+    }
+
+    private IsBoxed(Object receiver) {
+        super(receiver);
+    }
+
+    @Override
+    public String toString() {
+        return String.format("IsBoxed(%s)", receiver.toString());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/messages/IsExecutable.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop.messages;
+
+import com.oracle.truffle.api.interop.messages.*;
+
+public final class IsExecutable extends UnaryMessage {
+    public static IsExecutable create(Receiver receiver) {
+        return new IsExecutable(receiver);
+    }
+
+    public static IsExecutable create(Message receiver) {
+        return new IsExecutable(receiver);
+    }
+
+    private IsExecutable(Object receiver) {
+        super(receiver);
+    }
+
+    @Override
+    public String toString() {
+        return String.format("IsExecutable(%s)", receiver.toString());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/messages/IsNull.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop.messages;
+
+import com.oracle.truffle.api.interop.messages.*;
+
+public final class IsNull extends UnaryMessage {
+    public static IsNull create(Receiver receiver) {
+        return new IsNull(receiver);
+    }
+
+    public static IsNull create(Message receiver) {
+        return new IsNull(receiver);
+    }
+
+    private IsNull(Object receiver) {
+        super(receiver);
+    }
+
+    @Override
+    public String toString() {
+        return String.format("IsNull(%s)", receiver.toString());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/messages/MessageUtil.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop.messages;
+
+import com.oracle.truffle.api.interop.messages.*;
+
+final class MessageUtil {
+
+    static boolean compareMessage(Object o1, Object o2) {
+        if (o1 instanceof Message && o2 instanceof Message) {
+            return ((Message) o1).matchStructure(o2);
+        } else if (o1 instanceof Receiver && o2 instanceof Receiver) {
+            return true;
+        }
+        throw new IllegalStateException();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/messages/Read.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop.messages;
+
+import com.oracle.truffle.api.interop.messages.*;
+
+public final class Read implements Message {
+    private final Object receiver;
+    private final Argument id;
+
+    private Read(Object receiver, Argument id) {
+        this.receiver = receiver;
+        this.id = id;
+    }
+
+    public static Read create(Receiver receiver, Argument id) {
+        return new Read(receiver, id);
+    }
+
+    public static Read create(Message receiver, Argument id) {
+        return new Read(receiver, id);
+    }
+
+    public Argument getId() {
+        return id;
+    }
+
+    public Object getReceiver() {
+        return receiver;
+    }
+
+    public boolean matchStructure(Object message) {
+        if (!(message instanceof Read)) {
+            return false;
+        }
+        Read m1 = this;
+        Read m2 = (Read) message;
+        return MessageUtil.compareMessage(m1.getReceiver(), m2.getReceiver());
+    }
+
+    @Override
+    public String toString() {
+        return String.format("Read(%s, %s)", receiver.toString(), id.toString());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/messages/Receiver.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop.messages;
+
+public final class Receiver {
+
+    private Receiver() {
+
+    }
+
+    public static Receiver create() {
+        return new Receiver();
+    }
+
+    @Override
+    public String toString() {
+        return String.format("Receiver");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/messages/UnaryMessage.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop.messages;
+
+import com.oracle.truffle.api.interop.messages.*;
+
+abstract class UnaryMessage implements Message {
+    protected final Object receiver;
+
+    protected UnaryMessage(Object receiver) {
+        this.receiver = receiver;
+    }
+
+    public Object getReceiver() {
+        return receiver;
+    }
+
+    public boolean matchStructure(Object message) {
+        if (message == null) {
+            return false;
+        }
+        if (this.getClass() != message.getClass()) {
+            return false;
+        }
+        UnaryMessage m1 = this;
+        UnaryMessage m2 = (UnaryMessage) message;
+        return MessageUtil.compareMessage(m1.getReceiver(), m2.getReceiver());
+    }
+
+    @Override
+    public abstract String toString();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/messages/Unbox.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop.messages;
+
+import com.oracle.truffle.api.interop.messages.*;
+
+public final class Unbox extends UnaryMessage {
+    public static Unbox create(Receiver receiver) {
+        return new Unbox(receiver);
+    }
+
+    public static Unbox create(Message receiver) {
+        return new Unbox(receiver);
+    }
+
+    private Unbox(Object receiver) {
+        super(receiver);
+    }
+
+    @Override
+    public String toString() {
+        return String.format("Unbox(%s)", receiver.toString());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/messages/Write.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop.messages;
+
+import com.oracle.truffle.api.interop.messages.*;
+
+public final class Write implements Message {
+    private final Object receiver;
+    private final Argument id;
+    private final Argument value;
+
+    private Write(Object receiver, Argument id, Argument value) {
+        this.receiver = receiver;
+        this.id = id;
+        this.value = value;
+    }
+
+    public static Write create(Receiver receiver, Argument id, Argument value) {
+        return new Write(receiver, id, value);
+    }
+
+    public static Write create(Message receiver, Argument id, Argument value) {
+        return new Write(receiver, id, value);
+    }
+
+    public Argument getId() {
+        return id;
+    }
+
+    public Object getReceiver() {
+        return receiver;
+    }
+
+    public Argument getValue() {
+        return value;
+    }
+
+    public boolean matchStructure(Object message) {
+        if (!(message instanceof Write)) {
+            return false;
+        }
+        Write m1 = this;
+        Write m2 = (Write) message;
+        return MessageUtil.compareMessage(m1.getReceiver(), m2.getReceiver());
+    }
+
+    @Override
+    public String toString() {
+        return String.format("Write(%s, %s, %s)", receiver.toString(), id.toString(), value.toString());
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/node/ForeignObjectAccessHeadNode.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.truffle.interop.node;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.interop.*;
+import com.oracle.truffle.api.interop.messages.*;
+
+final class ForeignObjectAccessHeadNode extends ForeignObjectAccessNode {
+
+    @Child private ObjectAccessNode first;
+    private final Message accessTree;
+
+    protected ForeignObjectAccessHeadNode(Message tree) {
+        this.accessTree = tree;
+        this.first = new UnresolvedObjectAccessNode();
+        adoptChildren();
+    }
+
+    protected Message getAccessTree() {
+        return accessTree;
+    }
+
+    protected ObjectAccessNode getFirst() {
+        return first;
+    }
+
+    @Override
+    public Object executeForeign(VirtualFrame frame, TruffleObject receiver, Object... arguments) {
+        return first.executeWith(frame, receiver, arguments);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/node/ForeignObjectAccessNode.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.truffle.interop.node;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.interop.*;
+import com.oracle.truffle.api.interop.messages.*;
+import com.oracle.truffle.api.nodes.*;
+
+public abstract class ForeignObjectAccessNode extends Node {
+
+    public static ForeignObjectAccessNode getAccess(Message tree) {
+        return new ForeignObjectAccessHeadNode(tree);
+    }
+
+    public abstract Object executeForeign(VirtualFrame frame, TruffleObject receiver, Object... arguments);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/node/ObjectAccessNode.java	Mon Apr 20 15:31:36 2015 +0200
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.interop.node;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.interop.*;
+import com.oracle.truffle.api.interop.InteropPredicate;
+import com.oracle.truffle.api.interop.messages.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.interop.*;
+
+abstract class ObjectAccessNode extends Node {
+
+    public abstract Object executeWith(VirtualFrame frame, TruffleObject receiver, Object[] arguments);
+
+}
+
+class UnresolvedObjectAccessNode extends ObjectAccessNode {
+
+    private static final int CACHE_SIZE = 8;
+    private int cacheLength = 1;
+
+    @Override
+    public Object executeWith(VirtualFrame frame, TruffleObject receiver, Object[] arguments) {
+        CompilerDirectives.transferToInterpreterAndInvalidate();
+        ForeignObjectAccessHeadNode nthParent = (ForeignObjectAccessHeadNode) NodeUtil.getNthParent(this, cacheLength);
+        ObjectAccessNode first = nthParent.getFirst();
+        if (cacheLength < CACHE_SIZE) {
+            cacheLength++;
+            CachedObjectAccessNode createCachedAccess = createCachedAccess(receiver, nthParent.getAccessTree(), first);
+            return first.replace(createCachedAccess).executeWith(frame, receiver, arguments);
+        } else {
+            return first.replace(createGenericAccess(nthParent.getAccessTree())).executeWith(frame, receiver, arguments);
+        }
+    }
+
+    private static CachedObjectAccessNode createCachedAccess(TruffleObject receiver, Message accessTree, ObjectAccessNode next) {
+        ForeignAccessFactory accessFactory = receiver.getForeignAccessFactory();
+        return new CachedObjectAccessNode(Truffle.getRuntime().createDirectCallNode(accessFactory.getAccess(accessTree)), next, accessFactory.getLanguageCheck());
+    }
+
+    private static GenericObjectAccessNode createGenericAccess(Message access) {
+        return new GenericObjectAccessNode(access);
+    }
+}
+
+class GenericObjectAccessNode extends ObjectAccessNode {
+
+    private final Message access;
+    @Child private IndirectCallNode indirectCallNode;
+
+    public GenericObjectAccessNode(Message access) {
+        this.access = access;
+        indirectCallNode = Truffle.getRuntime().createIndirectCallNode();
+    }
+
+    public GenericObjectAccessNode(GenericObjectAccessNode prev) {
+        this(prev.access);
+    }
+
+    @Override
+    public Object executeWith(VirtualFrame frame, TruffleObject truffleObject, Object[] arguments) {
+        return indirectCallNode.call(frame, truffleObject.getForeignAccessFactory().getAccess(access), ForeignAccessArguments.create(truffleObject, arguments));
+    }
+}
+
+class CachedObjectAccessNode extends ObjectAccessNode {
+    @Child private DirectCallNode callTarget;
+    @Child private ObjectAccessNode next;
+
+    private final InteropPredicate languageCheck;
+
+    protected CachedObjectAccessNode(DirectCallNode callTarget, ObjectAccessNode next, InteropPredicate languageCheck) {
+        this.callTarget = callTarget;
+        this.next = next;
+        this.languageCheck = languageCheck;
+        this.callTarget.forceInlining();
+    }
+
+    protected CachedObjectAccessNode(CachedObjectAccessNode prev) {
+        this(prev.callTarget, prev.next, prev.languageCheck);
+    }
+
+    @Override
+    public Object executeWith(VirtualFrame frame, TruffleObject receiver, Object[] arguments) {
+        return doAccess(frame, receiver, arguments);
+    }
+
+    private Object doAccess(VirtualFrame frame, TruffleObject receiver, Object[] arguments) {
+        if (languageCheck.test(receiver)) {
+            return callTarget.call(frame, ForeignAccessArguments.create(receiver, arguments));
+        } else {
+            return doNext(frame, receiver, arguments);
+        }
+    }
+
+    private Object doNext(VirtualFrame frame, TruffleObject receiver, Object[] arguments) {
+        return next.executeWith(frame, receiver, arguments);
+    }
+}
--- a/mx/suite.py	Mon Apr 20 14:58:45 2015 +0200
+++ b/mx/suite.py	Mon Apr 20 15:31:36 2015 +0200
@@ -587,7 +587,6 @@
         "com.oracle.graal.service.processor",
       ],
       "workingSets" : "Graal,Replacements",
-      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.replacements.amd64" : {
@@ -1003,6 +1002,15 @@
       "workingSets" : "API,Truffle",
     },
 
+    "com.oracle.truffle.interop" : {
+      "subDir" : "graal",
+      "sourceDirs" : ["src"],
+      "dependencies" : ["com.oracle.truffle.api.interop"],
+      "javaCompliance" : "1.7",
+      "workingSets" : "Truffle",
+      "checkstyle" : "com.oracle.truffle.api",
+    },
+
     "com.oracle.truffle.api.object" : {
       "subDir" : "graal",
       "sourceDirs" : ["src"],
@@ -1156,6 +1164,7 @@
       "dependencies" : [
         "com.oracle.truffle.api.dsl",
         "com.oracle.nfi",
+        "com.oracle.truffle.interop",
         "com.oracle.truffle.object.basic",
       ],
     },