changeset 18401:e7ab82e7cc37

Move metaspace pointer handling to hotspot specific WordTypeRewriter.
author Roland Schatz <roland.schatz@oracle.com>
date Mon, 17 Nov 2014 17:25:38 +0100
parents 43e0f6dfdb4e
children 64c042352f00
files graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILNewObjectSnippets.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/LoadIndexedPointerNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewArrayStubCall.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewInstanceStubCall.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopySnippets.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassGetHubNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassSubstitutions.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotNodeSubstitutions.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HubGetClassNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectSubstitutions.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/word/HotSpotOperation.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/word/HotSpotWordTypeRewriterPhase.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/word/KlassPointer.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/word/MethodPointer.java graal/com.oracle.graal.word/src/com/oracle/graal/word/MethodPointer.java graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java graal/com.oracle.graal.word/src/com/oracle/graal/word/TypePointer.java graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/LoadIndexedPointerNode.java graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java
diffstat 31 files changed, 465 insertions(+), 293 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILNewObjectSnippets.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILNewObjectSnippets.java	Mon Nov 17 17:25:38 2014 +0100
@@ -38,6 +38,7 @@
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.replacements.*;
 import com.oracle.graal.hotspot.stubs.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
@@ -159,7 +160,7 @@
         return result;
     }
 
-    protected static Object addressToFormattedObject(Word addr, @ConstantParameter int size, TypePointer hub, Word prototypeMarkWord, @ConstantParameter boolean fillContents,
+    protected static Object addressToFormattedObject(Word addr, @ConstantParameter int size, KlassPointer hub, Word prototypeMarkWord, @ConstantParameter boolean fillContents,
                     @ConstantParameter String typeContext) {
         Object result = formatObject(hub, size, addr, prototypeMarkWord, fillContents, true, true);
         profileAllocation("instance", size, typeContext);
@@ -167,7 +168,7 @@
     }
 
     @Snippet
-    public static Object allocateInstanceAtomic(@ConstantParameter int size, TypePointer hub, Word prototypeMarkWord, @ConstantParameter boolean fillContents, @ConstantParameter String typeContext) {
+    public static Object allocateInstanceAtomic(@ConstantParameter int size, KlassPointer hub, Word prototypeMarkWord, @ConstantParameter boolean fillContents, @ConstantParameter String typeContext) {
         boolean haveResult = false;
         if (useTLAB()) {
             // inlining this manually here because it resulted in better fastpath codegen
@@ -206,7 +207,7 @@
     }
 
     @Snippet
-    public static Object allocateArrayAtomic(TypePointer hub, int length, Word prototypeMarkWord, @ConstantParameter int headerSize, @ConstantParameter int log2ElementSize,
+    public static Object allocateArrayAtomic(KlassPointer hub, int length, Word prototypeMarkWord, @ConstantParameter int headerSize, @ConstantParameter int log2ElementSize,
                     @ConstantParameter boolean fillContents, @ConstantParameter boolean maybeUnroll, @ConstantParameter String typeContext) {
         if (!belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) {
             // This handles both negative array sizes and very large array sizes
@@ -215,7 +216,7 @@
         return allocateArrayAtomicImpl(hub, length, prototypeMarkWord, headerSize, log2ElementSize, fillContents, maybeUnroll, typeContext);
     }
 
-    protected static Object addressToFormattedArray(Word addr, int allocationSize, int length, int headerSize, TypePointer hub, Word prototypeMarkWord, boolean fillContents, boolean maybeUnroll,
+    protected static Object addressToFormattedArray(Word addr, int allocationSize, int length, int headerSize, KlassPointer hub, Word prototypeMarkWord, boolean fillContents, boolean maybeUnroll,
                     @ConstantParameter String typeContext) {
         // we are not in a stub so we can set useSnippetCounters to true
         Object result = formatArray(hub, allocationSize, length, headerSize, addr, prototypeMarkWord, fillContents, maybeUnroll, true);
@@ -223,7 +224,7 @@
         return piArrayCast(verifyOop(result), length, StampFactory.forNodeIntrinsic());
     }
 
-    private static Object allocateArrayAtomicImpl(TypePointer hub, int length, Word prototypeMarkWord, int headerSize, int log2ElementSize, boolean fillContents, boolean maybeUnroll,
+    private static Object allocateArrayAtomicImpl(KlassPointer hub, int length, Word prototypeMarkWord, int headerSize, int log2ElementSize, boolean fillContents, boolean maybeUnroll,
                     String typeContext) {
         int alignment = wordSize();
         int allocationSize = computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java	Mon Nov 17 17:25:38 2014 +0100
@@ -30,9 +30,11 @@
 import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.replacements.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
+import com.oracle.graal.word.phases.*;
 
 /**
  * Filters certain method substitutions based on whether there is underlying hardware support for
@@ -97,4 +99,23 @@
         }
         return super.getMacroSubstitution(method);
     }
+
+    @Override
+    protected GraphMaker createGraphMaker(ResolvedJavaMethod substitute, ResolvedJavaMethod original, FrameStateProcessing frameStateProcessing) {
+        return new HotSpotGraphMaker(this, substitute, original, frameStateProcessing);
+    }
+
+    private static class HotSpotGraphMaker extends ReplacementsImpl.GraphMaker {
+
+        protected HotSpotGraphMaker(ReplacementsImpl replacements, ResolvedJavaMethod substitute, ResolvedJavaMethod substitutedMethod, FrameStateProcessing frameStateProcessing) {
+            super(replacements, substitute, substitutedMethod, frameStateProcessing);
+        }
+
+        @Override
+        protected void afterParsing(StructuredGraph graph) {
+            MetaAccessProvider metaAccess = replacements.providers.getMetaAccess();
+            new WordTypeVerificationPhase(metaAccess, replacements.snippetReflection, replacements.target.wordKind).apply(graph);
+            new HotSpotWordTypeRewriterPhase(metaAccess, replacements.snippetReflection, replacements.target.wordKind).apply(graph);
+        }
+    }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java	Mon Nov 17 17:25:38 2014 +0100
@@ -30,11 +30,11 @@
 import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.virtual.*;
-import com.oracle.graal.word.phases.*;
 
 /**
  * Utility creating a graph for a stub used to call a native function.
@@ -91,7 +91,7 @@
 
             ReturnNode returnNode = g.add(ReturnNode.create(boxedResult));
             callNode.setNext(returnNode);
-            (new WordTypeRewriterPhase(providers.getMetaAccess(), providers.getSnippetReflection(), Kind.Long)).apply(g);
+            (new HotSpotWordTypeRewriterPhase(providers.getMetaAccess(), providers.getSnippetReflection(), Kind.Long)).apply(g);
             return g;
         } catch (NoSuchMethodException e) {
             throw GraalInternalError.shouldNotReachHere("Call Stub method not found");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/LoadIndexedPointerNode.java	Mon Nov 17 17:25:38 2014 +0100
@@ -0,0 +1,46 @@
+/*
+ * 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.hotspot.nodes;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.compiler.common.type.*;
+import com.oracle.graal.nodeinfo.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.java.*;
+
+@NodeInfo
+public class LoadIndexedPointerNode extends LoadIndexedNode {
+
+    public static LoadIndexedPointerNode create(Stamp stamp, ValueNode array, ValueNode index) {
+        return new LoadIndexedPointerNode(stamp, array, index);
+    }
+
+    protected LoadIndexedPointerNode(Stamp stamp, ValueNode array, ValueNode index) {
+        super(stamp, array, index, Kind.Illegal);
+    }
+
+    @Override
+    public boolean inferStamp() {
+        return false;
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewArrayStubCall.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewArrayStubCall.java	Mon Nov 17 17:25:38 2014 +0100
@@ -28,11 +28,11 @@
 import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.stubs.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.nodeinfo.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.word.*;
 
 /**
  * A call to the {@link NewArrayStub}.
@@ -72,5 +72,5 @@
     }
 
     @NodeIntrinsic
-    public static native Object call(TypePointer hub, int length);
+    public static native Object call(KlassPointer hub, int length);
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewInstanceStubCall.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewInstanceStubCall.java	Mon Nov 17 17:25:38 2014 +0100
@@ -29,10 +29,10 @@
 import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.stubs.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodeinfo.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.word.*;
 
 /**
  * A call to the {@link NewInstanceStub}.
@@ -70,5 +70,5 @@
     }
 
     @NodeIntrinsic
-    public static native Object call(TypePointer hub);
+    public static native Object call(KlassPointer hub);
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopySnippets.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopySnippets.java	Mon Nov 17 17:25:38 2014 +0100
@@ -34,6 +34,7 @@
 import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.graph.Node.ConstantNodeParameter;
 import com.oracle.graal.graph.Node.NodeIntrinsic;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
@@ -93,7 +94,7 @@
         UnsafeArrayCopyNode.arraycopy(nonNullSrc, srcPos, nonNullDest, destPos, length, baseKind);
     }
 
-    private static int checkArrayType(TypePointer hub) {
+    private static int checkArrayType(KlassPointer hub) {
         int layoutHelper = readLayoutHelper(hub);
         if (probability(SLOW_PATH_PROBABILITY, layoutHelper >= 0)) {
             DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
@@ -183,9 +184,9 @@
     public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length) {
         Object nonNullSrc = guardingNonNull(src);
         Object nonNullDest = guardingNonNull(dest);
-        TypePointer srcHub = loadHub(nonNullSrc);
-        TypePointer destHub = loadHub(nonNullDest);
-        if (probability(FAST_PATH_PROBABILITY, Word.equal(srcHub, destHub)) && probability(FAST_PATH_PROBABILITY, nonNullSrc != nonNullDest)) {
+        KlassPointer srcHub = loadHub(nonNullSrc);
+        KlassPointer destHub = loadHub(nonNullDest);
+        if (probability(FAST_PATH_PROBABILITY, srcHub.equal(destHub)) && probability(FAST_PATH_PROBABILITY, nonNullSrc != nonNullDest)) {
             int layoutHelper = checkArrayType(srcHub);
             final boolean isObjectArray = ((layoutHelper & layoutHelperElementTypePrimitiveInPlace()) == 0);
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java	Mon Nov 17 17:25:38 2014 +0100
@@ -56,7 +56,7 @@
             isNull.inc();
         } else {
             GuardingNode anchorNode = SnippetAnchorNode.anchor();
-            Pointer objectHub = Word.fromTypePointer(loadHubIntrinsic(object, anchorNode));
+            Pointer objectHub = loadHubIntrinsic(object, anchorNode).asWord();
             if (!checkUnknownSubType(hub, objectHub)) {
                 DeoptimizeNode.deopt(InvalidateReprofile, ClassCastException);
             }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassGetHubNode.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassGetHubNode.java	Mon Nov 17 17:25:38 2014 +0100
@@ -31,12 +31,12 @@
 import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodeinfo.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.HeapAccess.BarrierType;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.word.*;
 
 /**
  * Read Class::_klass to get the hub for a {@link java.lang.Class}. This node mostly exists to
@@ -112,9 +112,9 @@
     }
 
     @NodeIntrinsic
-    public static native TypePointer readClass(Class<?> clazz);
+    public static native KlassPointer readClass(Class<?> clazz);
 
     @NodeIntrinsic
-    public static native TypePointer readClass(Class<?> clazz, GuardingNode guard);
+    public static native KlassPointer readClass(Class<?> clazz, GuardingNode guard);
 
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassSubstitutions.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassSubstitutions.java	Mon Nov 17 17:25:38 2014 +0100
@@ -29,6 +29,7 @@
 
 import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.hotspot.nodes.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.word.*;
@@ -42,13 +43,13 @@
     @MacroSubstitution(macro = ClassGetModifiersNode.class, isStatic = false)
     @MethodSubstitution(isStatic = false, forced = true)
     public static int getModifiers(final Class<?> thisObj) {
-        TypePointer klass = ClassGetHubNode.readClass(thisObj);
-        TypePointer zero = Word.unsigned(0).toTypePointer();
-        if (Word.equal(klass, zero)) {
+        KlassPointer klass = ClassGetHubNode.readClass(thisObj);
+        KlassPointer zero = KlassPointer.fromWord(Word.unsigned(0));
+        if (klass.equal(zero)) {
             // Class for primitive type
             return Modifier.ABSTRACT | Modifier.FINAL | Modifier.PUBLIC;
         } else {
-            return Word.fromTypePointer(klass).readInt(klassModifierFlagsOffset(), KLASS_MODIFIER_FLAGS_LOCATION);
+            return klass.asWord().readInt(klassModifierFlagsOffset(), KLASS_MODIFIER_FLAGS_LOCATION);
         }
     }
 
@@ -56,7 +57,7 @@
     @MacroSubstitution(macro = ClassIsInterfaceNode.class, isStatic = false)
     @MethodSubstitution(isStatic = false, forced = true)
     public static boolean isInterface(final Class<?> thisObj) {
-        Pointer klass = Word.fromTypePointer(ClassGetHubNode.readClass(thisObj));
+        Pointer klass = ClassGetHubNode.readClass(thisObj).asWord();
         if (klass.equal(0)) {
             return false;
         } else {
@@ -69,8 +70,8 @@
     @MacroSubstitution(macro = ClassIsArrayNode.class, isStatic = false)
     @MethodSubstitution(isStatic = false, forced = true)
     public static boolean isArray(final Class<?> thisObj) {
-        TypePointer klassPtr = ClassGetHubNode.readClass(thisObj);
-        Pointer klass = Word.fromTypePointer(klassPtr);
+        KlassPointer klassPtr = ClassGetHubNode.readClass(thisObj);
+        Pointer klass = klassPtr.asWord();
         if (klass.equal(0)) {
             return false;
         } else {
@@ -82,7 +83,7 @@
     @MacroSubstitution(macro = ClassIsPrimitiveNode.class, isStatic = false)
     @MethodSubstitution(isStatic = false, forced = true)
     public static boolean isPrimitive(final Class<?> thisObj) {
-        Pointer klass = Word.fromTypePointer(ClassGetHubNode.readClass(thisObj));
+        Pointer klass = ClassGetHubNode.readClass(thisObj).asWord();
         return klass.equal(0);
     }
 
@@ -92,8 +93,8 @@
     @MacroSubstitution(macro = ClassGetSuperclassNode.class, isStatic = false)
     @MethodSubstitution(isStatic = false)
     public static Class<?> getSuperclass(final Class<?> thisObj) {
-        TypePointer klassPtr = ClassGetHubNode.readClass(thisObj);
-        Pointer klass = Word.fromTypePointer(klassPtr);
+        KlassPointer klassPtr = ClassGetHubNode.readClass(thisObj);
+        Pointer klass = klassPtr.asWord();
         if (klass.notEqual(0)) {
             int accessFlags = klass.readInt(klassAccessFlagsOffset(), KLASS_ACCESS_FLAGS_LOCATION);
             if ((accessFlags & Modifier.INTERFACE) == 0) {
@@ -115,8 +116,8 @@
     @MacroSubstitution(macro = ClassGetComponentTypeNode.class, isStatic = false)
     @MethodSubstitution(isStatic = false)
     public static Class<?> getComponentType(final Class<?> thisObj) {
-        TypePointer klassPtr = ClassGetHubNode.readClass(thisObj);
-        Pointer klass = Word.fromTypePointer(klassPtr);
+        KlassPointer klassPtr = ClassGetHubNode.readClass(thisObj);
+        Pointer klass = klassPtr.asWord();
         if (klass.notEqual(0)) {
             if (klassIsArray(klassPtr)) {
                 return piCastExactNonNull(klass.readObject(arrayKlassComponentMirrorOffset(), ARRAY_KLASS_COMPONENT_MIRROR), Class.class);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotNodeSubstitutions.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotNodeSubstitutions.java	Mon Nov 17 17:25:38 2014 +0100
@@ -27,6 +27,7 @@
 
 import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.word.*;
 
 @ClassSubstitution(Node.class)
@@ -41,7 +42,7 @@
         // HotSpot creates the NodeClass for each Node subclass while initializing it
         // so we are guaranteed to read a non-null value here. As long as NodeClass
         // is final, the stamp of the PiNode below will automatically be exact.
-        TypePointer klass = loadHub(node);
-        return piCastNonNull(Word.fromTypePointer(klass).readObject(Word.signed(instanceKlassNodeClassOffset()), KLASS_NODE_CLASS), NodeClass.class);
+        KlassPointer klass = loadHub(node);
+        return piCastNonNull(klass.asWord().readObject(Word.signed(instanceKlassNodeClassOffset()), KLASS_NODE_CLASS), NodeClass.class);
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java	Mon Nov 17 17:25:38 2014 +0100
@@ -35,6 +35,7 @@
 import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.nodes.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.replacements.nodes.*;
@@ -298,17 +299,17 @@
         return config().klassLayoutHelperOffset;
     }
 
-    public static int readLayoutHelper(TypePointer hub) {
+    public static int readLayoutHelper(KlassPointer hub) {
         // return hub.readInt(klassLayoutHelperOffset(), KLASS_LAYOUT_HELPER_LOCATION);
         GuardingNode anchorNode = SnippetAnchorNode.anchor();
         return loadKlassLayoutHelperIntrinsic(hub, anchorNode);
     }
 
     @NodeIntrinsic(value = KlassLayoutHelperNode.class)
-    public static native int loadKlassLayoutHelperIntrinsic(TypePointer object, GuardingNode anchor);
+    public static native int loadKlassLayoutHelperIntrinsic(KlassPointer object, GuardingNode anchor);
 
     @NodeIntrinsic(value = KlassLayoutHelperNode.class)
-    public static native int loadKlassLayoutHelperIntrinsic(TypePointer object);
+    public static native int loadKlassLayoutHelperIntrinsic(KlassPointer object);
 
     /**
      * Checks if class {@code klass} is an array.
@@ -318,7 +319,7 @@
      * @param klass the class to be checked
      * @return true if klass is an array, false otherwise
      */
-    public static boolean klassIsArray(TypePointer klass) {
+    public static boolean klassIsArray(KlassPointer klass) {
         /*
          * The less-than check only works if both values are ints. We use local variables to make
          * sure these are still ints and haven't changed.
@@ -358,7 +359,7 @@
         return config().hubOffset;
     }
 
-    public static void initializeObjectHeader(Word memory, Word markWord, TypePointer hub) {
+    public static void initializeObjectHeader(Word memory, Word markWord, KlassPointer hub) {
         memory.writeWord(markOffset(), markWord, MARK_WORD_LOCATION);
         StoreHubNode.write(memory, hub);
     }
@@ -549,7 +550,7 @@
     /**
      * Loads the hub of an object (without null checking it first).
      */
-    public static TypePointer loadHub(Object object) {
+    public static KlassPointer loadHub(Object object) {
         return loadHubIntrinsic(object);
     }
 
@@ -597,13 +598,13 @@
 
     @SuppressWarnings("unused")
     @NodeIntrinsic(value = LoadHubNode.class)
-    public static TypePointer loadHubIntrinsic(Object object, GuardingNode anchor) {
-        return Word.unsigned(unsafeReadKlassPointer(object)).toTypePointer();
+    public static KlassPointer loadHubIntrinsic(Object object, GuardingNode anchor) {
+        return KlassPointer.fromWord(Word.unsigned(unsafeReadKlassPointer(object)));
     }
 
     @NodeIntrinsic(value = LoadHubNode.class)
-    public static TypePointer loadHubIntrinsic(Object object) {
-        return Word.unsigned(unsafeReadKlassPointer(object)).toTypePointer();
+    public static KlassPointer loadHubIntrinsic(Object object) {
+        return KlassPointer.fromWord(Word.unsigned(unsafeReadKlassPointer(object)));
     }
 
     @Fold
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HubGetClassNode.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HubGetClassNode.java	Mon Nov 17 17:25:38 2014 +0100
@@ -30,12 +30,12 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodeinfo.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.HeapAccess.BarrierType;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.word.*;
 
 /**
  * Read Klass::_java_mirror and incorporate non-null type information into stamp. This is also used
@@ -88,6 +88,6 @@
     }
 
     @NodeIntrinsic
-    public static native Class<?> readClass(TypePointer hub);
+    public static native Class<?> readClass(KlassPointer hub);
 
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java	Mon Nov 17 17:25:38 2014 +0100
@@ -37,6 +37,7 @@
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.hotspot.replacements.TypeCheckSnippetUtils.Hints;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
@@ -80,7 +81,7 @@
      * @see #hintHitProbabilityThresholdForDeoptimizingSnippet()
      */
     @Snippet
-    public static Object instanceofWithProfile(Object object, @VarargsParameter TypePointer[] hints, @VarargsParameter boolean[] hintIsPositive, Object trueValue, Object falseValue,
+    public static Object instanceofWithProfile(Object object, @VarargsParameter KlassPointer[] hints, @VarargsParameter boolean[] hintIsPositive, Object trueValue, Object falseValue,
                     @ConstantParameter boolean nullSeen) {
         if (probability(NOT_FREQUENT_PROBABILITY, object == null)) {
             isNull.inc();
@@ -92,13 +93,13 @@
             return falseValue;
         }
         GuardingNode anchorNode = SnippetAnchorNode.anchor();
-        TypePointer objectHub = loadHubIntrinsic(object, anchorNode);
+        KlassPointer objectHub = loadHubIntrinsic(object, anchorNode);
         // if we get an exact match: succeed immediately
         ExplodeLoopNode.explodeLoop();
         for (int i = 0; i < hints.length; i++) {
-            TypePointer hintHub = hints[i];
+            KlassPointer hintHub = hints[i];
             boolean positive = hintIsPositive[i];
-            if (probability(NOT_FREQUENT_PROBABILITY, Word.equal(hintHub, objectHub))) {
+            if (probability(NOT_FREQUENT_PROBABILITY, hintHub.equal(objectHub))) {
                 hintsHit.inc();
                 return positive ? trueValue : falseValue;
             }
@@ -115,14 +116,14 @@
      * A test against a final type.
      */
     @Snippet
-    public static Object instanceofExact(Object object, TypePointer exactHub, Object trueValue, Object falseValue) {
+    public static Object instanceofExact(Object object, KlassPointer exactHub, Object trueValue, Object falseValue) {
         if (probability(NOT_FREQUENT_PROBABILITY, object == null)) {
             isNull.inc();
             return falseValue;
         }
         GuardingNode anchorNode = SnippetAnchorNode.anchor();
-        TypePointer objectHub = loadHubIntrinsic(object, anchorNode);
-        if (probability(LIKELY_PROBABILITY, Word.notEqual(objectHub, exactHub))) {
+        KlassPointer objectHub = loadHubIntrinsic(object, anchorNode);
+        if (probability(LIKELY_PROBABILITY, objectHub.notEqual(exactHub))) {
             exactMiss.inc();
             return falseValue;
         }
@@ -134,14 +135,14 @@
      * A test against a primary type.
      */
     @Snippet
-    public static Object instanceofPrimary(TypePointer hub, Object object, @ConstantParameter int superCheckOffset, Object trueValue, Object falseValue) {
+    public static Object instanceofPrimary(KlassPointer hub, Object object, @ConstantParameter int superCheckOffset, Object trueValue, Object falseValue) {
         if (probability(NOT_FREQUENT_PROBABILITY, object == null)) {
             isNull.inc();
             return falseValue;
         }
         GuardingNode anchorNode = SnippetAnchorNode.anchor();
-        Pointer objectHub = Word.fromTypePointer(loadHubIntrinsic(object, anchorNode));
-        if (probability(NOT_LIKELY_PROBABILITY, objectHub.readWord(superCheckOffset, PRIMARY_SUPERS_LOCATION).notEqual(Word.fromTypePointer(hub)))) {
+        Pointer objectHub = loadHubIntrinsic(object, anchorNode).asWord();
+        if (probability(NOT_LIKELY_PROBABILITY, objectHub.readWord(superCheckOffset, PRIMARY_SUPERS_LOCATION).notEqual(hub.asWord()))) {
             displayMiss.inc();
             return falseValue;
         }
@@ -153,24 +154,24 @@
      * A test against a restricted secondary type type.
      */
     @Snippet
-    public static Object instanceofSecondary(TypePointer hub, Object object, @VarargsParameter TypePointer[] hints, @VarargsParameter boolean[] hintIsPositive, Object trueValue, Object falseValue) {
+    public static Object instanceofSecondary(KlassPointer hub, Object object, @VarargsParameter KlassPointer[] hints, @VarargsParameter boolean[] hintIsPositive, Object trueValue, Object falseValue) {
         if (probability(NOT_FREQUENT_PROBABILITY, object == null)) {
             isNull.inc();
             return falseValue;
         }
         GuardingNode anchorNode = SnippetAnchorNode.anchor();
-        Pointer objectHub = Word.fromTypePointer(loadHubIntrinsic(object, anchorNode));
+        Pointer objectHub = loadHubIntrinsic(object, anchorNode).asWord();
         // if we get an exact match: succeed immediately
         ExplodeLoopNode.explodeLoop();
         for (int i = 0; i < hints.length; i++) {
-            Pointer hintHub = Word.fromTypePointer(hints[i]);
+            Pointer hintHub = hints[i].asWord();
             boolean positive = hintIsPositive[i];
             if (probability(NOT_FREQUENT_PROBABILITY, hintHub.equal(objectHub))) {
                 hintsHit.inc();
                 return positive ? trueValue : falseValue;
             }
         }
-        if (!checkSecondarySubType(Word.fromTypePointer(hub), objectHub)) {
+        if (!checkSecondarySubType(hub.asWord(), objectHub)) {
             return falseValue;
         }
         return trueValue;
@@ -186,8 +187,8 @@
             return falseValue;
         }
         GuardingNode anchorNode = SnippetAnchorNode.anchor();
-        Pointer hub = Word.fromTypePointer(ClassGetHubNode.readClass(mirror, anchorNode));
-        Pointer objectHub = Word.fromTypePointer(loadHubIntrinsic(object, anchorNode));
+        Pointer hub = ClassGetHubNode.readClass(mirror, anchorNode).asWord();
+        Pointer objectHub = loadHubIntrinsic(object, anchorNode).asWord();
         if (hub.equal(0) || !checkUnknownSubType(hub, objectHub)) {
             return falseValue;
         }
@@ -235,7 +236,7 @@
                     Hints hints = createHints(hintInfo, providers.getMetaAccess(), false, graph);
                     args = new Arguments(instanceofWithProfile, graph.getGuardsStage(), tool.getLoweringStage());
                     args.add("object", object);
-                    args.addVarargs("hints", TypePointer.class, StampFactory.forPointer(PointerType.Type), hints.hubs);
+                    args.addVarargs("hints", KlassPointer.class, StampFactory.forPointer(PointerType.Type), hints.hubs);
                     args.addVarargs("hintIsPositive", boolean.class, StampFactory.forKind(Kind.Boolean), hints.isPositive);
                 } else if (hintInfo.exact != null) {
                     args = new Arguments(instanceofExact, graph.getGuardsStage(), tool.getLoweringStage());
@@ -251,7 +252,7 @@
                     args = new Arguments(instanceofSecondary, graph.getGuardsStage(), tool.getLoweringStage());
                     args.add("hub", hub);
                     args.add("object", object);
-                    args.addVarargs("hints", TypePointer.class, StampFactory.forPointer(PointerType.Type), hints.hubs);
+                    args.addVarargs("hints", KlassPointer.class, StampFactory.forPointer(PointerType.Type), hints.hubs);
                     args.addVarargs("hintIsPositive", boolean.class, StampFactory.forKind(Kind.Boolean), hints.isPositive);
                 }
                 args.add("trueValue", replacer.trueValue);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java	Mon Nov 17 17:25:38 2014 +0100
@@ -128,7 +128,7 @@
             } else {
                 // The bias pattern is present in the object's mark word. Need to check
                 // whether the bias owner and the epoch are both still current.
-                Pointer hub = Word.fromTypePointer(loadHubIntrinsic(object, anchorNode));
+                Pointer hub = loadHubIntrinsic(object, anchorNode).asWord();
                 final Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION);
                 final Word thread = registerAsWord(threadRegister);
                 final Word tmp = prototypeMarkWord.or(thread).xor(mark).and(~ageMaskInPlace());
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java	Mon Nov 17 17:25:38 2014 +0100
@@ -42,6 +42,7 @@
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.debug.*;
 import com.oracle.graal.nodes.extended.*;
@@ -130,7 +131,7 @@
     }
 
     @Snippet
-    public static Object allocateInstance(@ConstantParameter int size, TypePointer hub, Word prototypeMarkWord, @ConstantParameter boolean fillContents, @ConstantParameter Register threadRegister,
+    public static Object allocateInstance(@ConstantParameter int size, KlassPointer hub, Word prototypeMarkWord, @ConstantParameter boolean fillContents, @ConstantParameter Register threadRegister,
                     @ConstantParameter boolean constantSize, @ConstantParameter String typeContext) {
         Object result;
         Word thread = registerAsWord(threadRegister);
@@ -151,8 +152,8 @@
 
     @Snippet
     public static Object allocateInstanceDynamic(Class<?> type, @ConstantParameter boolean fillContents, @ConstantParameter Register threadRegister, @ConstantParameter String typeContext) {
-        TypePointer hubPtr = ClassGetHubNode.readClass(type);
-        Pointer hub = Word.fromTypePointer(hubPtr);
+        KlassPointer hubPtr = ClassGetHubNode.readClass(type);
+        Pointer hub = hubPtr.asWord();
         if (probability(FAST_PATH_PROBABILITY, !hub.equal(Word.zero()))) {
             if (probability(FAST_PATH_PROBABILITY, isInstanceKlassFullyInitialized(hub))) {
                 int layoutHelper = readLayoutHelper(hubPtr);
@@ -164,7 +165,7 @@
                  */
                 if (probability(FAST_PATH_PROBABILITY, (layoutHelper & 1) == 0)) {
                     Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION);
-                    return allocateInstance(layoutHelper, hub.toTypePointer(), prototypeMarkWord, fillContents, threadRegister, false, typeContext);
+                    return allocateInstance(layoutHelper, KlassPointer.fromWord(hub), prototypeMarkWord, fillContents, threadRegister, false, typeContext);
                 }
             }
         }
@@ -177,13 +178,13 @@
     public static final int MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH = 0x00FFFFFF;
 
     @Snippet
-    public static Object allocateArray(TypePointer hub, int length, Word prototypeMarkWord, @ConstantParameter int headerSize, @ConstantParameter int log2ElementSize,
+    public static Object allocateArray(KlassPointer hub, int length, Word prototypeMarkWord, @ConstantParameter int headerSize, @ConstantParameter int log2ElementSize,
                     @ConstantParameter boolean fillContents, @ConstantParameter Register threadRegister, @ConstantParameter boolean maybeUnroll, @ConstantParameter String typeContext) {
         return allocateArrayImpl(hub, length, prototypeMarkWord, headerSize, log2ElementSize, fillContents, threadRegister, maybeUnroll, typeContext, false);
     }
 
-    private static Object allocateArrayImpl(TypePointer hub, int length, Word prototypeMarkWord, int headerSize, int log2ElementSize, boolean fillContents, @ConstantParameter Register threadRegister,
-                    @ConstantParameter boolean maybeUnroll, String typeContext, boolean skipNegativeCheck) {
+    private static Object allocateArrayImpl(KlassPointer hub, int length, Word prototypeMarkWord, int headerSize, int log2ElementSize, boolean fillContents,
+                    @ConstantParameter Register threadRegister, @ConstantParameter boolean maybeUnroll, String typeContext, boolean skipNegativeCheck) {
         Object result;
         int alignment = wordSize();
         int allocationSize = computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize);
@@ -224,7 +225,8 @@
             return dynamicNewArrayStub(DYNAMIC_NEW_ARRAY, elementType, length);
         }
 
-        int layoutHelper = readLayoutHelper(hub.toTypePointer());
+        KlassPointer klass = KlassPointer.fromWord(hub);
+        int layoutHelper = readLayoutHelper(klass);
         //@formatter:off
         // from src/share/vm/oops/klass.hpp:
         //
@@ -242,7 +244,7 @@
         int log2ElementSize = (layoutHelper >> layoutHelperLog2ElementSizeShift()) & layoutHelperLog2ElementSizeMask();
         Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION);
 
-        return allocateArrayImpl(hub.toTypePointer(), length, prototypeMarkWord, headerSize, log2ElementSize, fillContents, threadRegister, false, "dynamic type", true);
+        return allocateArrayImpl(klass, length, prototypeMarkWord, headerSize, log2ElementSize, fillContents, threadRegister, false, "dynamic type", true);
     }
 
     /**
@@ -336,15 +338,15 @@
      * Formats some allocated memory with an object header and zeroes out the rest. Disables asserts
      * since they can't be compiled in stubs.
      */
-    public static Object formatObjectForStub(TypePointer hub, int size, Word memory, Word compileTimePrototypeMarkWord) {
+    public static Object formatObjectForStub(KlassPointer hub, int size, Word memory, Word compileTimePrototypeMarkWord) {
         return formatObject(hub, size, memory, compileTimePrototypeMarkWord, true, false, false);
     }
 
     /**
      * Formats some allocated memory with an object header and zeroes out the rest.
      */
-    protected static Object formatObject(TypePointer hub, int size, Word memory, Word compileTimePrototypeMarkWord, boolean fillContents, boolean constantSize, boolean useSnippetCounters) {
-        Word prototypeMarkWord = useBiasedLocking() ? Word.fromTypePointer(hub).readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION) : compileTimePrototypeMarkWord;
+    protected static Object formatObject(KlassPointer hub, int size, Word memory, Word compileTimePrototypeMarkWord, boolean fillContents, boolean constantSize, boolean useSnippetCounters) {
+        Word prototypeMarkWord = useBiasedLocking() ? hub.asWord().readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION) : compileTimePrototypeMarkWord;
         initializeObjectHeader(memory, prototypeMarkWord, hub);
         if (fillContents) {
             zeroMemory(size, memory, constantSize, instanceHeaderSize(), false, useSnippetCounters);
@@ -355,7 +357,7 @@
     /**
      * Formats some allocated memory with an object header and zeroes out the rest.
      */
-    public static Object formatArray(TypePointer hub, int allocationSize, int length, int headerSize, Word memory, Word prototypeMarkWord, boolean fillContents, boolean maybeUnroll,
+    public static Object formatArray(KlassPointer hub, int allocationSize, int length, int headerSize, Word memory, Word prototypeMarkWord, boolean fillContents, boolean maybeUnroll,
                     boolean useSnippetCounters) {
         memory.writeInt(arrayLengthOffset(), length, INIT_LOCATION);
         /*
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectSubstitutions.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectSubstitutions.java	Mon Nov 17 17:25:38 2014 +0100
@@ -25,10 +25,10 @@
 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
 
 import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.word.*;
 
 /**
  * Substitutions for {@link java.lang.Object} methods.
@@ -38,7 +38,7 @@
 
     @MethodSubstitution(isStatic = false, forced = true)
     public static Class<?> getClass(final Object thisObj) {
-        TypePointer hub = loadHub(GuardingPiNode.guardingNonNull(thisObj));
+        KlassPointer hub = loadHub(GuardingPiNode.guardingNonNull(thisObj));
         return HubGetClassNode.readClass(hub);
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java	Mon Nov 17 17:25:38 2014 +0100
@@ -26,6 +26,7 @@
 import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.RegisterEffect.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.hotspot.*;
@@ -33,7 +34,9 @@
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.hotspot.replacements.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.replacements.nodes.*;
 import com.oracle.graal.word.*;
@@ -186,7 +189,7 @@
 
         StructuredGraph graph = new StructuredGraph(toString(), null);
 
-        GraphKit kit = new GraphKit(graph, providers);
+        GraphKit kit = new HotSpotGraphKit(graph, providers);
         ParameterNode[] params = createParameters(kit, args);
 
         ReadRegisterNode thread = kit.append(ReadRegisterNode.create(providers.getRegisters().getThreadRegister(), true, false));
@@ -212,6 +215,18 @@
         return graph;
     }
 
+    private static class HotSpotGraphKit extends GraphKit {
+
+        public HotSpotGraphKit(StructuredGraph graph, Providers providers) {
+            super(graph, providers);
+        }
+
+        @Override
+        public void rewriteWordTypes(SnippetReflectionProvider snippetReflection) {
+            new HotSpotWordTypeRewriterPhase(providers.getMetaAccess(), snippetReflection, providers.getCodeCache().getTarget().wordKind).apply(graph);
+        }
+    }
+
     private ParameterNode[] createParameters(GraphKit kit, Class<?>[] args) {
         ParameterNode[] params = new ParameterNode[args.length];
         ResolvedJavaType accessingClass = providers.getMetaAccess().lookupJavaType(getClass());
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java	Mon Nov 17 17:25:38 2014 +0100
@@ -37,6 +37,7 @@
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.hotspot.replacements.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodes.StructuredGraph.GuardsStage;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.replacements.*;
@@ -83,7 +84,7 @@
      * @param intArrayHub the hub for {@code int[].class}
      */
     @Snippet
-    private static Object newArray(TypePointer hub, int length, @ConstantParameter TypePointer intArrayHub, @ConstantParameter Register threadRegister) {
+    private static Object newArray(KlassPointer hub, int length, @ConstantParameter KlassPointer intArrayHub, @ConstantParameter Register threadRegister) {
         int layoutHelper = loadKlassLayoutHelperIntrinsic(hub);
         int log2ElementSize = (layoutHelper >> layoutHelperLog2ElementSizeShift()) & layoutHelperLog2ElementSizeMask();
         int headerSize = (layoutHelper >> layoutHelperHeaderSizeShift()) & layoutHelperHeaderSizeMask();
@@ -93,7 +94,7 @@
             printf("newArray: element kind %d\n", elementKind);
             printf("newArray: array length %d\n", length);
             printf("newArray: array size %d\n", sizeInBytes);
-            printf("newArray: hub=%p\n", Word.fromTypePointer(hub).rawValue());
+            printf("newArray: hub=%p\n", hub.asWord().rawValue());
         }
 
         // check that array length is small enough for fast path.
@@ -116,8 +117,8 @@
         return verifyObject(getAndClearObjectResult(thread));
     }
 
-    public static final ForeignCallDescriptor NEW_ARRAY_C = newDescriptor(NewArrayStub.class, "newArrayC", void.class, Word.class, TypePointer.class, int.class);
+    public static final ForeignCallDescriptor NEW_ARRAY_C = newDescriptor(NewArrayStub.class, "newArrayC", void.class, Word.class, KlassPointer.class, int.class);
 
     @NodeIntrinsic(StubForeignCallNode.class)
-    public static native void newArrayC(@ConstantNodeParameter ForeignCallDescriptor newArrayC, Word thread, TypePointer hub, int length);
+    public static native void newArrayC(@ConstantNodeParameter ForeignCallDescriptor newArrayC, Word thread, KlassPointer hub, int length);
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java	Mon Nov 17 17:25:38 2014 +0100
@@ -37,6 +37,7 @@
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.hotspot.replacements.*;
+import com.oracle.graal.hotspot.word.*;
 import com.oracle.graal.nodes.StructuredGraph.GuardsStage;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.replacements.*;
@@ -96,12 +97,12 @@
      * @param intArrayHub the hub for {@code int[].class}
      */
     @Snippet
-    private static Object newInstance(TypePointer hub, @ConstantParameter TypePointer intArrayHub, @ConstantParameter Register threadRegister) {
+    private static Object newInstance(KlassPointer hub, @ConstantParameter KlassPointer intArrayHub, @ConstantParameter Register threadRegister) {
         /*
          * The type is known to be an instance so Klass::_layout_helper is the instance size as a
          * raw number
          */
-        Pointer hubPtr = Word.fromTypePointer(hub);
+        Pointer hubPtr = hub.asWord();
         int sizeInBytes = loadKlassLayoutHelperIntrinsic(hub);
         Word thread = registerAsWord(threadRegister);
         if (!forceSlowPath() && inlineContiguousAllocationSupported()) {
@@ -134,7 +135,7 @@
      * @return the newly allocated, uninitialized chunk of memory, or {@link Word#zero()} if the
      *         operation was unsuccessful
      */
-    static Word refillAllocate(Word thread, TypePointer intArrayHub, int sizeInBytes, boolean log) {
+    static Word refillAllocate(Word thread, KlassPointer intArrayHub, int sizeInBytes, boolean log) {
         // If G1 is enabled, the "eden" allocation space is not the same always
         // and therefore we have to go to slowpath to allocate a new TLAB.
         if (useG1GC()) {
@@ -257,8 +258,8 @@
         return Boolean.getBoolean("graal.newInstanceStub.forceSlowPath");
     }
 
-    public static final ForeignCallDescriptor NEW_INSTANCE_C = newDescriptor(NewInstanceStub.class, "newInstanceC", void.class, Word.class, TypePointer.class);
+    public static final ForeignCallDescriptor NEW_INSTANCE_C = newDescriptor(NewInstanceStub.class, "newInstanceC", void.class, Word.class, KlassPointer.class);
 
     @NodeIntrinsic(StubForeignCallNode.class)
-    public static native void newInstanceC(@ConstantNodeParameter ForeignCallDescriptor newInstanceC, Word thread, TypePointer hub);
+    public static native void newInstanceC(@ConstantNodeParameter ForeignCallDescriptor newInstanceC, Word thread, KlassPointer hub);
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java	Mon Nov 17 17:25:38 2014 +0100
@@ -229,7 +229,7 @@
                     fatal("oop not in heap: %p", oop.rawValue());
                 }
 
-                Pointer klass = Word.fromTypePointer(loadHubIntrinsic(object, anchorNode));
+                Pointer klass = loadHubIntrinsic(object, anchorNode).asWord();
                 if (klass.equal(Word.zero())) {
                     fatal("klass for oop %p is null", oop.rawValue());
                 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/word/HotSpotOperation.java	Mon Nov 17 17:25:38 2014 +0100
@@ -0,0 +1,40 @@
+/*
+ * 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.hotspot.word;
+
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface HotSpotOperation {
+
+    public enum HotspotOpcode {
+        FROM_POINTER,
+        TO_KLASS_POINTER,
+        TO_METHOD_POINTER,
+        POINTER_EQ,
+        POINTER_NE
+    }
+
+    HotspotOpcode opcode();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/word/HotSpotWordTypeRewriterPhase.java	Mon Nov 17 17:25:38 2014 +0100
@@ -0,0 +1,144 @@
+/*
+ * 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.hotspot.word;
+
+import static com.oracle.graal.hotspot.word.HotSpotOperation.HotspotOpcode.*;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.compiler.common.*;
+import com.oracle.graal.compiler.common.type.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.hotspot.nodes.*;
+import com.oracle.graal.hotspot.word.HotSpotOperation.HotspotOpcode;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.calc.*;
+import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.nodes.type.*;
+import com.oracle.graal.word.nodes.*;
+import com.oracle.graal.word.phases.*;
+
+public class HotSpotWordTypeRewriterPhase extends WordTypeRewriterPhase {
+
+    private final ResolvedJavaType klassPointerType;
+    private final ResolvedJavaType methodPointerType;
+
+    public HotSpotWordTypeRewriterPhase(MetaAccessProvider metaAccess, SnippetReflectionProvider snippetReflection, Kind wordKind) {
+        super(metaAccess, snippetReflection, wordKind);
+        this.klassPointerType = metaAccess.lookupJavaType(KlassPointer.class);
+        this.methodPointerType = metaAccess.lookupJavaType(MethodPointer.class);
+    }
+
+    @Override
+    protected void changeToWord(StructuredGraph graph, ValueNode node) {
+        PointerType type = getPointerType(node);
+        if (type != null) {
+            node.setStamp(StampFactory.forPointer(type));
+        } else {
+            super.changeToWord(graph, node);
+        }
+    }
+
+    protected PointerType getPointerType(ValueNode node) {
+        return getPointerType(StampTool.typeOrNull(node));
+    }
+
+    protected PointerType getPointerType(ResolvedJavaType type) {
+        if (type != null) {
+            if (klassPointerType.isAssignableFrom(type)) {
+                return PointerType.Type;
+            } else if (methodPointerType.isAssignableFrom(type)) {
+                return PointerType.Method;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    protected void rewriteAccessIndexed(StructuredGraph graph, AccessIndexedNode node) {
+        if (node.stamp() instanceof PointerStamp && node instanceof LoadIndexedNode && node.elementKind() != Kind.Illegal) {
+            /*
+             * Prevent rewriting of the PointerStamp in the CanonicalizerPhase.
+             */
+            graph.replaceFixedWithFixed(node, graph.add(LoadIndexedPointerNode.create(node.stamp(), node.array(), node.index())));
+        } else {
+            super.rewriteAccessIndexed(graph, node);
+        }
+    }
+
+    @Override
+    protected void rewriteInvoke(StructuredGraph graph, MethodCallTargetNode callTargetNode) {
+        ResolvedJavaMethod targetMethod = callTargetNode.targetMethod();
+        HotSpotOperation operation = targetMethod.getAnnotation(HotSpotOperation.class);
+        if (operation == null) {
+            super.rewriteInvoke(graph, callTargetNode);
+        } else {
+            Invoke invoke = callTargetNode.invoke();
+            NodeInputList<ValueNode> arguments = callTargetNode.arguments();
+
+            switch (operation.opcode()) {
+                case POINTER_EQ:
+                case POINTER_NE:
+                    assert arguments.size() == 2;
+                    replace(invoke, pointerComparisonOp(graph, operation.opcode(), arguments.get(0), arguments.get(1)));
+                    break;
+
+                case FROM_POINTER:
+                    assert arguments.size() == 1;
+                    WordCastNode ptrToWord = graph.add(WordCastNode.pointerToWord(arguments.get(0), wordKind));
+                    graph.addBeforeFixed(invoke.asNode(), ptrToWord);
+                    replace(invoke, ptrToWord);
+                    break;
+
+                case TO_KLASS_POINTER:
+                    assert arguments.size() == 1;
+                    replaceToPointerOp(graph, invoke, PointerType.Type, arguments.get(0));
+                    break;
+
+                case TO_METHOD_POINTER:
+                    assert arguments.size() == 1;
+                    replaceToPointerOp(graph, invoke, PointerType.Method, arguments.get(0));
+                    break;
+
+                default:
+                    throw GraalInternalError.shouldNotReachHere("unknown operation: " + operation.opcode());
+            }
+        }
+    }
+
+    private void replaceToPointerOp(StructuredGraph graph, Invoke invoke, PointerType type, ValueNode word) {
+        WordCastNode wordToObject = graph.add(WordCastNode.wordToPointer(word, wordKind, type));
+        graph.addBeforeFixed(invoke.asNode(), wordToObject);
+        replace(invoke, wordToObject);
+    }
+
+    private static ValueNode pointerComparisonOp(StructuredGraph graph, HotspotOpcode opcode, ValueNode left, ValueNode right) {
+        assert left.stamp() instanceof PointerStamp && right.stamp() instanceof PointerStamp;
+        assert opcode == POINTER_EQ || opcode == POINTER_NE;
+
+        PointerEqualsNode comparison = graph.unique(PointerEqualsNode.create(left, right));
+        ValueNode eqValue = ConstantNode.forBoolean(opcode == POINTER_EQ, graph);
+        ValueNode neValue = ConstantNode.forBoolean(opcode == POINTER_NE, graph);
+        return graph.unique(ConditionalNode.create(comparison, eqValue, neValue));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/word/KlassPointer.java	Mon Nov 17 17:25:38 2014 +0100
@@ -0,0 +1,45 @@
+/*
+ * 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.hotspot.word;
+
+import static com.oracle.graal.hotspot.word.HotSpotOperation.HotspotOpcode.*;
+
+import com.oracle.graal.word.*;
+
+/**
+ * Marker type for a metaspace pointer to a type.
+ */
+public abstract class KlassPointer {
+
+    @HotSpotOperation(opcode = POINTER_EQ)
+    public abstract boolean equal(KlassPointer other);
+
+    @HotSpotOperation(opcode = POINTER_NE)
+    public abstract boolean notEqual(KlassPointer other);
+
+    @HotSpotOperation(opcode = FROM_POINTER)
+    public abstract Pointer asWord();
+
+    @HotSpotOperation(opcode = TO_KLASS_POINTER)
+    public static native KlassPointer fromWord(Pointer pointer);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/word/MethodPointer.java	Mon Nov 17 17:25:38 2014 +0100
@@ -0,0 +1,45 @@
+/*
+ * 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.hotspot.word;
+
+import static com.oracle.graal.hotspot.word.HotSpotOperation.HotspotOpcode.*;
+
+import com.oracle.graal.word.*;
+
+/**
+ * Marker type for a metaspace pointer to a method.
+ */
+public abstract class MethodPointer {
+
+    @HotSpotOperation(opcode = POINTER_EQ)
+    public abstract boolean equal(KlassPointer other);
+
+    @HotSpotOperation(opcode = POINTER_NE)
+    public abstract boolean notEqual(KlassPointer other);
+
+    @HotSpotOperation(opcode = FROM_POINTER)
+    public abstract Pointer asWord();
+
+    @HotSpotOperation(opcode = TO_METHOD_POINTER)
+    public static native MethodPointer fromWord(Pointer pointer);
+}
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/MethodPointer.java	Mon Nov 17 14:59:54 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +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.word;
-
-import com.oracle.graal.api.meta.*;
-
-/**
- * Marker interface for a metaspace pointer to a method.
- */
-public interface MethodPointer extends TrustedInterface {
-}
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java	Mon Nov 17 17:25:38 2014 +0100
@@ -46,10 +46,6 @@
      */
     Object toObject();
 
-    TypePointer toTypePointer();
-
-    MethodPointer toMethodPointer();
-
     /**
      * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
      * bytes.
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/TypePointer.java	Mon Nov 17 14:59:54 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +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.word;
-
-import com.oracle.graal.api.meta.*;
-
-/**
- * Marker interface for a metaspace pointer to a type.
- */
-public interface TypePointer extends TrustedInterface {
-}
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java	Mon Nov 17 17:25:38 2014 +0100
@@ -72,11 +72,8 @@
          FROM_UNSIGNED,
          FROM_SIGNED,
          FROM_OBJECT,
-         FROM_POINTER,
          FROM_ARRAY,
          TO_OBJECT,
-         TO_METHOD_POINTER,
-         TO_TYPE_POINTER,
          TO_RAW_VALUE,
     }
      // @formatter:on
@@ -176,12 +173,6 @@
     @Operation(opcode = Opcode.FROM_OBJECT)
     public static native Pointer fromObject(Object val);
 
-    @Operation(opcode = Opcode.FROM_POINTER)
-    public static native Pointer fromMethodPointer(MethodPointer val);
-
-    @Operation(opcode = Opcode.FROM_POINTER)
-    public static native Pointer fromTypePointer(TypePointer val);
-
     @Operation(opcode = Opcode.FROM_ARRAY)
     public static native Pointer fromArray(Object oop, Object location);
 
@@ -190,26 +181,6 @@
     public native Object toObject();
 
     @Override
-    @Operation(opcode = Opcode.TO_METHOD_POINTER)
-    public native MethodPointer toMethodPointer();
-
-    @Override
-    @Operation(opcode = Opcode.TO_TYPE_POINTER)
-    public native TypePointer toTypePointer();
-
-    @Operation(opcode = Opcode.COMPARISON, condition = Condition.EQ)
-    public static native boolean equal(MethodPointer a, MethodPointer b);
-
-    @Operation(opcode = Opcode.COMPARISON, condition = Condition.EQ)
-    public static native boolean equal(TypePointer a, TypePointer b);
-
-    @Operation(opcode = Opcode.COMPARISON, condition = Condition.NE)
-    public static native boolean notEqual(MethodPointer a, MethodPointer b);
-
-    @Operation(opcode = Opcode.COMPARISON, condition = Condition.NE)
-    public static native boolean notEqual(TypePointer a, TypePointer b);
-
-    @Override
     @Operation(node = AddNode.class)
     public Word add(Signed val) {
         return add((Word) val);
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/LoadIndexedPointerNode.java	Mon Nov 17 14:59:54 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +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.word.nodes;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.nodeinfo.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.java.*;
-
-@NodeInfo
-public class LoadIndexedPointerNode extends LoadIndexedNode {
-
-    public static LoadIndexedPointerNode create(Stamp stamp, ValueNode array, ValueNode index) {
-        return new LoadIndexedPointerNode(stamp, array, index);
-    }
-
-    protected LoadIndexedPointerNode(Stamp stamp, ValueNode array, ValueNode index) {
-        super(stamp, array, index, Kind.Illegal);
-    }
-
-    @Override
-    public boolean inferStamp() {
-        return false;
-    }
-}
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Mon Nov 17 14:59:54 2014 +0100
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Mon Nov 17 17:25:38 2014 +0100
@@ -56,8 +56,6 @@
     protected final SnippetReflectionProvider snippetReflection;
     protected final ResolvedJavaType wordBaseType;
     protected final ResolvedJavaType wordImplType;
-    protected final ResolvedJavaType typePointerType;
-    protected final ResolvedJavaType methodPointerType;
     protected final ResolvedJavaType objectAccessType;
     protected final ResolvedJavaType barrieredAccessType;
     protected final Kind wordKind;
@@ -68,8 +66,6 @@
         this.wordKind = wordKind;
         this.wordBaseType = metaAccess.lookupJavaType(WordBase.class);
         this.wordImplType = metaAccess.lookupJavaType(Word.class);
-        this.typePointerType = metaAccess.lookupJavaType(TypePointer.class);
-        this.methodPointerType = metaAccess.lookupJavaType(MethodPointer.class);
         this.objectAccessType = metaAccess.lookupJavaType(ObjectAccess.class);
         this.barrieredAccessType = metaAccess.lookupJavaType(BarrieredAccess.class);
     }
@@ -105,11 +101,6 @@
             } else {
                 node.setStamp(StampFactory.forKind(wordKind));
             }
-        } else {
-            PointerType pointer = getPointerType(node);
-            if (pointer != null) {
-                node.setStamp(StampFactory.forPointer(pointer));
-            }
         }
     }
 
@@ -172,11 +163,6 @@
             } else {
                 throw GraalInternalError.shouldNotReachHere();
             }
-        } else if (node.stamp() instanceof PointerStamp && node instanceof LoadIndexedNode && node.elementKind() != Kind.Illegal) {
-            /*
-             * Prevent rewriting of the PointerStamp.
-             */
-            graph.replaceFixedWithFixed(node, graph.add(LoadIndexedPointerNode.create(node.stamp(), node.array(), node.index())));
         }
     }
 
@@ -222,7 +208,7 @@
 
             case COMPARISON:
                 assert arguments.size() == 2;
-                replace(invoke, comparisonOp(graph, operation.condition(), arguments.get(0), arguments.get(1)));
+                replace(invoke, comparisonOp(graph, operation.condition(), arguments.get(0), fromSigned(graph, arguments.get(1))));
                 break;
 
             case NOT:
@@ -288,7 +274,6 @@
                 break;
 
             case FROM_OBJECT:
-            case FROM_POINTER:
                 assert arguments.size() == 1;
                 WordCastNode objectToWord = graph.add(WordCastNode.pointerToWord(arguments.get(0), wordKind));
                 graph.addBeforeFixed(invoke.asNode(), objectToWord);
@@ -301,24 +286,8 @@
                 break;
 
             case TO_OBJECT:
-            case TO_METHOD_POINTER:
-            case TO_TYPE_POINTER:
                 assert arguments.size() == 1;
-                PointerType type;
-                switch (operation.opcode()) {
-                    case TO_OBJECT:
-                        type = PointerType.Object;
-                        break;
-                    case TO_METHOD_POINTER:
-                        type = PointerType.Method;
-                        break;
-                    case TO_TYPE_POINTER:
-                        type = PointerType.Type;
-                        break;
-                    default:
-                        throw GraalInternalError.shouldNotReachHere();
-                }
-                WordCastNode wordToObject = graph.add(WordCastNode.wordToPointer(arguments.get(0), wordKind, type));
+                WordCastNode wordToObject = graph.add(WordCastNode.wordToPointer(arguments.get(0), wordKind, PointerType.Object));
                 graph.addBeforeFixed(invoke.asNode(), wordToObject);
                 replace(invoke, wordToObject);
                 break;
@@ -374,6 +343,8 @@
     }
 
     private ValueNode comparisonOp(StructuredGraph graph, Condition condition, ValueNode left, ValueNode right) {
+        assert left.getKind() == wordKind && right.getKind() == wordKind;
+
         // mirroring gets the condition into canonical form
         boolean mirror = condition.canonicalMirror();
 
@@ -381,21 +352,12 @@
         ValueNode b = mirror ? left : right;
 
         CompareNode comparison;
-        if (left.stamp() instanceof AbstractPointerStamp) {
-            assert right.stamp() instanceof AbstractPointerStamp;
-            assert condition == Condition.EQ || condition == Condition.NE;
-            comparison = PointerEqualsNode.create(a, b);
+        if (condition == Condition.EQ || condition == Condition.NE) {
+            comparison = IntegerEqualsNode.create(a, b);
+        } else if (condition.isUnsigned()) {
+            comparison = IntegerBelowNode.create(a, b);
         } else {
-            a = fromSigned(graph, a);
-            b = fromSigned(graph, b);
-            assert a.getKind() == wordKind && b.getKind() == wordKind;
-            if (condition == Condition.EQ || condition == Condition.NE) {
-                comparison = IntegerEqualsNode.create(a, b);
-            } else if (condition.isUnsigned()) {
-                comparison = IntegerBelowNode.create(a, b);
-            } else {
-                comparison = IntegerLessThanNode.create(a, b);
-            }
+            comparison = IntegerLessThanNode.create(a, b);
         }
 
         ConstantNode trueValue = ConstantNode.forInt(1, graph);
@@ -468,21 +430,6 @@
         return type != null && wordBaseType.isAssignableFrom(type);
     }
 
-    protected PointerType getPointerType(ValueNode node) {
-        return getPointerType(StampTool.typeOrNull(node));
-    }
-
-    protected PointerType getPointerType(ResolvedJavaType type) {
-        if (type != null) {
-            if (typePointerType.isAssignableFrom(type)) {
-                return PointerType.Type;
-            } else if (methodPointerType.isAssignableFrom(type)) {
-                return PointerType.Method;
-            }
-        }
-        return null;
-    }
-
     protected Kind asKind(JavaType type) {
         if (type instanceof ResolvedJavaType && isWord((ResolvedJavaType) type)) {
             return wordKind;