# HG changeset patch # User Doug Simon # Date 1341922300 -7200 # Node ID 013081f7771bf6228266a6e3754e80634c78b28d # Parent b77a8c06b47767fa97ec7a0300592dfd101e708a consolidated 2 separate size fields in TLABAllocate into 1 diff -r b77a8c06b477 -r 013081f7771b 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 Jul 10 13:27:39 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TLABAllocateNode.java Tue Jul 10 14:11:40 2012 +0200 @@ -22,8 +22,6 @@ */ package com.oracle.graal.hotspot.nodes; -import java.util.*; - import com.oracle.graal.api.meta.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; @@ -36,62 +34,31 @@ */ public final class TLABAllocateNode extends FixedWithNextNode implements Lowerable { - private final int size; - @Input private ValueNode sizeNode; + @Input private ValueNode size; - public TLABAllocateNode(int size, Kind wordKind) { + public TLABAllocateNode(ValueNode size, Kind wordKind) { super(StampFactory.forWord(wordKind, true)); this.size = size; - this.sizeNode = null; } - public TLABAllocateNode(Kind wordKind, ValueNode size) { - super(StampFactory.forWord(wordKind, true)); - this.size = -1; - this.sizeNode = size; - } - - public boolean isSizeConstant() { - return sizeNode == null; - } - - public int constantSize() { - assert isSizeConstant(); + public ValueNode size() { return size; } - public ValueNode variableSize() { - assert !isSizeConstant(); - return sizeNode; - } - @Override public void lower(LoweringTool tool) { tool.getRuntime().lower(this, tool); } - @Override - public Map getDebugProperties() { - Map debugProperties = super.getDebugProperties(); - debugProperties.put("size", String.valueOf(size)); - return debugProperties; - } - + /** + * @return null if allocation fails + */ /** * @return null if allocation fails */ @SuppressWarnings("unused") @NodeIntrinsic - public static Word allocateConstantSize(@ConstantNodeParameter int size, @ConstantNodeParameter Kind wordKind) { - throw new UnsupportedOperationException(); - } - - /** - * @return null if allocation fails - */ - @SuppressWarnings("unused") - @NodeIntrinsic - public static Word allocateVariableSize(@ConstantNodeParameter Kind wordKind, int size) { + public static Word allocateVariableSize(int size, @ConstantNodeParameter Kind wordKind) { throw new UnsupportedOperationException(); } } diff -r b77a8c06b477 -r 013081f7771b 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 Tue Jul 10 13:27:39 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java Tue Jul 10 14:11:40 2012 +0200 @@ -143,7 +143,7 @@ DeoptimizeNode.deopt(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.RuntimeConstraint); } int size = getArraySize(length, alignment, headerSize, log2ElementSize); - Word memory = TLABAllocateNode.allocateVariableSize(wordKind, size); + Word memory = TLABAllocateNode.allocateVariableSize(size, wordKind); return InitializeArrayNode.initialize(memory, length, size, type); } @@ -252,7 +252,8 @@ if (!useTLAB) { memory = ConstantNode.forConstant(new Constant(target.wordKind, 0L), runtime, graph); } else { - TLABAllocateNode tlabAllocateNode = graph.add(new TLABAllocateNode(size, wordKind())); + ConstantNode sizeNode = ConstantNode.forInt(size, graph); + TLABAllocateNode tlabAllocateNode = graph.add(new TLABAllocateNode(sizeNode, wordKind())); graph.addBeforeFixed(newInstanceNode, tlabAllocateNode); memory = tlabAllocateNode; } @@ -286,7 +287,7 @@ // Calculate aligned size int size = getArraySize(length, alignment, headerSize, log2ElementSize); ConstantNode sizeNode = ConstantNode.forInt(size, graph); - tlabAllocateNode = graph.add(new TLABAllocateNode(size, target.wordKind)); + tlabAllocateNode = graph.add(new TLABAllocateNode(sizeNode, target.wordKind)); graph.addBeforeFixed(newArrayNode, tlabAllocateNode); InitializeArrayNode initializeNode = graph.add(new InitializeArrayNode(tlabAllocateNode, lengthNode, sizeNode, arrayType)); graph.replaceFixedWithFixed(newArrayNode, initializeNode); @@ -307,12 +308,7 @@ @SuppressWarnings("unused") public void lower(TLABAllocateNode tlabAllocateNode, LoweringTool tool) { StructuredGraph graph = (StructuredGraph) tlabAllocateNode.graph(); - ValueNode size; - if (tlabAllocateNode.isSizeConstant()) { - size = ConstantNode.forInt(tlabAllocateNode.constantSize(), graph); - } else { - size = tlabAllocateNode.variableSize(); - } + ValueNode size = tlabAllocateNode.size(); Key key = new Key(allocate); Arguments arguments = arguments("size", size); SnippetTemplate template = cache.get(key);