# HG changeset patch # User Doug Simon # Date 1353011543 -3600 # Node ID 0e20ad1ea98bc8ff50976dc6efb18a61a6d8d8c2 # Parent 606964349cf4978bedec0a69d1ce7b53b926baa0 removed WordStamp (and a nasty bug associated with its misusage) diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Thu Nov 15 21:32:23 2012 +0100 @@ -33,6 +33,7 @@ import com.oracle.graal.hotspot.logging.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.*; /** @@ -61,12 +62,24 @@ } private static Kind wordKind; + private static Stamp wordStamp; + /** + * Gets the kind of a word value. + */ public static Kind wordKind() { assert wordKind != null; return wordKind; } + /** + * Gets the stamp for a word value. + */ + public static Stamp wordStamp() { + assert wordStamp != null; + return wordStamp; + } + protected final CompilerToVM compilerToVm; protected final VMToCompiler vmToCompiler; @@ -109,6 +122,7 @@ target = createTarget(); assert wordKind == null || wordKind.equals(target.wordKind); wordKind = target.wordKind; + wordStamp = StampFactory.forInteger(wordKind, wordKind.getMinValue(), wordKind.getMaxValue()); runtime = createRuntime(); diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Thu Nov 15 21:32:23 2012 +0100 @@ -134,7 +134,7 @@ @Override public void run() { VMToCompilerImpl.this.intrinsifyArrayCopy = new IntrinsifyArrayCopyPhase(runtime); - SnippetInstaller installer = new SnippetInstaller(runtime, runtime.getGraalRuntime().getTarget()); + SnippetInstaller installer = new SnippetInstaller(runtime, runtime.getGraalRuntime().getTarget(), HotSpotGraalRuntime.wordStamp()); GraalIntrinsics.installIntrinsics(installer); runtime.installSnippets(installer); } diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Nov 15 21:32:23 2012 +0100 @@ -26,6 +26,7 @@ import static com.oracle.graal.api.code.MemoryBarriers.*; import static com.oracle.graal.api.meta.DeoptimizationReason.*; import static com.oracle.graal.api.meta.Value.*; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import static com.oracle.graal.hotspot.snippets.SystemSnippets.*; import static com.oracle.graal.java.GraphBuilderPhase.*; import static com.oracle.graal.nodes.StructuredGraph.*; @@ -397,9 +398,8 @@ // as HotSpot does not guarantee they are final values. assert vtableEntryOffset > 0; LoadHubNode hub = graph.add(new LoadHubNode(receiver, wordKind)); - Stamp nonZeroWordStamp = StampFactory.forWord(wordKind, true); - ReadNode metaspaceMethod = graph.add(new ReadNode(hub, LocationNode.create(LocationNode.ANY_LOCATION, wordKind, vtableEntryOffset, graph), nonZeroWordStamp)); - ReadNode compiledEntry = graph.add(new ReadNode(metaspaceMethod, LocationNode.create(LocationNode.ANY_LOCATION, wordKind, config.methodCompiledEntryOffset, graph), nonZeroWordStamp)); + ReadNode metaspaceMethod = graph.add(new ReadNode(hub, LocationNode.create(LocationNode.ANY_LOCATION, wordKind, vtableEntryOffset, graph), wordStamp())); + ReadNode compiledEntry = graph.add(new ReadNode(metaspaceMethod, LocationNode.create(LocationNode.ANY_LOCATION, wordKind, config.methodCompiledEntryOffset, graph), wordStamp())); loweredCallTarget = graph.add(new HotSpotIndirectCallTargetNode(metaspaceMethod, compiledEntry, parameters, invoke.node().stamp(), signature, callTarget.targetMethod(), CallingConvention.Type.JavaCall)); @@ -490,10 +490,9 @@ value = checkcast; } } else { - Stamp nonZeroWordStamp = StampFactory.forWord(wordKind, true); LoadHubNode arrayClass = graph.add(new LoadHubNode(array, wordKind)); LocationNode location = LocationNode.create(LocationNode.FINAL_LOCATION, wordKind, config.arrayClassElementOffset, graph); - FloatingReadNode arrayElementKlass = graph.unique(new FloatingReadNode(arrayClass, location, null, nonZeroWordStamp)); + FloatingReadNode arrayElementKlass = graph.unique(new FloatingReadNode(arrayClass, location, null, wordStamp())); CheckCastDynamicNode checkcast = graph.add(new CheckCastDynamicNode(arrayElementKlass, value)); graph.addBeforeFixed(storeIndexed, checkcast); graph.addBeforeFixed(checkcast, arrayClass); @@ -540,7 +539,7 @@ LocationNode location = LocationNode.create(LocationNode.FINAL_LOCATION, wordKind, config.hubOffset, graph); ValueNode object = loadHub.object(); ValueNode guard = tool.createNullCheckGuard(object, StructuredGraph.INVALID_GRAPH_ID); - ReadNode hub = graph.add(new ReadNode(object, location, StampFactory.forWord(wordKind, true))); + ReadNode hub = graph.add(new ReadNode(object, location, wordStamp())); hub.dependencies().add(guard); graph.replaceFixed(loadHub, hub); } else if (n instanceof CheckCastNode) { @@ -617,7 +616,7 @@ if (fullName.equals("getModifiers()I")) { StructuredGraph graph = new StructuredGraph(); LocalNode receiver = graph.unique(new LocalNode(0, StampFactory.objectNonNull())); - SafeReadNode klass = safeRead(graph, wordKind, receiver, config.klassOffset, StampFactory.forWord(wordKind, true), INVALID_GRAPH_ID); + SafeReadNode klass = safeRead(graph, wordKind, receiver, config.klassOffset, wordStamp(), INVALID_GRAPH_ID); graph.start().setNext(klass); LocationNode location = LocationNode.create(LocationNode.FINAL_LOCATION, Kind.Int, config.klassModifierFlagsOffset, graph); FloatingReadNode readModifiers = graph.unique(new FloatingReadNode(klass, location, null, StampFactory.intValue())); diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java Thu Nov 15 21:32:23 2012 +0100 @@ -26,9 +26,9 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.target.*; +import com.oracle.graal.hotspot.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.type.*; import com.oracle.graal.snippets.*; /** @@ -42,8 +42,8 @@ private final boolean eliminated; - public BeginLockScopeNode(boolean eliminated, Kind wordKind) { - super(StampFactory.forWord(wordKind, true)); + public BeginLockScopeNode(boolean eliminated) { + super(HotSpotGraalRuntime.wordStamp()); this.eliminated = eliminated; } @@ -63,5 +63,5 @@ } @NodeIntrinsic - public static native Word beginLockScope(@ConstantNodeParameter boolean eliminated, @ConstantNodeParameter Kind wordKind); + public static native Word beginLockScope(@ConstantNodeParameter boolean eliminated); } diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentLockNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentLockNode.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentLockNode.java Thu Nov 15 21:32:23 2012 +0100 @@ -25,8 +25,8 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.target.*; +import com.oracle.graal.hotspot.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.type.*; import com.oracle.graal.snippets.*; /** @@ -34,8 +34,8 @@ */ public final class CurrentLockNode extends FixedWithNextNode implements LIRGenLowerable { - public CurrentLockNode(Kind wordKind) { - super(StampFactory.forWord(wordKind, true)); + public CurrentLockNode() { + super(HotSpotGraalRuntime.wordStamp()); } @Override @@ -46,5 +46,5 @@ } @NodeIntrinsic - public static native Word currentLock(@ConstantNodeParameter Kind wordKind); + public static native Word currentLock(); } diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DimensionsNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DimensionsNode.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DimensionsNode.java Thu Nov 15 21:32:23 2012 +0100 @@ -26,9 +26,9 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.target.*; +import com.oracle.graal.hotspot.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.type.*; import com.oracle.graal.snippets.*; @@ -40,8 +40,8 @@ private final int rank; - public DimensionsNode(int rank, Kind wordKind) { - super(StampFactory.forWord(wordKind, true)); + public DimensionsNode(int rank) { + super(HotSpotGraalRuntime.wordStamp()); this.rank = rank; } @@ -54,5 +54,5 @@ } @NodeIntrinsic - public static native Word allocaDimsArray(@ConstantNodeParameter int rank, @ConstantNodeParameter Kind wordKind); + public static native Word allocaDimsArray(@ConstantNodeParameter int rank); } diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorCounterNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorCounterNode.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorCounterNode.java Thu Nov 15 21:32:23 2012 +0100 @@ -26,8 +26,8 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.target.*; +import com.oracle.graal.hotspot.*; import com.oracle.graal.nodes.calc.*; -import com.oracle.graal.nodes.type.*; import com.oracle.graal.snippets.*; /** @@ -36,8 +36,8 @@ */ public final class MonitorCounterNode extends FloatingNode implements LIRGenLowerable { - public MonitorCounterNode(Kind wordKind) { - super(StampFactory.forWord(wordKind, true)); + public MonitorCounterNode() { + super(HotSpotGraalRuntime.wordStamp()); } @Override @@ -49,5 +49,5 @@ } @NodeIntrinsic - public static native Word counter(@ConstantNodeParameter Kind wordKind); + public static native Word counter(); } diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TLABAllocateNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TLABAllocateNode.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TLABAllocateNode.java Thu Nov 15 21:32:23 2012 +0100 @@ -22,10 +22,9 @@ */ package com.oracle.graal.hotspot.nodes; -import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.type.*; import com.oracle.graal.snippets.*; /** @@ -36,8 +35,8 @@ @Input private ValueNode size; - public TLABAllocateNode(ValueNode size, Kind wordKind) { - super(StampFactory.forWord(wordKind, true)); + public TLABAllocateNode(ValueNode size) { + super(HotSpotGraalRuntime.wordStamp()); this.size = size; } @@ -54,5 +53,5 @@ * @return null if allocation fails */ @NodeIntrinsic - public static native Word allocateVariableSize(int size, @ConstantNodeParameter Kind wordKind); + public static native Word allocateVariableSize(int size); } diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/CheckCastSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/CheckCastSnippets.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/CheckCastSnippets.java Thu Nov 15 21:32:23 2012 +0100 @@ -21,6 +21,7 @@ * questions. */ package com.oracle.graal.hotspot.snippets; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import static com.oracle.graal.hotspot.snippets.HotSpotSnippetUtils.*; import static com.oracle.graal.snippets.SnippetTemplate.*; import static com.oracle.graal.snippets.SnippetTemplate.Arguments.*; @@ -29,13 +30,12 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; -import com.oracle.graal.graph.Node.*; +import com.oracle.graal.graph.Node.NodeIntrinsic; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.*; import com.oracle.graal.snippets.*; import com.oracle.graal.snippets.Snippet.ConstantParameter; @@ -267,7 +267,7 @@ arguments = arguments("hub", hub).add("object", object); } else { ConstantNode[] hints = createHints(hintInfo, runtime, graph); - key = new Key(secondary).add("hints", Varargs.vargargs(new Word[hints.length], StampFactory.forWord(wordKind(), true))).add("checkNull", checkNull); + key = new Key(secondary).add("hints", Varargs.vargargs(new Word[hints.length], wordStamp())).add("checkNull", checkNull); arguments = arguments("hub", hub).add("object", object).add("hints", hints); } diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/InstanceOfSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/InstanceOfSnippets.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/InstanceOfSnippets.java Thu Nov 15 21:32:23 2012 +0100 @@ -21,6 +21,7 @@ * questions. */ package com.oracle.graal.hotspot.snippets; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import static com.oracle.graal.hotspot.snippets.CheckCastSnippets.*; import static com.oracle.graal.hotspot.snippets.CheckCastSnippets.Templates.*; import static com.oracle.graal.hotspot.snippets.HotSpotSnippetUtils.*; @@ -32,7 +33,6 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.*; import com.oracle.graal.snippets.*; import com.oracle.graal.snippets.Snippet.ConstantParameter; @@ -193,7 +193,7 @@ arguments = arguments("hub", hub).add("object", object).add("trueValue", trueValue).add("falseValue", falseValue); } else { ConstantNode[] hints = createHints(hintInfo, runtime, hub.graph()); - key = new Key(instanceofSecondary).add("hints", Varargs.vargargs(new Word[hints.length], StampFactory.forWord(wordKind(), true))).add("checkNull", checkNull); + key = new Key(instanceofSecondary).add("hints", Varargs.vargargs(new Word[hints.length], wordStamp())).add("checkNull", checkNull); arguments = arguments("hub", hub).add("object", object).add("hints", hints).add("trueValue", trueValue).add("falseValue", falseValue); } return new KeyAndArguments(key, arguments); diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/MonitorSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/MonitorSnippets.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/MonitorSnippets.java Thu Nov 15 21:32:23 2012 +0100 @@ -84,7 +84,7 @@ // Load the mark word - this includes a null-check on object final Word mark = loadWordFromObject(object, markOffset()); - final Word lock = beginLockScope(false, wordKind()); + final Word lock = beginLockScope(false); trace(trace, " object: 0x%016lx\n", Word.fromObject(object).toLong()); trace(trace, " lock: 0x%016lx\n", lock.toLong()); @@ -249,7 +249,7 @@ @Snippet public static void monitorenterEliminated() { incCounter(); - beginLockScope(true, wordKind()); + beginLockScope(true); } /** @@ -264,7 +264,7 @@ } // BeginLockScope nodes do not read from object so a use of object // cannot float about the null check above - final Word lock = beginLockScope(false, wordKind()); + final Word lock = beginLockScope(false); trace(trace, "+lock{stub}", object); MonitorEnterStubCall.call(object, lock); } @@ -289,7 +289,7 @@ } } - final Word lock = CurrentLockNode.currentLock(wordKind()); + final Word lock = CurrentLockNode.currentLock(); // Load displaced mark final Word displacedMark = loadWordFromWord(lock, lockDisplacedMarkOffset()); @@ -358,7 +358,7 @@ private static void incCounter() { if (CHECK_BALANCED_MONITORS) { - final Word counter = MonitorCounterNode.counter(wordKind()); + final Word counter = MonitorCounterNode.counter(); final int count = UnsafeLoadNode.load(counter, 0, 0, Kind.Int); DirectObjectStoreNode.storeInt(counter, 0, 0, count + 1); } @@ -366,7 +366,7 @@ private static void decCounter() { if (CHECK_BALANCED_MONITORS) { - final Word counter = MonitorCounterNode.counter(wordKind()); + final Word counter = MonitorCounterNode.counter(); final int count = UnsafeLoadNode.load(counter, 0, 0, Kind.Int); DirectObjectStoreNode.storeInt(counter, 0, 0, count - 1); } @@ -374,13 +374,13 @@ @Snippet private static void initCounter() { - final Word counter = MonitorCounterNode.counter(wordKind()); + final Word counter = MonitorCounterNode.counter(); DirectObjectStoreNode.storeInt(counter, 0, 0, 0); } @Snippet private static void checkCounter(String errMsg) { - final Word counter = MonitorCounterNode.counter(wordKind()); + final Word counter = MonitorCounterNode.counter(); final int count = UnsafeLoadNode.load(counter, 0, 0, Kind.Int); if (count != 0) { vmError(errMsg, count); diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java Thu Nov 15 21:32:23 2012 +0100 @@ -155,14 +155,13 @@ @ConstantParameter("alignment") int alignment, @ConstantParameter("headerSize") int headerSize, @ConstantParameter("log2ElementSize") int log2ElementSize, - @ConstantParameter("type") ResolvedJavaType type, - @ConstantParameter("wordKind") Kind wordKind) { + @ConstantParameter("type") ResolvedJavaType type) { if (!belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) { // This handles both negative array sizes and very large array sizes DeoptimizeNode.deopt(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.RuntimeConstraint); } int size = getArraySize(length, alignment, headerSize, log2ElementSize); - Word memory = TLABAllocateNode.allocateVariableSize(size, wordKind); + Word memory = TLABAllocateNode.allocateVariableSize(size); return InitializeArrayNode.initialize(memory, length, size, type, true, false); } @@ -180,7 +179,7 @@ @Parameter("hub") Word hub, @ConstantParameter("rank") int rank, @VarargsParameter("dimensions") int[] dimensions) { - Word dims = DimensionsNode.allocaDimsArray(rank, wordKind()); + Word dims = DimensionsNode.allocaDimsArray(rank); ExplodeLoopNode.explodeLoop(); for (int i = 0; i < rank; i++) { DirectObjectStoreNode.storeInt(dims, 0, i * 4, dimensions[i]); @@ -251,7 +250,7 @@ initializeObject = snippet("initializeObject", Word.class, Word.class, Word.class, int.class, boolean.class, boolean.class); initializeObjectArray = snippet("initializeObjectArray", Word.class, Word.class, int.class, int.class, Word.class, int.class, boolean.class, boolean.class); initializePrimitiveArray = snippet("initializePrimitiveArray", Word.class, Word.class, int.class, int.class, Word.class, int.class, boolean.class, boolean.class); - allocateArrayAndInitialize = snippet("allocateArrayAndInitialize", int.class, int.class, int.class, int.class, ResolvedJavaType.class, Kind.class); + allocateArrayAndInitialize = snippet("allocateArrayAndInitialize", int.class, int.class, int.class, int.class, ResolvedJavaType.class); newmultiarray = snippet("newmultiarray", Word.class, int.class, int[].class); } @@ -272,7 +271,7 @@ memory = ConstantNode.forConstant(new Constant(target.wordKind, 0L), runtime, graph); } else { ConstantNode sizeNode = ConstantNode.forInt(size, graph); - TLABAllocateNode tlabAllocateNode = graph.add(new TLABAllocateNode(sizeNode, wordKind())); + TLABAllocateNode tlabAllocateNode = graph.add(new TLABAllocateNode(sizeNode)); graph.addBeforeFixed(newInstanceNode, tlabAllocateNode); memory = tlabAllocateNode; } @@ -306,7 +305,7 @@ // Calculate aligned size int size = getArraySize(length, alignment, headerSize, log2ElementSize); ConstantNode sizeNode = ConstantNode.forInt(size, graph); - tlabAllocateNode = graph.add(new TLABAllocateNode(sizeNode, target.wordKind)); + tlabAllocateNode = graph.add(new TLABAllocateNode(sizeNode)); graph.addBeforeFixed(newArrayNode, tlabAllocateNode); InitializeArrayNode initializeNode = graph.add(new InitializeArrayNode(tlabAllocateNode, lengthNode, sizeNode, arrayType, newArrayNode.fillContents(), newArrayNode.locked())); graph.replaceFixedWithFixed(newArrayNode, initializeNode); @@ -315,7 +314,6 @@ add("alignment", alignment). add("headerSize", headerSize). add("log2ElementSize", log2ElementSize). - add("wordKind", target.wordKind). add("type", arrayType); Arguments arguments = new Arguments().add("length", lengthNode); SnippetTemplate template = cache.get(key); diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java Thu Nov 15 21:32:23 2012 +0100 @@ -61,10 +61,6 @@ setCache(Kind.Void, voidStamp); } - public static Stamp forWord(Kind wordKind, boolean nonNull) { - return new WordStamp(wordKind, nonNull); - } - public static Stamp forKind(Kind kind) { assert stampCache[kind.getStackKind().ordinal()] != null : "unexpected forKind(" + kind + ")"; return stampCache[kind.getStackKind().ordinal()]; diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/WordStamp.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/WordStamp.java Wed Nov 14 16:14:34 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2012, 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.nodes.type; - -import com.oracle.graal.api.meta.*; - -/** - * Models the word type. - */ -public class WordStamp extends IntegerStamp { - - private final boolean nonNull; - - public WordStamp(Kind wordKind, boolean nonNull) { - super(wordKind); - this.nonNull = nonNull; - } - - @Override - public boolean nonNull() { - return nonNull; - } - - @Override - public String toString() { - StringBuilder str = new StringBuilder(); - str.append(kind().getTypeChar()); - str.append(nonNull ? "!" : ""); - return str.toString(); - } - - @Override - public boolean alwaysDistinct(Stamp otherStamp) { - return false; - } - - @Override - public Stamp meet(Stamp otherStamp) { - if (otherStamp.getClass() == IntegerStamp.class) { - IntegerStamp istamp = (IntegerStamp) otherStamp; - assert istamp.lowerBound() == istamp.upperBound() : "expected a word constant"; - return istamp; - } - WordStamp other = (WordStamp) otherStamp; - boolean meetNonNull = nonNull && other.nonNull; - if (meetNonNull == this.nonNull) { - return this; - } else if (meetNonNull == other.nonNull) { - return other; - } else { - return new WordStamp(kind(), meetNonNull); - } - } - - @Override - public Stamp join(Stamp otherStamp) { - WordStamp other = (WordStamp) otherStamp; - boolean joinNonNull = nonNull || other.nonNull; - if (joinNonNull == this.nonNull) { - return this; - } else if (joinNonNull == other.nonNull) { - return other; - } else { - return new WordStamp(kind(), joinNonNull); - } - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (nonNull ? 1231 : 1237); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - WordStamp other = (WordStamp) obj; - if (nonNull != other.nonNull) { - return false; - } - return true; - } -} diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/WordTest.java --- a/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/WordTest.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/WordTest.java Thu Nov 15 21:32:23 2012 +0100 @@ -32,6 +32,7 @@ import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.type.*; import com.oracle.graal.snippets.Snippet.InliningPolicy; /** @@ -43,7 +44,9 @@ public WordTest() { TargetDescription target = Graal.getRequiredCapability(GraalCompiler.class).target; - installer = new SnippetInstaller(runtime, target); + Kind wordKind = target.wordKind; + Stamp wordStamp = StampFactory.forInteger(wordKind, wordKind.getMinValue(), wordKind.getMaxValue()); + installer = new SnippetInstaller(runtime, target, wordStamp); } private static final ThreadLocal inliningPolicy = new ThreadLocal<>(); diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetInstaller.java --- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetInstaller.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetInstaller.java Thu Nov 15 21:32:23 2012 +0100 @@ -35,6 +35,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; +import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; import com.oracle.graal.snippets.Snippet.InliningPolicy; @@ -46,6 +47,7 @@ private final MetaAccessProvider runtime; private final TargetDescription target; + private final Stamp wordStamp; private final BoxingMethodPool pool; /** @@ -56,9 +58,10 @@ */ private final Map graphCache; - public SnippetInstaller(MetaAccessProvider runtime, TargetDescription target) { + public SnippetInstaller(MetaAccessProvider runtime, TargetDescription target, Stamp wordStamp) { this.runtime = runtime; this.target = target; + this.wordStamp = wordStamp; this.pool = new BoxingMethodPool(runtime); this.graphCache = new HashMap<>(); } @@ -179,7 +182,7 @@ InliningUtil.inline(invoke, targetGraph, true); Debug.dump(graph, "after inlining %s", callee); if (GraalOptions.OptCanonicalizer) { - new WordTypeRewriterPhase(target.wordKind, runtime.lookupJavaType(target.wordKind.toJavaClass())).apply(graph); + new WordTypeRewriterPhase(target.wordKind, wordStamp, runtime.lookupJavaType(target.wordKind.toJavaClass())).apply(graph); new CanonicalizerPhase(target, runtime, null).apply(graph); } } @@ -187,7 +190,7 @@ new SnippetIntrinsificationPhase(runtime, pool, true).apply(graph); - new WordTypeRewriterPhase(target.wordKind, runtime.lookupJavaType(target.wordKind.toJavaClass())).apply(graph); + new WordTypeRewriterPhase(target.wordKind, wordStamp, runtime.lookupJavaType(target.wordKind.toJavaClass())).apply(graph); new DeadCodeEliminationPhase().apply(graph); if (GraalOptions.OptCanonicalizer) { diff -r 606964349cf4 -r 0e20ad1ea98b graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/WordTypeRewriterPhase.java --- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/WordTypeRewriterPhase.java Wed Nov 14 16:14:34 2012 +0100 +++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/WordTypeRewriterPhase.java Thu Nov 15 21:32:23 2012 +0100 @@ -46,11 +46,13 @@ private static final String WordClassName = MetaUtil.toInternalName(Word.class.getName()); private final Kind wordKind; + private final Stamp wordStamp; private final ResolvedJavaType wordType; - public WordTypeRewriterPhase(Kind wordKind, ResolvedJavaType wordType) { + public WordTypeRewriterPhase(Kind wordKind, Stamp wordStamp, ResolvedJavaType wordType) { this.wordKind = wordKind; this.wordType = wordType; + this.wordStamp = wordStamp; } @Override @@ -85,7 +87,7 @@ // Replace ObjectEqualsNodes with IntegerEqualsNodes where the values being compared are words for (LoadIndexedNode load : graph.getNodes().filter(LoadIndexedNode.class).snapshot()) { if (isWord(load)) { - load.setStamp(StampFactory.forWord(wordKind, false)); + load.setStamp(wordStamp); } } @@ -293,9 +295,6 @@ } public static boolean isWord(ValueNode node) { - if (node.stamp() instanceof WordStamp) { - return true; - } if (node instanceof LoadIndexedNode) { return isWord(((LoadIndexedNode) node).array().objectStamp().type().getComponentType()); } @@ -314,7 +313,7 @@ private void changeToWord(ValueNode valueNode) { assert !(valueNode instanceof ConstantNode); - valueNode.setStamp(StampFactory.forKind(wordKind)); + valueNode.setStamp(wordStamp); // Propagate word kind. for (Node n : valueNode.usages()) {