changeset 5805:013081f7771b

consolidated 2 separate size fields in TLABAllocate into 1
author Doug Simon <doug.simon@oracle.com>
date Tue, 10 Jul 2012 14:11:40 +0200
parents b77a8c06b477
children b3d3a2fcba3d
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TLABAllocateNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java
diffstat 2 files changed, 12 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- 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<Object, Object> getDebugProperties() {
-        Map<Object, Object> 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();
     }
 }
--- 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);