changeset 19312:a8d128366ebf

Merge
author Andreas Woess <andreas.woess@jku.at>
date Thu, 12 Feb 2015 04:01:46 +0100
parents a0a760b0fb5f (current diff) b54b548047ac (diff)
children a7247418a58b
files graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadFinalNode.java
diffstat 16 files changed, 752 insertions(+), 747 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java	Thu Feb 12 01:54:05 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java	Thu Feb 12 04:01:46 2015 +0100
@@ -22,13 +22,11 @@
  */
 package com.oracle.graal.truffle;
 
-import java.nio.*;
 import java.lang.reflect.*;
 import java.util.*;
 
 import sun.misc.*;
 
-import com.oracle.graal.api.meta.*;
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
 
@@ -107,9 +105,9 @@
     }
 
     private byte getByteUnsafe(FrameSlot slot) {
-        long offset = alignPrimitive(slot, Kind.Byte);
+        long offset = getPrimitiveOffset(slot);
         boolean condition = this.getTags()[slot.getIndex()] == FrameSlotKind.Byte.ordinal();
-        return unsafeGetByte(getPrimitiveLocals(), offset, condition, slot);
+        return (byte) unsafeGetInt(getPrimitiveLocals(), offset, condition, slot);
     }
 
     @Override
@@ -119,8 +117,8 @@
     }
 
     private void setByteUnsafe(FrameSlot slot, byte value) {
-        long offset = alignPrimitive(slot, Kind.Boolean);
-        unsafePutByte(getPrimitiveLocals(), offset, value, slot);
+        long offset = getPrimitiveOffset(slot);
+        unsafePutInt(getPrimitiveLocals(), offset, value, slot);
     }
 
     @Override
@@ -130,9 +128,9 @@
     }
 
     private boolean getBooleanUnsafe(FrameSlot slot) {
-        long offset = alignPrimitive(slot, Kind.Boolean);
+        long offset = getPrimitiveOffset(slot);
         boolean condition = this.getTags()[slot.getIndex()] == FrameSlotKind.Boolean.ordinal();
-        return unsafeGetBoolean(getPrimitiveLocals(), offset, condition, slot);
+        return unsafeGetInt(getPrimitiveLocals(), offset, condition, slot) != 0;
     }
 
     @Override
@@ -142,8 +140,8 @@
     }
 
     private void setBooleanUnsafe(FrameSlot slot, boolean value) {
-        long offset = alignPrimitive(slot, Kind.Boolean);
-        unsafePutBoolean(getPrimitiveLocals(), offset, value, slot);
+        long offset = getPrimitiveOffset(slot);
+        unsafePutInt(getPrimitiveLocals(), offset, value ? 1 : 0, slot);
     }
 
     @Override
@@ -153,7 +151,7 @@
     }
 
     private float getFloatUnsafe(FrameSlot slot) {
-        long offset = alignPrimitive(slot, Kind.Float);
+        long offset = getPrimitiveOffset(slot);
         boolean condition = this.getTags()[slot.getIndex()] == FrameSlotKind.Float.ordinal();
         return unsafeGetFloat(getPrimitiveLocals(), offset, condition, slot);
     }
@@ -165,7 +163,7 @@
     }
 
     private void setFloatUnsafe(FrameSlot slot, float value) {
-        long offset = alignPrimitive(slot, Kind.Float);
+        long offset = getPrimitiveOffset(slot);
         unsafePutFloat(getPrimitiveLocals(), offset, value, slot);
     }
 
@@ -176,7 +174,7 @@
     }
 
     private long getLongUnsafe(FrameSlot slot) {
-        long offset = alignPrimitive(slot, Kind.Long);
+        long offset = getPrimitiveOffset(slot);
         boolean condition = this.getTags()[slot.getIndex()] == FrameSlotKind.Long.ordinal();
         return unsafeGetLong(getPrimitiveLocals(), offset, condition, slot);
     }
@@ -188,7 +186,7 @@
     }
 
     private void setLongUnsafe(FrameSlot slot, long value) {
-        long offset = alignPrimitive(slot, Kind.Long);
+        long offset = getPrimitiveOffset(slot);
         unsafePutLong(getPrimitiveLocals(), offset, value, slot);
     }
 
@@ -199,7 +197,7 @@
     }
 
     private int getIntUnsafe(FrameSlot slot) {
-        long offset = alignPrimitive(slot, Kind.Int);
+        long offset = getPrimitiveOffset(slot);
         boolean condition = this.getTags()[slot.getIndex()] == FrameSlotKind.Int.ordinal();
         return unsafeGetInt(getPrimitiveLocals(), offset, condition, slot);
     }
@@ -211,7 +209,7 @@
     }
 
     private void setIntUnsafe(FrameSlot slot, int value) {
-        long offset = alignPrimitive(slot, Kind.Int);
+        long offset = getPrimitiveOffset(slot);
         unsafePutInt(getPrimitiveLocals(), offset, value, slot);
     }
 
@@ -222,7 +220,7 @@
     }
 
     private double getDoubleUnsafe(FrameSlot slot) {
-        long offset = alignPrimitive(slot, Kind.Double);
+        long offset = getPrimitiveOffset(slot);
         boolean condition = this.getTags()[slot.getIndex()] == FrameSlotKind.Double.ordinal();
         return unsafeGetDouble(getPrimitiveLocals(), offset, condition, slot);
     }
@@ -234,7 +232,7 @@
     }
 
     private void setDoubleUnsafe(FrameSlot slot, double value) {
-        long offset = alignPrimitive(slot, Kind.Double);
+        long offset = getPrimitiveOffset(slot);
         unsafePutDouble(getPrimitiveLocals(), offset, value, slot);
     }
 
@@ -245,38 +243,34 @@
 
     private void verifySet(FrameSlot slot, FrameSlotKind accessKind) {
         int slotIndex = slot.getIndex();
-        if (slotIndex >= getTags().length) {
+        byte[] tagsArray = getTags();
+        if (slotIndex >= tagsArray.length) {
             CompilerDirectives.transferToInterpreter();
             if (!resize()) {
                 throw new IllegalArgumentException(String.format("The frame slot '%s' is not known by the frame descriptor.", slot));
             }
         }
-        getTags()[slotIndex] = (byte) accessKind.ordinal();
+        tagsArray[slotIndex] = (byte) accessKind.ordinal();
     }
 
     private void verifyGet(FrameSlot slot, FrameSlotKind accessKind) throws FrameSlotTypeException {
         int slotIndex = slot.getIndex();
-        if (slotIndex >= getTags().length) {
+        byte[] tagsArray = getTags();
+        if (slotIndex >= tagsArray.length) {
             CompilerDirectives.transferToInterpreter();
             if (!resize()) {
                 throw new IllegalArgumentException(String.format("The frame slot '%s' is not known by the frame descriptor.", slot));
             }
         }
-        byte tag = this.getTags()[slotIndex];
+        byte tag = tagsArray[slotIndex];
         if (tag != accessKind.ordinal()) {
             CompilerDirectives.transferToInterpreter();
             throw new FrameSlotTypeException();
         }
     }
 
-    private static long alignPrimitive(FrameSlot slot, Kind forKind) {
-        long offset = Unsafe.ARRAY_LONG_BASE_OFFSET + slot.getIndex() * (long) Unsafe.ARRAY_LONG_INDEX_SCALE;
-        if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
-            // On big endian, we use int in long type, which means, when byteCount() <=4, the value
-            // is right aligned in the 4 byte half, which has the lower address.
-            offset += Kind.Long.getByteCount() - Math.min((long) Unsafe.ARRAY_LONG_INDEX_SCALE, 4 + forKind.getByteCount());
-        }
-        return offset;
+    private static long getPrimitiveOffset(FrameSlot slot) {
+        return Unsafe.ARRAY_LONG_BASE_OFFSET + slot.getIndex() * (long) Unsafe.ARRAY_LONG_INDEX_SCALE;
     }
 
     @Override
@@ -368,16 +362,6 @@
     }
 
     @SuppressWarnings("unused")
-    static boolean unsafeGetBoolean(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getBoolean(receiver, offset);
-    }
-
-    @SuppressWarnings("unused")
-    static byte unsafeGetByte(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getByte(receiver, offset);
-    }
-
-    @SuppressWarnings("unused")
     static int unsafeGetInt(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getInt(receiver, offset);
     }
@@ -403,16 +387,6 @@
     }
 
     @SuppressWarnings("unused")
-    static void unsafePutBoolean(Object receiver, long offset, boolean value, Object locationIdentity) {
-        UNSAFE.putBoolean(receiver, offset, value);
-    }
-
-    @SuppressWarnings("unused")
-    static void unsafePutByte(Object receiver, long offset, byte value, Object locationIdentity) {
-        UNSAFE.putByte(receiver, offset, value);
-    }
-
-    @SuppressWarnings("unused")
     static void unsafePutInt(Object receiver, long offset, int value, Object locationIdentity) {
         UNSAFE.putInt(receiver, offset, value);
     }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Thu Feb 12 01:54:05 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Thu Feb 12 04:01:46 2015 +0100
@@ -34,10 +34,12 @@
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.truffle.debug.*;
+import com.oracle.graal.truffle.unsafe.*;
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.unsafe.*;
 
 public abstract class GraalTruffleRuntime implements TruffleRuntime {
 
@@ -181,6 +183,9 @@
     }
 
     public <T> T getCapability(Class<T> capability) {
+        if (capability == UnsafeAccessFactory.class) {
+            return capability.cast(new UnsafeAccessFactoryImpl());
+        }
         return null;
     }
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleReplacements.java	Thu Feb 12 01:54:05 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleReplacements.java	Thu Feb 12 04:01:46 2015 +0100
@@ -32,6 +32,7 @@
 import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.truffle.substitutions.*;
+import com.oracle.graal.truffle.unsafe.*;
 import com.oracle.truffle.api.*;
 
 /**
@@ -55,6 +56,7 @@
         registerSubstitutions(OptimizedAssumption.class, OptimizedAssumptionSubstitutions.class);
         registerSubstitutions(OptimizedCallTarget.class, OptimizedCallTargetSubstitutions.class);
         registerSubstitutions(FrameWithoutBoxing.class, FrameWithoutBoxingSubstitutions.class);
+        registerSubstitutions(UnsafeAccessImpl.class, UnsafeAccessSubstitutions.class);
     }
 
     @Override
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java	Thu Feb 12 01:54:05 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java	Thu Feb 12 04:01:46 2015 +0100
@@ -195,11 +195,7 @@
         Kind graalKind = null;
         switch (kind) {
             case Boolean:
-                graalKind = Kind.Boolean;
-                break;
             case Byte:
-                graalKind = Kind.Byte;
-                break;
             case Int:
                 graalKind = Kind.Int;
                 break;
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadFinalNode.java	Thu Feb 12 01:54:05 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2014, 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.
- *
- * 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.graal.truffle.nodes.typesystem;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.calc.*;
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.spi.*;
-import com.oracle.graal.nodeinfo.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.truffle.nodes.*;
-
-/**
- * Load of a final value from a location specified as an offset relative to an object.
- *
- * Substitution for method CompilerDirectives#unsafeGet*.
- */
-@NodeInfo
-public final class CustomizedUnsafeLoadFinalNode extends FixedWithNextNode implements Canonicalizable, Virtualizable, Lowerable {
-    @Input ValueNode object;
-    @Input ValueNode offset;
-    @Input ValueNode condition;
-    @Input ValueNode location;
-    protected final Kind accessKind;
-
-    public CustomizedUnsafeLoadFinalNode(ValueNode object, ValueNode offset, ValueNode condition, ValueNode location, Kind accessKind) {
-        super(StampFactory.forKind(accessKind.getStackKind()));
-        this.object = object;
-        this.offset = offset;
-        this.condition = condition;
-        this.location = location;
-        this.accessKind = accessKind;
-    }
-
-    @Override
-    public Node canonical(CanonicalizerTool tool) {
-        if (object.isConstant() && !object.isNullConstant() && offset.isConstant() && condition.isConstant() && condition.asJavaConstant().asInt() == 1) {
-            JavaConstant constant = tool.getConstantReflection().getMemoryAccessProvider().readUnsafeConstant(accessKind, object.asJavaConstant(), offset.asJavaConstant().asLong());
-            return ConstantNode.forConstant(constant, tool.getMetaAccess());
-        }
-        return this;
-    }
-
-    /**
-     * @see UnsafeLoadNode#virtualize(VirtualizerTool)
-     */
-    @Override
-    public void virtualize(VirtualizerTool tool) {
-        State state = tool.getObjectState(object);
-        if (state != null && state.getState() == EscapeState.Virtual) {
-            ValueNode offsetValue = tool.getReplacedValue(offset);
-            if (offsetValue.isConstant()) {
-                long constantOffset = offsetValue.asJavaConstant().asLong();
-                int entryIndex = state.getVirtualObject().entryIndexForOffset(constantOffset, accessKind);
-                if (entryIndex != -1) {
-                    ValueNode entry = state.getEntry(entryIndex);
-                    if (entry.getKind() == getKind() || state.getVirtualObject().entryKind(entryIndex) == accessKind) {
-                        tool.replaceWith(entry);
-                    }
-                }
-            }
-        }
-    }
-
-    @Override
-    public void lower(LoweringTool tool) {
-        LogicNode compare = CompareNode.createCompareNode(graph(), Condition.EQ, condition, ConstantNode.forBoolean(true, graph()), tool.getConstantReflection());
-        LocationIdentity locationIdentity;
-        if (!location.isConstant() || location.isNullConstant()) {
-            locationIdentity = LocationIdentity.ANY_LOCATION;
-        } else {
-            locationIdentity = ObjectLocationIdentity.create(location.asJavaConstant());
-        }
-        UnsafeLoadNode result = graph().add(new UnsafeLoadNode(object, offset, accessKind, locationIdentity, compare));
-        graph().replaceFixedWithFixed(this, result);
-        result.lower(tool);
-    }
-
-    @SuppressWarnings("unused")
-    @NodeIntrinsic
-    public static <T> T load(Object object, long offset, boolean condition, Object locationIdentity, @ConstantNodeParameter Kind kind) {
-        return UnsafeLoadNode.load(object, offset, kind, null);
-    }
-}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/CompilerDirectivesSubstitutions.java	Thu Feb 12 01:54:05 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/CompilerDirectivesSubstitutions.java	Thu Feb 12 04:01:46 2015 +0100
@@ -31,7 +31,6 @@
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.truffle.nodes.*;
 import com.oracle.graal.truffle.nodes.frame.*;
-import com.oracle.graal.truffle.nodes.typesystem.*;
 import com.oracle.truffle.api.*;
 
 @ClassSubstitution(CompilerDirectives.class)
@@ -77,100 +76,8 @@
     @MacroSubstitution(macro = IsCompilationConstantNode.class, isStatic = true)
     public static native boolean isCompilationConstant(Object value);
 
-    @MacroSubstitution(macro = UnsafeTypeCastMacroNode.class, isStatic = true)
-    public static native Object unsafeCast(Object value, Class<?> clazz, boolean condition, boolean nonNull);
-
-    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
-    public static native boolean unsafeGetBoolean(Object receiver, long offset, boolean condition, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
-    public static native byte unsafeGetByte(Object receiver, long offset, boolean condition, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
-    public static native short unsafeGetShort(Object receiver, long offset, boolean condition, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
-    public static native int unsafeGetInt(Object receiver, long offset, boolean condition, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
-    public static native long unsafeGetLong(Object receiver, long offset, boolean condition, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
-    public static native float unsafeGetFloat(Object receiver, long offset, boolean condition, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
-    public static native double unsafeGetDouble(Object receiver, long offset, boolean condition, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
-    public static native Object unsafeGetObject(Object receiver, long offset, boolean condition, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
-    public static native void unsafePutBoolean(Object receiver, long offset, boolean value, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
-    public static native void unsafePutByte(Object receiver, long offset, byte value, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
-    public static native void unsafePutShort(Object receiver, long offset, short value, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
-    public static native void unsafePutInt(Object receiver, long offset, int value, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
-    public static native void unsafePutLong(Object receiver, long offset, long value, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
-    public static native void unsafePutFloat(Object receiver, long offset, float value, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
-    public static native void unsafePutDouble(Object receiver, long offset, double value, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
-    public static native void unsafePutObject(Object receiver, long offset, Object value, Object locationIdentity);
-
-    @MethodSubstitution
-    public static boolean unsafeGetFinalBoolean(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return CustomizedUnsafeLoadFinalNode.load(receiver, offset, condition, locationIdentity, Kind.Boolean);
-    }
-
-    @MethodSubstitution
-    public static byte unsafeGetFinalByte(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return CustomizedUnsafeLoadFinalNode.load(receiver, offset, condition, locationIdentity, Kind.Byte);
-    }
-
-    @MethodSubstitution
-    public static short unsafeGetFinalShort(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return CustomizedUnsafeLoadFinalNode.load(receiver, offset, condition, locationIdentity, Kind.Short);
-    }
-
-    @MethodSubstitution
-    public static int unsafeGetFinalInt(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return CustomizedUnsafeLoadFinalNode.load(receiver, offset, condition, locationIdentity, Kind.Int);
-    }
-
-    @MethodSubstitution
-    public static long unsafeGetFinalLong(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return CustomizedUnsafeLoadFinalNode.load(receiver, offset, condition, locationIdentity, Kind.Long);
-    }
-
-    @MethodSubstitution
-    public static float unsafeGetFinalFloat(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return CustomizedUnsafeLoadFinalNode.load(receiver, offset, condition, locationIdentity, Kind.Float);
-    }
-
-    @MethodSubstitution
-    public static double unsafeGetFinalDouble(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return CustomizedUnsafeLoadFinalNode.load(receiver, offset, condition, locationIdentity, Kind.Double);
-    }
-
-    @MethodSubstitution
-    public static Object unsafeGetFinalObject(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return CustomizedUnsafeLoadFinalNode.load(receiver, offset, condition, locationIdentity, Kind.Object);
-    }
-
     @MethodSubstitution
     public static void materialize(Object obj) {
         ForceMaterializeNode.force(obj);
     }
-
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/FrameWithoutBoxingSubstitutions.java	Thu Feb 12 01:54:05 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/FrameWithoutBoxingSubstitutions.java	Thu Feb 12 04:01:46 2015 +0100
@@ -41,12 +41,6 @@
     public static native Object unsafeCast(Object value, Class<?> clazz, boolean condition, boolean nonNull);
 
     @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
-    public static native boolean unsafeGetBoolean(Object receiver, long offset, boolean condition, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
-    public static native byte unsafeGetByte(Object receiver, long offset, boolean condition, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
     public static native int unsafeGetInt(Object receiver, long offset, boolean condition, Object locationIdentity);
 
     @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
@@ -62,12 +56,6 @@
     public static native Object unsafeGetObject(Object receiver, long offset, boolean condition, Object locationIdentity);
 
     @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
-    public static native void unsafePutBoolean(Object receiver, long offset, boolean value, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
-    public static native void unsafePutByte(Object receiver, long offset, byte value, Object locationIdentity);
-
-    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
     public static native void unsafePutInt(Object receiver, long offset, int value, Object locationIdentity);
 
     @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java	Thu Feb 12 01:54:05 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java	Thu Feb 12 04:01:46 2015 +0100
@@ -42,6 +42,7 @@
 import com.oracle.graal.truffle.nodes.*;
 import com.oracle.graal.truffle.nodes.arithmetic.*;
 import com.oracle.graal.truffle.nodes.frame.*;
+import com.oracle.graal.truffle.unsafe.*;
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
 
@@ -190,10 +191,10 @@
             }
         });
 
-        registerUnsafeLoadStorePlugins(r, Kind.Boolean, Kind.Byte, Kind.Int, Kind.Long, Kind.Float, Kind.Double, Kind.Object);
+        registerUnsafeLoadStorePlugins(r, Kind.Int, Kind.Long, Kind.Float, Kind.Double, Kind.Object);
 
         // CompilerDirectives.class
-        r = new Registration(plugins, metaAccess, CompilerDirectives.class);
+        r = new Registration(plugins, metaAccess, UnsafeAccessImpl.class);
         registerUnsafeLoadStorePlugins(r, Kind.Boolean, Kind.Byte, Kind.Int, Kind.Short, Kind.Long, Kind.Float, Kind.Double, Kind.Object);
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/UnsafeAccessSubstitutions.java	Thu Feb 12 04:01:46 2015 +0100
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013, 2015, 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.
+ *
+ * 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.graal.truffle.substitutions;
+
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.truffle.nodes.typesystem.*;
+import com.oracle.graal.truffle.unsafe.*;
+
+@ClassSubstitution(UnsafeAccessImpl.class)
+public class UnsafeAccessSubstitutions {
+    @MacroSubstitution(macro = UnsafeTypeCastMacroNode.class, isStatic = true)
+    public static native Object unsafeCast(Object value, Class<?> clazz, boolean condition, boolean nonNull);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native boolean unsafeGetBoolean(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native byte unsafeGetByte(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native short unsafeGetShort(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native int unsafeGetInt(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native long unsafeGetLong(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native float unsafeGetFloat(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native double unsafeGetDouble(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native Object unsafeGetObject(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutBoolean(Object receiver, long offset, boolean value, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutByte(Object receiver, long offset, byte value, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutShort(Object receiver, long offset, short value, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutInt(Object receiver, long offset, int value, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutLong(Object receiver, long offset, long value, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutFloat(Object receiver, long offset, float value, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutDouble(Object receiver, long offset, double value, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutObject(Object receiver, long offset, Object value, Object locationIdentity);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/unsafe/UnsafeAccessFactoryImpl.java	Thu Feb 12 04:01:46 2015 +0100
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013, 2015, 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.
+ *
+ * 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.graal.truffle.unsafe;
+
+import sun.misc.*;
+
+import com.oracle.truffle.api.unsafe.*;
+
+public final class UnsafeAccessFactoryImpl implements UnsafeAccessFactory {
+    public UnsafeAccess createUnsafeAccess(Unsafe unsafe) {
+        return new UnsafeAccessImpl(unsafe);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/unsafe/UnsafeAccessImpl.java	Thu Feb 12 04:01:46 2015 +0100
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2013, 2015, 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.
+ *
+ * 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.graal.truffle.unsafe;
+
+import java.lang.reflect.*;
+
+import sun.misc.*;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.unsafe.*;
+
+@SuppressWarnings("unused")
+public final class UnsafeAccessImpl implements UnsafeAccess {
+    public UnsafeAccessImpl(Unsafe unsafe) {
+    }
+
+    public <T> T uncheckedCast(Object value, Class<T> type, boolean condition, boolean nonNull) {
+        return unsafeCast(value, type, condition, nonNull);
+    }
+
+    public boolean getBoolean(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return unsafeGetBoolean(receiver, offset, condition, locationIdentity);
+    }
+
+    public byte getByte(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return unsafeGetByte(receiver, offset, condition, locationIdentity);
+    }
+
+    public short getShort(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return unsafeGetShort(receiver, offset, condition, locationIdentity);
+    }
+
+    public int getInt(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return unsafeGetInt(receiver, offset, condition, locationIdentity);
+    }
+
+    public long getLong(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return unsafeGetLong(receiver, offset, condition, locationIdentity);
+    }
+
+    public float getFloat(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return unsafeGetFloat(receiver, offset, condition, locationIdentity);
+    }
+
+    public double getDouble(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return unsafeGetDouble(receiver, offset, condition, locationIdentity);
+    }
+
+    public Object getObject(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return unsafeGetObject(receiver, offset, condition, locationIdentity);
+    }
+
+    public void putBoolean(Object receiver, long offset, boolean value, Object locationIdentity) {
+        unsafePutBoolean(receiver, offset, value, locationIdentity);
+    }
+
+    public void putByte(Object receiver, long offset, byte value, Object locationIdentity) {
+        unsafePutByte(receiver, offset, value, locationIdentity);
+    }
+
+    public void putShort(Object receiver, long offset, short value, Object locationIdentity) {
+        unsafePutShort(receiver, offset, value, locationIdentity);
+    }
+
+    public void putInt(Object receiver, long offset, int value, Object locationIdentity) {
+        unsafePutInt(receiver, offset, value, locationIdentity);
+    }
+
+    public void putLong(Object receiver, long offset, long value, Object locationIdentity) {
+        unsafePutLong(receiver, offset, value, locationIdentity);
+    }
+
+    public void putFloat(Object receiver, long offset, float value, Object locationIdentity) {
+        unsafePutFloat(receiver, offset, value, locationIdentity);
+    }
+
+    public void putDouble(Object receiver, long offset, double value, Object locationIdentity) {
+        unsafePutDouble(receiver, offset, value, locationIdentity);
+    }
+
+    public void putObject(Object receiver, long offset, Object value, Object locationIdentity) {
+        unsafePutObject(receiver, offset, value, locationIdentity);
+    }
+
+    @SuppressWarnings("unchecked")
+    private static <T> T unsafeCast(Object value, Class<T> type, boolean condition, boolean nonNull) {
+        return (T) value;
+    }
+
+    private static boolean unsafeGetBoolean(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getBoolean(receiver, offset);
+    }
+
+    private static byte unsafeGetByte(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getByte(receiver, offset);
+    }
+
+    private static short unsafeGetShort(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getShort(receiver, offset);
+    }
+
+    private static int unsafeGetInt(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getInt(receiver, offset);
+    }
+
+    private static long unsafeGetLong(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getLong(receiver, offset);
+    }
+
+    private static float unsafeGetFloat(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getFloat(receiver, offset);
+    }
+
+    private static double unsafeGetDouble(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getDouble(receiver, offset);
+    }
+
+    private static Object unsafeGetObject(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getObject(receiver, offset);
+    }
+
+    private static void unsafePutBoolean(Object receiver, long offset, boolean value, Object locationIdentity) {
+        UNSAFE.putBoolean(receiver, offset, value);
+    }
+
+    private static void unsafePutByte(Object receiver, long offset, byte value, Object locationIdentity) {
+        UNSAFE.putByte(receiver, offset, value);
+    }
+
+    private static void unsafePutShort(Object receiver, long offset, short value, Object locationIdentity) {
+        UNSAFE.putShort(receiver, offset, value);
+    }
+
+    private static void unsafePutInt(Object receiver, long offset, int value, Object locationIdentity) {
+        UNSAFE.putInt(receiver, offset, value);
+    }
+
+    private static void unsafePutLong(Object receiver, long offset, long value, Object locationIdentity) {
+        UNSAFE.putLong(receiver, offset, value);
+    }
+
+    private static void unsafePutFloat(Object receiver, long offset, float value, Object locationIdentity) {
+        UNSAFE.putFloat(receiver, offset, value);
+    }
+
+    private static void unsafePutDouble(Object receiver, long offset, double value, Object locationIdentity) {
+        UNSAFE.putDouble(receiver, offset, value);
+    }
+
+    private static void unsafePutObject(Object receiver, long offset, Object value, Object locationIdentity) {
+        UNSAFE.putObject(receiver, offset, value);
+    }
+
+    private static final Unsafe UNSAFE = getUnsafe();
+
+    private static Unsafe getUnsafe() {
+        try {
+            return Unsafe.getUnsafe();
+        } catch (SecurityException e) {
+        }
+        try {
+            Field theUnsafeInstance = Unsafe.class.getDeclaredField("theUnsafe");
+            theUnsafeInstance.setAccessible(true);
+            return (Unsafe) theUnsafeInstance.get(Unsafe.class);
+        } catch (Exception e) {
+            throw new RuntimeException("exception while trying to get Unsafe.theUnsafe via reflection:", e);
+        }
+    }
+}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java	Thu Feb 12 01:54:05 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java	Thu Feb 12 04:01:46 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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
@@ -25,11 +25,8 @@
 package com.oracle.truffle.api;
 
 import java.lang.annotation.*;
-import java.lang.reflect.*;
 import java.util.concurrent.*;
 
-import sun.misc.*;
-
 /**
  * Directives that influence the optimizations of the Truffle compiler. All of the operations have
  * no effect when executed in the Truffle interpreter.
@@ -42,22 +39,6 @@
     public static final double SLOWPATH_PROBABILITY = 0.0001;
     public static final double FASTPATH_PROBABILITY = 1.0 - SLOWPATH_PROBABILITY;
 
-    private static final Unsafe UNSAFE = getUnsafe();
-
-    private static Unsafe getUnsafe() {
-        try {
-            return Unsafe.getUnsafe();
-        } catch (SecurityException e) {
-        }
-        try {
-            Field theUnsafeInstance = Unsafe.class.getDeclaredField("theUnsafe");
-            theUnsafeInstance.setAccessible(true);
-            return (Unsafe) theUnsafeInstance.get(Unsafe.class);
-        } catch (Exception e) {
-            throw new RuntimeException("exception while trying to get Unsafe.theUnsafe via reflection:", e);
-        }
-    }
-
     /**
      * Directive for the compiler to discontinue compilation at this code position and instead
      * insert a transfer to the interpreter.
@@ -203,464 +184,6 @@
     }
 
     /**
-     * Casts the given value to the value of the given type without any checks. The class must
-     * evaluate to a constant. The condition parameter gives a hint to the compiler under which
-     * circumstances this cast can be moved to an earlier location in the program.
-     *
-     * @param value the value that is known to have the specified type
-     * @param type the specified new type of the value
-     * @param condition the condition that makes this cast safe also at an earlier location of the
-     *            program
-     * @return the value to be casted to the new type
-     */
-    @Deprecated
-    public static <T> T unsafeCast(Object value, Class<T> type, boolean condition) {
-        return unsafeCast(value, type, condition, false);
-    }
-
-    /**
-     * Casts the given value to the value of the given type without any checks. The class must
-     * evaluate to a constant. The condition parameter gives a hint to the compiler under which
-     * circumstances this cast can be moved to an earlier location in the program.
-     *
-     * @param value the value that is known to have the specified type
-     * @param type the specified new type of the value
-     * @param condition the condition that makes this cast safe also at an earlier location of the
-     *            program
-     * @param nonNull whether value is known to never be null
-     * @return the value to be casted to the new type
-     */
-    @Deprecated
-    @SuppressWarnings("unchecked")
-    public static <T> T unsafeCast(Object value, Class<T> type, boolean condition, boolean nonNull) {
-        return (T) value;
-    }
-
-    /**
-     * Unsafe access to a boolean value within an object. The condition parameter gives a hint to
-     * the compiler under which circumstances this access can be moved to an earlier location in the
-     * program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static boolean unsafeGetBoolean(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getBoolean(receiver, offset);
-    }
-
-    /**
-     * Unsafe access to a byte value within an object. The condition parameter gives a hint to the
-     * compiler under which circumstances this access can be moved to an earlier location in the
-     * program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static byte unsafeGetByte(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getByte(receiver, offset);
-    }
-
-    /**
-     * Unsafe access to a short value within an object. The condition parameter gives a hint to the
-     * compiler under which circumstances this access can be moved to an earlier location in the
-     * program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static short unsafeGetShort(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getShort(receiver, offset);
-    }
-
-    /**
-     * Unsafe access to an int value within an object. The condition parameter gives a hint to the
-     * compiler under which circumstances this access can be moved to an earlier location in the
-     * program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static int unsafeGetInt(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getInt(receiver, offset);
-    }
-
-    /**
-     * Unsafe access to a long value within an object. The condition parameter gives a hint to the
-     * compiler under which circumstances this access can be moved to an earlier location in the
-     * program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static long unsafeGetLong(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getLong(receiver, offset);
-    }
-
-    /**
-     * Unsafe access to a float value within an object. The condition parameter gives a hint to the
-     * compiler under which circumstances this access can be moved to an earlier location in the
-     * program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static float unsafeGetFloat(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getFloat(receiver, offset);
-    }
-
-    /**
-     * Unsafe access to a double value within an object. The condition parameter gives a hint to the
-     * compiler under which circumstances this access can be moved to an earlier location in the
-     * program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static double unsafeGetDouble(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getDouble(receiver, offset);
-    }
-
-    /**
-     * Unsafe access to an Object value within an object. The condition parameter gives a hint to
-     * the compiler under which circumstances this access can be moved to an earlier location in the
-     * program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static Object unsafeGetObject(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getObject(receiver, offset);
-    }
-
-    /**
-     * Write a boolean value within an object. The location identity gives a hint to the compiler
-     * for improved global value numbering.
-     *
-     * @param receiver the object that is written to
-     * @param offset the offset at which to write to the object in bytes
-     * @param value the value to be written
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     */
-    @Deprecated
-    public static void unsafePutBoolean(Object receiver, long offset, boolean value, Object locationIdentity) {
-        UNSAFE.putBoolean(receiver, offset, value);
-    }
-
-    /**
-     * Write a byte value within an object. The location identity gives a hint to the compiler for
-     * improved global value numbering.
-     *
-     * @param receiver the object that is written to
-     * @param offset the offset at which to write to the object in bytes
-     * @param value the value to be written
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     */
-    @Deprecated
-    public static void unsafePutByte(Object receiver, long offset, byte value, Object locationIdentity) {
-        UNSAFE.putByte(receiver, offset, value);
-    }
-
-    /**
-     * Write a short value within an object. The location identity gives a hint to the compiler for
-     * improved global value numbering.
-     *
-     * @param receiver the object that is written to
-     * @param offset the offset at which to write to the object in bytes
-     * @param value the value to be written
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     */
-    @Deprecated
-    public static void unsafePutShort(Object receiver, long offset, short value, Object locationIdentity) {
-        UNSAFE.putShort(receiver, offset, value);
-    }
-
-    /**
-     * Write an int value within an object. The location identity gives a hint to the compiler for
-     * improved global value numbering.
-     *
-     * @param receiver the object that is written to
-     * @param offset the offset at which to write to the object in bytes
-     * @param value the value to be written
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     */
-    @Deprecated
-    public static void unsafePutInt(Object receiver, long offset, int value, Object locationIdentity) {
-        UNSAFE.putInt(receiver, offset, value);
-    }
-
-    /**
-     * Write a long value within an object. The location identity gives a hint to the compiler for
-     * improved global value numbering.
-     *
-     * @param receiver the object that is written to
-     * @param offset the offset at which to write to the object in bytes
-     * @param value the value to be written
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     */
-    @Deprecated
-    public static void unsafePutLong(Object receiver, long offset, long value, Object locationIdentity) {
-        UNSAFE.putLong(receiver, offset, value);
-    }
-
-    /**
-     * Write a float value within an object. The location identity gives a hint to the compiler for
-     * improved global value numbering.
-     *
-     * @param receiver the object that is written to
-     * @param offset the offset at which to write to the object in bytes
-     * @param value the value to be written
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     */
-    @Deprecated
-    public static void unsafePutFloat(Object receiver, long offset, float value, Object locationIdentity) {
-        UNSAFE.putFloat(receiver, offset, value);
-    }
-
-    /**
-     * Write a double value within an object. The location identity gives a hint to the compiler for
-     * improved global value numbering.
-     *
-     * @param receiver the object that is written to
-     * @param offset the offset at which to write to the object in bytes
-     * @param value the value to be written
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     */
-    @Deprecated
-    public static void unsafePutDouble(Object receiver, long offset, double value, Object locationIdentity) {
-        UNSAFE.putDouble(receiver, offset, value);
-    }
-
-    /**
-     * Write an Object value within an object. The location identity gives a hint to the compiler
-     * for improved global value numbering.
-     *
-     * @param receiver the object that is written to
-     * @param offset the offset at which to write to the object in bytes
-     * @param value the value to be written
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     */
-    @Deprecated
-    public static void unsafePutObject(Object receiver, long offset, Object value, Object locationIdentity) {
-        UNSAFE.putObject(receiver, offset, value);
-    }
-
-    /**
-     * Unsafe access to a final boolean value within an object. The condition parameter gives a hint
-     * to the compiler under which circumstances this access can be moved to an earlier location in
-     * the program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static boolean unsafeGetFinalBoolean(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getBoolean(receiver, offset);
-    }
-
-    /**
-     * Unsafe access to a final byte value within an object. The condition parameter gives a hint to
-     * the compiler under which circumstances this access can be moved to an earlier location in the
-     * program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static byte unsafeGetFinalByte(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getByte(receiver, offset);
-    }
-
-    /**
-     * Unsafe access to a final short value within an object. The condition parameter gives a hint
-     * to the compiler under which circumstances this access can be moved to an earlier location in
-     * the program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static short unsafeGetFinalShort(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getShort(receiver, offset);
-    }
-
-    /**
-     * Unsafe access to a final int value within an object. The condition parameter gives a hint to
-     * the compiler under which circumstances this access can be moved to an earlier location in the
-     * program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static int unsafeGetFinalInt(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getInt(receiver, offset);
-    }
-
-    /**
-     * Unsafe access to a final long value within an object. The condition parameter gives a hint to
-     * the compiler under which circumstances this access can be moved to an earlier location in the
-     * program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static long unsafeGetFinalLong(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getLong(receiver, offset);
-    }
-
-    /**
-     * Unsafe access to a final float value within an object. The condition parameter gives a hint
-     * to the compiler under which circumstances this access can be moved to an earlier location in
-     * the program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static float unsafeGetFinalFloat(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getFloat(receiver, offset);
-    }
-
-    /**
-     * Unsafe access to a final double value within an object. The condition parameter gives a hint
-     * to the compiler under which circumstances this access can be moved to an earlier location in
-     * the program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static double unsafeGetFinalDouble(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getDouble(receiver, offset);
-    }
-
-    /**
-     * Unsafe access to a final Object value within an object. The condition parameter gives a hint
-     * to the compiler under which circumstances this access can be moved to an earlier location in
-     * the program. The location identity gives a hint to the compiler for improved global value
-     * numbering.
-     *
-     * @param receiver the object that is accessed
-     * @param offset the offset at which to access the object in bytes
-     * @param condition the condition that makes this access safe also at an earlier location in the
-     *            program
-     * @param locationIdentity the location identity token that can be used for improved global
-     *            value numbering or null
-     * @return the accessed value
-     */
-    @Deprecated
-    public static Object unsafeGetFinalObject(Object receiver, long offset, boolean condition, Object locationIdentity) {
-        return UNSAFE.getObject(receiver, offset);
-    }
-
-    /**
      * Marks a method that it is considered as a boundary for Truffle partial evaluation.
      */
     @Retention(RetentionPolicy.RUNTIME)
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultTruffleRuntime.java	Thu Feb 12 01:54:05 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultTruffleRuntime.java	Thu Feb 12 04:01:46 2015 +0100
@@ -29,6 +29,7 @@
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.unsafe.*;
 
 /**
  * Default implementation of the Truffle runtime if the virtual machine does not provide a better
@@ -147,6 +148,9 @@
     }
 
     public <T> T getCapability(Class<T> capability) {
+        if (capability == UnsafeAccessFactory.class) {
+            return capability.cast(new UnsafeAccessFactoryImpl());
+        }
         return null;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeAccessFactoryImpl.java	Thu Feb 12 04:01:46 2015 +0100
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013, 2015, 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.api.impl;
+
+import sun.misc.*;
+
+import com.oracle.truffle.api.unsafe.*;
+
+final class UnsafeAccessFactoryImpl implements UnsafeAccessFactory {
+    public UnsafeAccess createUnsafeAccess(final Unsafe unsafe) {
+        return new UnsafeAccessImpl(unsafe);
+    }
+
+    private static final class UnsafeAccessImpl implements UnsafeAccess {
+        private final Unsafe unsafe;
+
+        private UnsafeAccessImpl(Unsafe unsafe) {
+            this.unsafe = unsafe;
+        }
+
+        @SuppressWarnings("unchecked")
+        public <T> T uncheckedCast(Object value, Class<T> type, boolean condition, boolean nonNull) {
+            return (T) value;
+        }
+
+        public void putShort(Object receiver, long offset, short value, Object locationIdentity) {
+            unsafe.putShort(receiver, offset, value);
+        }
+
+        public void putObject(Object receiver, long offset, Object value, Object locationIdentity) {
+            unsafe.putObject(receiver, offset, value);
+        }
+
+        public void putLong(Object receiver, long offset, long value, Object locationIdentity) {
+            unsafe.putLong(receiver, offset, value);
+        }
+
+        public void putInt(Object receiver, long offset, int value, Object locationIdentity) {
+            unsafe.putInt(receiver, offset, value);
+        }
+
+        public void putFloat(Object receiver, long offset, float value, Object locationIdentity) {
+            unsafe.putFloat(receiver, offset, value);
+        }
+
+        public void putDouble(Object receiver, long offset, double value, Object locationIdentity) {
+            unsafe.putDouble(receiver, offset, value);
+        }
+
+        public void putByte(Object receiver, long offset, byte value, Object locationIdentity) {
+            unsafe.putByte(receiver, offset, value);
+        }
+
+        public void putBoolean(Object receiver, long offset, boolean value, Object locationIdentity) {
+            unsafe.putBoolean(receiver, offset, value);
+        }
+
+        public short getShort(Object receiver, long offset, boolean condition, Object locationIdentity) {
+            return unsafe.getShort(receiver, offset);
+        }
+
+        public Object getObject(Object receiver, long offset, boolean condition, Object locationIdentity) {
+            return unsafe.getObject(receiver, offset);
+        }
+
+        public long getLong(Object receiver, long offset, boolean condition, Object locationIdentity) {
+            return unsafe.getLong(receiver, offset);
+        }
+
+        public int getInt(Object receiver, long offset, boolean condition, Object locationIdentity) {
+            return unsafe.getInt(receiver, offset);
+        }
+
+        public float getFloat(Object receiver, long offset, boolean condition, Object locationIdentity) {
+            return unsafe.getFloat(receiver, offset);
+        }
+
+        public double getDouble(Object receiver, long offset, boolean condition, Object locationIdentity) {
+            return unsafe.getDouble(receiver, offset);
+        }
+
+        public byte getByte(Object receiver, long offset, boolean condition, Object locationIdentity) {
+            return unsafe.getByte(receiver, offset);
+        }
+
+        public boolean getBoolean(Object receiver, long offset, boolean condition, Object locationIdentity) {
+            return unsafe.getBoolean(receiver, offset);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/unsafe/UnsafeAccess.java	Thu Feb 12 04:01:46 2015 +0100
@@ -0,0 +1,266 @@
+/*
+ * Copyright (c) 2013, 2015, 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.api.unsafe;
+
+public interface UnsafeAccess {
+
+    /**
+     * Casts the given value to the value of the given type without any checks. The class must
+     * evaluate to a constant. The condition parameter gives a hint to the compiler under which
+     * circumstances this cast can be moved to an earlier location in the program.
+     *
+     * @param value the value that is known to have the specified type
+     * @param type the specified new type of the value
+     * @param condition the condition that makes this cast safe also at an earlier location of the
+     *            program
+     * @param nonNull whether value is known to never be null
+     * @return the value to be casted to the new type
+     */
+    <T> T uncheckedCast(Object value, Class<T> type, boolean condition, boolean nonNull);
+
+    /**
+     * Unsafe access to a boolean value within an object. The condition parameter gives a hint to
+     * the compiler under which circumstances this access can be moved to an earlier location in the
+     * program. The location identity gives a hint to the compiler for improved global value
+     * numbering.
+     *
+     * @param receiver the object that is accessed
+     * @param offset the offset at which to access the object in bytes
+     * @param condition the condition that makes this access safe also at an earlier location in the
+     *            program
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     * @return the accessed value
+     */
+    boolean getBoolean(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    /**
+     * Unsafe access to a byte value within an object. The condition parameter gives a hint to the
+     * compiler under which circumstances this access can be moved to an earlier location in the
+     * program. The location identity gives a hint to the compiler for improved global value
+     * numbering.
+     *
+     * @param receiver the object that is accessed
+     * @param offset the offset at which to access the object in bytes
+     * @param condition the condition that makes this access safe also at an earlier location in the
+     *            program
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     * @return the accessed value
+     */
+    byte getByte(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    /**
+     * Unsafe access to a short value within an object. The condition parameter gives a hint to the
+     * compiler under which circumstances this access can be moved to an earlier location in the
+     * program. The location identity gives a hint to the compiler for improved global value
+     * numbering.
+     *
+     * @param receiver the object that is accessed
+     * @param offset the offset at which to access the object in bytes
+     * @param condition the condition that makes this access safe also at an earlier location in the
+     *            program
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     * @return the accessed value
+     */
+    short getShort(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    /**
+     * Unsafe access to an int value within an object. The condition parameter gives a hint to the
+     * compiler under which circumstances this access can be moved to an earlier location in the
+     * program. The location identity gives a hint to the compiler for improved global value
+     * numbering.
+     *
+     * @param receiver the object that is accessed
+     * @param offset the offset at which to access the object in bytes
+     * @param condition the condition that makes this access safe also at an earlier location in the
+     *            program
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     * @return the accessed value
+     */
+    int getInt(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    /**
+     * Unsafe access to a long value within an object. The condition parameter gives a hint to the
+     * compiler under which circumstances this access can be moved to an earlier location in the
+     * program. The location identity gives a hint to the compiler for improved global value
+     * numbering.
+     *
+     * @param receiver the object that is accessed
+     * @param offset the offset at which to access the object in bytes
+     * @param condition the condition that makes this access safe also at an earlier location in the
+     *            program
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     * @return the accessed value
+     */
+    long getLong(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    /**
+     * Unsafe access to a float value within an object. The condition parameter gives a hint to the
+     * compiler under which circumstances this access can be moved to an earlier location in the
+     * program. The location identity gives a hint to the compiler for improved global value
+     * numbering.
+     *
+     * @param receiver the object that is accessed
+     * @param offset the offset at which to access the object in bytes
+     * @param condition the condition that makes this access safe also at an earlier location in the
+     *            program
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     * @return the accessed value
+     */
+    float getFloat(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    /**
+     * Unsafe access to a double value within an object. The condition parameter gives a hint to the
+     * compiler under which circumstances this access can be moved to an earlier location in the
+     * program. The location identity gives a hint to the compiler for improved global value
+     * numbering.
+     *
+     * @param receiver the object that is accessed
+     * @param offset the offset at which to access the object in bytes
+     * @param condition the condition that makes this access safe also at an earlier location in the
+     *            program
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     * @return the accessed value
+     */
+    double getDouble(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    /**
+     * Unsafe access to an Object value within an object. The condition parameter gives a hint to
+     * the compiler under which circumstances this access can be moved to an earlier location in the
+     * program. The location identity gives a hint to the compiler for improved global value
+     * numbering.
+     *
+     * @param receiver the object that is accessed
+     * @param offset the offset at which to access the object in bytes
+     * @param condition the condition that makes this access safe also at an earlier location in the
+     *            program
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     * @return the accessed value
+     */
+    Object getObject(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    /**
+     * Write a boolean value within an object. The location identity gives a hint to the compiler
+     * for improved global value numbering.
+     *
+     * @param receiver the object that is written to
+     * @param offset the offset at which to write to the object in bytes
+     * @param value the value to be written
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     */
+    void putBoolean(Object receiver, long offset, boolean value, Object locationIdentity);
+
+    /**
+     * Write a byte value within an object. The location identity gives a hint to the compiler for
+     * improved global value numbering.
+     *
+     * @param receiver the object that is written to
+     * @param offset the offset at which to write to the object in bytes
+     * @param value the value to be written
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     */
+    void putByte(Object receiver, long offset, byte value, Object locationIdentity);
+
+    /**
+     * Write a short value within an object. The location identity gives a hint to the compiler for
+     * improved global value numbering.
+     *
+     * @param receiver the object that is written to
+     * @param offset the offset at which to write to the object in bytes
+     * @param value the value to be written
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     */
+    void putShort(Object receiver, long offset, short value, Object locationIdentity);
+
+    /**
+     * Write an int value within an object. The location identity gives a hint to the compiler for
+     * improved global value numbering.
+     *
+     * @param receiver the object that is written to
+     * @param offset the offset at which to write to the object in bytes
+     * @param value the value to be written
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     */
+    void putInt(Object receiver, long offset, int value, Object locationIdentity);
+
+    /**
+     * Write a long value within an object. The location identity gives a hint to the compiler for
+     * improved global value numbering.
+     *
+     * @param receiver the object that is written to
+     * @param offset the offset at which to write to the object in bytes
+     * @param value the value to be written
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     */
+    void putLong(Object receiver, long offset, long value, Object locationIdentity);
+
+    /**
+     * Write a float value within an object. The location identity gives a hint to the compiler for
+     * improved global value numbering.
+     *
+     * @param receiver the object that is written to
+     * @param offset the offset at which to write to the object in bytes
+     * @param value the value to be written
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     */
+    void putFloat(Object receiver, long offset, float value, Object locationIdentity);
+
+    /**
+     * Write a double value within an object. The location identity gives a hint to the compiler for
+     * improved global value numbering.
+     *
+     * @param receiver the object that is written to
+     * @param offset the offset at which to write to the object in bytes
+     * @param value the value to be written
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     */
+    void putDouble(Object receiver, long offset, double value, Object locationIdentity);
+
+    /**
+     * Write an Object value within an object. The location identity gives a hint to the compiler
+     * for improved global value numbering.
+     *
+     * @param receiver the object that is written to
+     * @param offset the offset at which to write to the object in bytes
+     * @param value the value to be written
+     * @param locationIdentity the location identity token that can be used for improved global
+     *            value numbering or null
+     */
+    void putObject(Object receiver, long offset, Object value, Object locationIdentity);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/unsafe/UnsafeAccessFactory.java	Thu Feb 12 04:01:46 2015 +0100
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013, 2015, 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.api.unsafe;
+
+import sun.misc.*;
+
+public interface UnsafeAccessFactory {
+    UnsafeAccess createUnsafeAccess(Unsafe unsafe);
+}