# HG changeset patch # User Lukas Stadler # Date 1368539816 -7200 # Node ID 0d0645267c32d3db2cc520ab9263f37f4a653fc6 # Parent a7376cc486ff4b5d1f148caf5a7b8a4acaf2de1b simplify NewObjectSnippets diff -r a7376cc486ff -r 0d0645267c32 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 Tue May 14 14:48:38 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Tue May 14 15:56:56 2013 +0200 @@ -510,7 +510,7 @@ checkcastSnippets = new CheckCastSnippets.Templates(this, replacements, graalRuntime.getTarget()); instanceofSnippets = new InstanceOfSnippets.Templates(this, replacements, graalRuntime.getTarget()); - newObjectSnippets = new NewObjectSnippets.Templates(this, replacements, graalRuntime.getTarget(), config.useTLAB); + newObjectSnippets = new NewObjectSnippets.Templates(this, replacements, graalRuntime.getTarget()); monitorSnippets = new MonitorSnippets.Templates(this, replacements, graalRuntime.getTarget(), config.useFastLocking); writeBarrierSnippets = new WriteBarrierSnippets.Templates(this, replacements, graalRuntime.getTarget()); boxingSnippets = new BoxingSnippets.Templates(this, replacements, graalRuntime.getTarget()); @@ -963,9 +963,9 @@ } else if (n instanceof InstanceOfDynamicNode) { instanceofSnippets.lower((InstanceOfDynamicNode) n, tool); } else if (n instanceof NewInstanceNode) { - newObjectSnippets.lower((NewInstanceNode) n, tool); + newObjectSnippets.lower((NewInstanceNode) n); } else if (n instanceof NewArrayNode) { - newObjectSnippets.lower((NewArrayNode) n, tool); + newObjectSnippets.lower((NewArrayNode) n); } else if (n instanceof MonitorEnterNode) { monitorSnippets.lower((MonitorEnterNode) n, tool); } else if (n instanceof MonitorExitNode) { @@ -974,14 +974,8 @@ writeBarrierSnippets.lower((SerialWriteBarrier) n, tool); } else if (n instanceof SerialArrayRangeWriteBarrier) { writeBarrierSnippets.lower((SerialArrayRangeWriteBarrier) n, tool); - } else if (n instanceof TLABAllocateNode) { - newObjectSnippets.lower((TLABAllocateNode) n, tool); - } else if (n instanceof InitializeObjectNode) { - newObjectSnippets.lower((InitializeObjectNode) n, tool); - } else if (n instanceof InitializeArrayNode) { - newObjectSnippets.lower((InitializeArrayNode) n, tool); } else if (n instanceof NewMultiArrayNode) { - newObjectSnippets.lower((NewMultiArrayNode) n, tool); + newObjectSnippets.lower((NewMultiArrayNode) n); } else if (n instanceof LoadExceptionObjectNode) { exceptionObjectSnippets.lower((LoadExceptionObjectNode) n); } else if (n instanceof IntegerDivNode || n instanceof IntegerRemNode || n instanceof UnsignedDivNode || n instanceof UnsignedRemNode) { diff -r a7376cc486ff -r 0d0645267c32 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeArrayNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeArrayNode.java Tue May 14 14:48:38 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +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.hotspot.nodes; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.type.*; - -/** - * Initializes the header and body of an uninitialized array cell. This node calls out to a stub to - * do both the allocation and formatting if the memory address it is given is zero/null (e.g. due to - * {@linkplain TLABAllocateNode TLAB allocation} failing). - */ -public final class InitializeArrayNode extends FixedWithNextNode implements Lowerable, ArrayLengthProvider { - - @Input private final ValueNode memory; - @Input private final ValueNode length; - @Input private final ValueNode allocationSize; - private final ResolvedJavaType type; - private final boolean fillContents; - - public InitializeArrayNode(ValueNode memory, ValueNode length, ValueNode allocationSize, ResolvedJavaType type, boolean fillContents) { - super(StampFactory.exactNonNull(type)); - this.memory = memory; - this.type = type; - this.length = length; - this.allocationSize = allocationSize; - this.fillContents = fillContents; - } - - public ValueNode memory() { - return memory; - } - - @Override - public ValueNode length() { - return length; - } - - /** - * Gets the size (in bytes) of the memory chunk allocated for the array. - */ - public ValueNode allocationSize() { - return allocationSize; - } - - public ResolvedJavaType type() { - return type; - } - - public boolean fillContents() { - // We fill contents when G1 GC is used since we want to record - // the original field values prior to stores - return fillContents; - } - - @Override - public void lower(LoweringTool tool, LoweringType loweringType) { - tool.getRuntime().lower(this, tool); - } - - @NodeIntrinsic - public static native Object initialize(Object memory, int length, int allocationSize, @ConstantNodeParameter ResolvedJavaType type, @ConstantNodeParameter boolean fillContents); -} diff -r a7376cc486ff -r 0d0645267c32 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeObjectNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeObjectNode.java Tue May 14 14:48:38 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +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.hotspot.nodes; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.type.*; - -/** - * Initializes the header and body of an uninitialized object cell. This node calls out to a stub to - * do both the allocation and formatting if the memory address it is given is zero/null (e.g. due to - * {@linkplain TLABAllocateNode TLAB allocation} failing). - */ -public final class InitializeObjectNode extends FixedWithNextNode implements Lowerable { - - @Input private final ValueNode memory; - private final ResolvedJavaType type; - private final boolean fillContents; - - public InitializeObjectNode(ValueNode memory, ResolvedJavaType type, boolean fillContents) { - super(StampFactory.exactNonNull(type)); - this.memory = memory; - this.type = type; - this.fillContents = fillContents; - } - - public ValueNode memory() { - return memory; - } - - public ResolvedJavaType type() { - return type; - } - - public boolean fillContents() { - return fillContents; - } - - @Override - public void lower(LoweringTool tool, LoweringType loweringType) { - tool.getRuntime().lower(this, tool); - } -} diff -r a7376cc486ff -r 0d0645267c32 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 Tue May 14 14:48:38 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +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.hotspot.nodes; - -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.type.*; -import com.oracle.graal.word.*; - -/** - * Allocates some uninitialized area. This is used for TLAB allocation only. If allocation fails, - * zero/null is produced by this node. - */ -public final class TLABAllocateNode extends FixedWithNextNode implements Lowerable { - - @Input private ValueNode size; - - public TLABAllocateNode(ValueNode size) { - super(StampFactory.forWord()); - this.size = size; - } - - public ValueNode size() { - return size; - } - - @Override - public void lower(LoweringTool tool, LoweringType loweringType) { - tool.getRuntime().lower(this, tool); - } - - /** - * @return null if allocation fails - */ - @NodeIntrinsic - public static native Word allocateVariableSize(int size); -} diff -r a7376cc486ff -r 0d0645267c32 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Tue May 14 14:48:38 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Tue May 14 15:56:56 2013 +0200 @@ -72,54 +72,52 @@ } @Snippet - public static Object initializeObject(Word memory, Word hub, Word prototypeMarkWord, @ConstantParameter int size, @ConstantParameter boolean fillContents) { - + public static Object allocateInstance(@ConstantParameter int size, Word hub, Word prototypeMarkWord, @ConstantParameter boolean fillContents) { Object result; - if (probability(SLOW_PATH_PROBABILITY, memory.equal(0))) { + Word thread = thread(); + Word top = readTlabTop(thread); + Word end = readTlabEnd(thread); + Word newTop = top.add(size); + if (useTLAB() && probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) { + writeTlabTop(thread, newTop); + result = formatObject(hub, size, top, prototypeMarkWord, fillContents); + } else { new_stub.inc(); result = NewInstanceStubCall.call(hub); - } else { - formatObject(hub, size, memory, prototypeMarkWord, fillContents); - result = memory.toObject(); } - /* - * make sure that the unsafeCast is anchored after initialization, see ReadAfterCheckCast - * and CheckCastSnippets - */ BeginNode anchorNode = BeginNode.anchor(StampFactory.forNodeIntrinsic()); return unsafeCast(verifyOop(result), StampFactory.forNodeIntrinsic(), anchorNode); } - @Snippet - public static Object initializeArray(Word memory, Word hub, int length, int allocationSize, Word prototypeMarkWord, @ConstantParameter int headerSize, @ConstantParameter boolean fillContents) { - Object result; - if (probability(SLOW_PATH_PROBABILITY, memory.equal(0))) { - newarray_stub.inc(); - result = NewArrayStubCall.call(hub, length); - } else { - newarray_loopInit.inc(); - formatArray(hub, allocationSize, length, headerSize, memory, prototypeMarkWord, fillContents); - result = memory.toObject(); - } - BeginNode anchorNode = BeginNode.anchor(StampFactory.forNodeIntrinsic()); - return unsafeArrayCast(verifyOop(result), length, StampFactory.forNodeIntrinsic(), anchorNode); - } - /** * Maximum array length for which fast path allocation is used. */ public static final int MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH = 0x00FFFFFF; @Snippet - public static Object allocateArrayAndInitialize(int length, @ConstantParameter int alignment, @ConstantParameter int headerSize, @ConstantParameter int log2ElementSize, - @ConstantParameter boolean fillContents, @ConstantParameter ResolvedJavaType type) { + public static Object allocateArray(Word hub, int length, Word prototypeMarkWord, @ConstantParameter int headerSize, @ConstantParameter int log2ElementSize, @ConstantParameter boolean fillContents) { if (!belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) { // This handles both negative array sizes and very large array sizes DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint); } + + Object result; + int alignment = wordSize(); int allocationSize = computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize); - Word memory = TLABAllocateNode.allocateVariableSize(allocationSize); - return InitializeArrayNode.initialize(memory, length, allocationSize, type, fillContents); + Word thread = thread(); + Word top = readTlabTop(thread); + Word end = readTlabEnd(thread); + Word newTop = top.add(allocationSize); + if (useTLAB() && probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) { + writeTlabTop(thread, newTop); + newarray_loopInit.inc(); + result = formatArray(hub, allocationSize, length, headerSize, top, prototypeMarkWord, fillContents); + } else { + newarray_stub.inc(); + result = NewArrayStubCall.call(hub, length); + } + BeginNode anchorNode = BeginNode.anchor(StampFactory.forNodeIntrinsic()); + return unsafeArrayCast(verifyOop(result), length, StampFactory.forNodeIntrinsic(), anchorNode); } /** @@ -160,7 +158,7 @@ /** * Formats some allocated memory with an object header zeroes out the rest. */ - private static void formatObject(Word hub, int size, Word memory, Word compileTimePrototypeMarkWord, boolean fillContents) { + private static Object formatObject(Word hub, int size, Word memory, Word compileTimePrototypeMarkWord, boolean fillContents) { Word prototypeMarkWord = useBiasedLocking() ? hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION) : compileTimePrototypeMarkWord; initializeObjectHeader(memory, prototypeMarkWord, hub); if (fillContents) { @@ -177,12 +175,13 @@ } } } + return memory.toObject(); } /** - * Formats some allocated memory with an object header zeroes out the rest. + * Formats some allocated memory with an object header and zeroes out the rest. */ - public static void formatArray(Word hub, int allocationSize, int length, int headerSize, Word memory, Word prototypeMarkWord, boolean fillContents) { + public static Object formatArray(Word hub, int allocationSize, int length, int headerSize, Word memory, Word prototypeMarkWord, boolean fillContents) { memory.writeInt(arrayLengthOffset(), length, ANY_LOCATION); /* * store hub last as the concurrent garbage collectors assume length is valid if hub field @@ -194,151 +193,66 @@ memory.writeWord(offset, Word.zero(), ANY_LOCATION); } } + return memory.toObject(); } public static class Templates extends AbstractTemplates { - private final SnippetInfo allocate = snippet(NewObjectSnippets.class, "allocate"); - private final SnippetInfo initializeObject = snippet(NewObjectSnippets.class, "initializeObject"); - private final SnippetInfo initializeArray = snippet(NewObjectSnippets.class, "initializeArray"); - private final SnippetInfo allocateArrayAndInitialize = snippet(NewObjectSnippets.class, "allocateArrayAndInitialize"); + private final SnippetInfo allocateInstance = snippet(NewObjectSnippets.class, "allocateInstance"); + private final SnippetInfo allocateArray = snippet(NewObjectSnippets.class, "allocateArray"); private final SnippetInfo newmultiarray = snippet(NewObjectSnippets.class, "newmultiarray"); - private final boolean useTLAB; - - public Templates(CodeCacheProvider runtime, Replacements replacements, TargetDescription target, boolean useTLAB) { + public Templates(CodeCacheProvider runtime, Replacements replacements, TargetDescription target) { super(runtime, replacements, target); - this.useTLAB = useTLAB; } /** * Lowers a {@link NewInstanceNode}. */ - @SuppressWarnings("unused") - public void lower(NewInstanceNode newInstanceNode, LoweringTool tool) { + public void lower(NewInstanceNode newInstanceNode) { StructuredGraph graph = newInstanceNode.graph(); HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) newInstanceNode.instanceClass(); + assert !type.isArray(); ConstantNode hub = ConstantNode.forConstant(type.klass(), runtime, graph); int size = instanceSize(type); - ValueNode memory; - if (!useTLAB) { - memory = ConstantNode.defaultForKind(target.wordKind, graph); - } else { - ConstantNode sizeNode = ConstantNode.forInt(size, graph); - TLABAllocateNode tlabAllocateNode = graph.add(new TLABAllocateNode(sizeNode)); - graph.addBeforeFixed(newInstanceNode, tlabAllocateNode); - memory = tlabAllocateNode; - } - InitializeObjectNode initializeNode = graph.add(new InitializeObjectNode(memory, type, newInstanceNode.fillContents())); - graph.replaceFixedWithFixed(newInstanceNode, initializeNode); + Arguments args = new Arguments(allocateInstance); + args.addConst("size", size); + args.add("hub", hub); + args.add("prototypeMarkWord", type.prototypeMarkWord()); + args.addConst("fillContents", newInstanceNode.fillContents()); + + SnippetTemplate template = template(args); + Debug.log("Lowering allocateInstance in %s: node=%s, template=%s, arguments=%s", graph, newInstanceNode, template, args); + template.instantiate(runtime, newInstanceNode, DEFAULT_REPLACER, args); } /** * Lowers a {@link NewArrayNode}. */ - @SuppressWarnings("unused") - public void lower(NewArrayNode newArrayNode, LoweringTool tool) { + public void lower(NewArrayNode newArrayNode) { StructuredGraph graph = newArrayNode.graph(); - ValueNode lengthNode = newArrayNode.length(); - TLABAllocateNode tlabAllocateNode; ResolvedJavaType elementType = newArrayNode.elementType(); - ResolvedJavaType arrayType = elementType.getArrayClass(); + HotSpotResolvedObjectType arrayType = (HotSpotResolvedObjectType) elementType.getArrayClass(); Kind elementKind = elementType.getKind(); - final int alignment = target.wordSize; + ConstantNode hub = ConstantNode.forConstant(arrayType.klass(), runtime, graph); final int headerSize = HotSpotRuntime.getArrayBaseOffset(elementKind); - final Integer length = lengthNode.isConstant() ? Integer.valueOf(lengthNode.asConstant().asInt()) : null; int log2ElementSize = CodeUtil.log2(target.arch.getSizeInBytes(elementKind)); - if (!useTLAB) { - ConstantNode zero = ConstantNode.defaultForKind(target.wordKind, graph); - /* - * value for 'size' doesn't matter as it isn't used since a stub call will be made - * anyway for both allocation and initialization - it just needs to be non-null - */ - ConstantNode size = ConstantNode.forInt(-1, graph); - InitializeArrayNode initializeNode = graph.add(new InitializeArrayNode(zero, lengthNode, size, arrayType, newArrayNode.fillContents())); - graph.replaceFixedWithFixed(newArrayNode, initializeNode); - } else if (length != null && belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) { - // Calculate aligned size - int size = computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize); - ConstantNode sizeNode = ConstantNode.forInt(size, graph); - tlabAllocateNode = graph.add(new TLABAllocateNode(sizeNode)); - graph.addBeforeFixed(newArrayNode, tlabAllocateNode); - InitializeArrayNode initializeNode = graph.add(new InitializeArrayNode(tlabAllocateNode, lengthNode, sizeNode, arrayType, newArrayNode.fillContents())); - graph.replaceFixedWithFixed(newArrayNode, initializeNode); - } else { - Arguments args = new Arguments(allocateArrayAndInitialize); - args.add("length", lengthNode); - args.addConst("alignment", alignment); - args.addConst("headerSize", headerSize); - args.addConst("log2ElementSize", log2ElementSize); - args.addConst("fillContents", newArrayNode.fillContents()); - args.addConst("type", arrayType); - SnippetTemplate template = template(args); - Debug.log("Lowering allocateArrayAndInitialize in %s: node=%s, template=%s, arguments=%s", graph, newArrayNode, template, args); - template.instantiate(runtime, newArrayNode, DEFAULT_REPLACER, args); - } - } - - @SuppressWarnings("unused") - public void lower(TLABAllocateNode tlabAllocateNode, LoweringTool tool) { - StructuredGraph graph = tlabAllocateNode.graph(); - ValueNode size = tlabAllocateNode.size(); - Arguments args = new Arguments(allocate).add("size", size); + Arguments args = new Arguments(allocateArray); + args.add("hub", hub); + args.add("length", newArrayNode.length()); + args.add("prototypeMarkWord", arrayType.prototypeMarkWord()); + args.addConst("headerSize", headerSize); + args.addConst("log2ElementSize", log2ElementSize); + args.addConst("fillContents", newArrayNode.fillContents()); SnippetTemplate template = template(args); - Debug.log("Lowering fastAllocate in %s: node=%s, template=%s, arguments=%s", graph, tlabAllocateNode, template, args); - template.instantiate(runtime, tlabAllocateNode, DEFAULT_REPLACER, args); - } - - @SuppressWarnings("unused") - public void lower(InitializeObjectNode initializeNode, LoweringTool tool) { - StructuredGraph graph = initializeNode.graph(); - HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) initializeNode.type(); - assert !type.isArray(); - ConstantNode hub = ConstantNode.forConstant(type.klass(), runtime, graph); - int size = instanceSize(type); - ValueNode memory = initializeNode.memory(); - - Arguments args = new Arguments(initializeObject); - args.add("memory", memory); - args.add("hub", hub); - args.add("prototypeMarkWord", type.prototypeMarkWord()); - args.addConst("size", size).addConst("fillContents", initializeNode.fillContents()); - - SnippetTemplate template = template(args); - Debug.log("Lowering initializeObject in %s: node=%s, template=%s, arguments=%s", graph, initializeNode, template, args); - template.instantiate(runtime, initializeNode, DEFAULT_REPLACER, args); + Debug.log("Lowering allocateArray in %s: node=%s, template=%s, arguments=%s", graph, newArrayNode, template, args); + template.instantiate(runtime, newArrayNode, DEFAULT_REPLACER, args); } - @SuppressWarnings("unused") - public void lower(InitializeArrayNode initializeNode, LoweringTool tool) { - StructuredGraph graph = initializeNode.graph(); - HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) initializeNode.type(); - ResolvedJavaType elementType = type.getComponentType(); - assert elementType != null; - ConstantNode hub = ConstantNode.forConstant(type.klass(), runtime, graph); - Kind elementKind = elementType.getKind(); - final int headerSize = HotSpotRuntime.getArrayBaseOffset(elementKind); - ValueNode memory = initializeNode.memory(); - - Arguments args = new Arguments(initializeArray); - args.add("memory", memory); - args.add("hub", hub); - args.add("length", initializeNode.length()); - args.add("allocationSize", initializeNode.allocationSize()); - args.add("prototypeMarkWord", type.prototypeMarkWord()); - args.addConst("headerSize", headerSize); - args.addConst("fillContents", initializeNode.fillContents()); - - SnippetTemplate template = template(args); - Debug.log("Lowering initializeArray in %s: node=%s, template=%s, arguments=%s", graph, initializeNode, template, args); - template.instantiate(runtime, initializeNode, DEFAULT_REPLACER, args); - } - - @SuppressWarnings("unused") - public void lower(NewMultiArrayNode newmultiarrayNode, LoweringTool tool) { + public void lower(NewMultiArrayNode newmultiarrayNode) { StructuredGraph graph = newmultiarrayNode.graph(); int rank = newmultiarrayNode.dimensionCount(); ValueNode[] dims = new ValueNode[rank]; diff -r a7376cc486ff -r 0d0645267c32 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneSnippets.java Tue May 14 14:48:38 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneSnippets.java Tue May 14 15:56:56 2013 +0200 @@ -52,11 +52,10 @@ private static Object instanceClone(Object src, Word hub, int layoutHelper) { int instanceSize = layoutHelper; - Pointer memory = NewObjectSnippets.allocate(instanceSize); Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION); - Object result = NewObjectSnippets.initializeObject((Word) memory, hub, prototypeMarkWord, instanceSize, false); + Object result = NewObjectSnippets.allocateInstance(instanceSize, hub, prototypeMarkWord, false); - memory = Word.fromObject(result); + Pointer memory = Word.fromObject(result); for (int offset = 2 * wordSize(); offset < instanceSize; offset += wordSize()) { memory.writeWord(offset, Word.fromObject(src).readWord(offset, ANY_LOCATION), ANY_LOCATION); } @@ -70,11 +69,10 @@ int headerSize = (layoutHelper >> layoutHelperHeaderSizeShift()) & layoutHelperHeaderSizeMask(); int sizeInBytes = NewObjectSnippets.computeArrayAllocationSize(arrayLength, wordSize(), headerSize, log2ElementSize); - Pointer memory = NewObjectSnippets.allocate(sizeInBytes); Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION); - Object result = NewObjectSnippets.initializeArray((Word) memory, hub, arrayLength, sizeInBytes, prototypeMarkWord, headerSize, false); + Object result = NewObjectSnippets.allocateArray(hub, arrayLength, prototypeMarkWord, headerSize, log2ElementSize, false); - memory = Word.fromObject(result); + Pointer memory = Word.fromObject(result); for (int offset = headerSize; offset < sizeInBytes; offset += wordSize()) { memory.writeWord(offset, Word.fromObject(src).readWord(offset, ANY_LOCATION), ANY_LOCATION); } diff -r a7376cc486ff -r 0d0645267c32 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java Tue May 14 14:48:38 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java Tue May 14 15:56:56 2013 +0200 @@ -108,8 +108,7 @@ if (logging()) { printf("newArray: allocated new array at %p\n", memory.rawValue()); } - formatArray(hub, sizeInBytes, length, headerSize, memory, Word.unsigned(arrayPrototypeMarkWord()), true); - return verifyObject(memory.toObject()); + return verifyObject(formatArray(hub, sizeInBytes, length, headerSize, memory, Word.unsigned(arrayPrototypeMarkWord()), true)); } } if (logging()) {