diff graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java @ 2812:d27bdbec3d67

Removed ArrayLength from CFG. Fixed an issue when scheduling Merge instructions within a block. If a block only consists of a single Merge instruction, we have to schedule this instruction as the first instruction.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Mon, 30 May 2011 15:24:26 +0200
parents c3f64b66fc78
children bd17ac598c6e
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java	Mon May 30 15:03:04 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java	Mon May 30 15:24:26 2011 +0200
@@ -31,10 +31,33 @@
 /**
  * The {@code ArrayLength} instruction gets the length of an array.
  */
-public final class ArrayLength extends AccessArray {
+public final class ArrayLength extends Value {
+
+    private static final int INPUT_COUNT = 1;
+    private static final int INPUT_ARRAY = 0;
+
+    private static final int SUCCESSOR_COUNT = 0;
+
+    @Override
+    protected int inputCount() {
+        return super.inputCount() + INPUT_COUNT;
+    }
 
-    private static final int INPUT_COUNT = 0;
-    private static final int SUCCESSOR_COUNT = 0;
+    @Override
+    protected int successorCount() {
+        return super.successorCount() + SUCCESSOR_COUNT;
+    }
+
+    /**
+     * The instruction that produces the array object.
+     */
+     public Value array() {
+        return (Value) inputs().get(super.inputCount() + INPUT_ARRAY);
+    }
+
+    public Value setArray(Value n) {
+        return (Value) inputs().set(super.inputCount() + INPUT_ARRAY, n);
+    }
 
     /**
      * Constructs a new ArrayLength instruction.
@@ -42,7 +65,8 @@
      * @param newFrameState the state after executing this instruction
      */
     public ArrayLength(Value array, Graph graph) {
-        super(CiKind.Int, array, INPUT_COUNT, SUCCESSOR_COUNT, graph);
+        super(CiKind.Int, INPUT_COUNT, SUCCESSOR_COUNT, graph);
+        setArray(array);
     }
 
     @Override