diff graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewArrayNode.java @ 10589:17c5cc84560b

Factor out common code of NewArrayNode and DynamicNewArrayNode.
author Roland Schatz <roland.schatz@oracle.com>
date Tue, 02 Jul 2013 10:17:35 +0200
parents f7ec3ec8a03c
children c6ab6ae1b360
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewArrayNode.java	Mon Jul 01 15:46:27 2013 -0400
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewArrayNode.java	Tue Jul 02 10:17:35 2013 +0200
@@ -23,25 +23,18 @@
 package com.oracle.graal.nodes.java;
 
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.nodes.virtual.*;
 
 /**
- * The {@code NewArrayNode} is used for all 1-dimensional array allocations.
+ * The {@code NewArrayNode} is used for all array allocations where the element type is know at
+ * compile time.
  */
-public class NewArrayNode extends FixedWithNextNode implements Canonicalizable, Lowerable, VirtualizableAllocation, ArrayLengthProvider, Node.IterableNodeType {
+public class NewArrayNode extends AbstractNewArrayNode implements VirtualizableAllocation {
 
-    @Input private ValueNode length;
     private final ResolvedJavaType elementType;
-    private final boolean fillContents;
-
-    @Override
-    public ValueNode length() {
-        return length;
-    }
 
     /**
      * Constructs a new NewArrayNode.
@@ -52,25 +45,8 @@
      * @param fillContents determines whether the array elements should be initialized to zero/null.
      */
     public NewArrayNode(ResolvedJavaType elementType, ValueNode length, boolean fillContents) {
-        super(StampFactory.exactNonNull(elementType.getArrayClass()));
-        this.length = length;
+        super(StampFactory.exactNonNull(elementType.getArrayClass()), length, fillContents);
         this.elementType = elementType;
-        this.fillContents = fillContents;
-    }
-
-    /**
-     * @return <code>true</code> if the elements of the array will be initialized.
-     */
-    public boolean fillContents() {
-        return fillContents;
-    }
-
-    /**
-     * The list of node which produce input for this instruction.
-     */
-    public ValueNode dimension(int index) {
-        assert index == 0;
-        return length();
     }
 
     /**
@@ -82,27 +58,6 @@
         return elementType;
     }
 
-    /**
-     * The rank of the array allocated by this node, i.e. how many array dimensions.
-     */
-    public int dimensionCount() {
-        return 1;
-    }
-
-    @Override
-    public ValueNode canonical(CanonicalizerTool tool) {
-        if (usages().isEmpty() && length.integerStamp().isPositive()) {
-            return null;
-        } else {
-            return this;
-        }
-    }
-
-    @Override
-    public void lower(LoweringTool tool, LoweringType loweringType) {
-        tool.getRuntime().lower(this, tool);
-    }
-
     @Override
     public void virtualize(VirtualizerTool tool) {
         if (length().asConstant() != null) {