diff graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java @ 2600:f1bc67c2d453

new node layout: TypeCheck, RegisterFinalizer, Invoke, NewArray, NullCheck
author Lukas Stadler <lukas.stadler@jku.at>
date Thu, 05 May 2011 16:32:20 +0200
parents c58a301eb2d7
children 91d3952f7eb7
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java	Thu May 05 16:07:00 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java	Thu May 05 16:32:20 2011 +0200
@@ -22,6 +22,7 @@
  */
 package com.sun.c1x.ir;
 
+import com.oracle.graal.graph.*;
 import com.sun.c1x.debug.*;
 import com.sun.c1x.util.*;
 import com.sun.c1x.value.*;
@@ -33,30 +34,42 @@
  */
 public final class NullCheck extends StateSplit {
 
-    Value object;
+    private static final int INPUT_COUNT = 1;
+    private static final int INPUT_OBJECT = 0;
+
+    private static final int SUCCESSOR_COUNT = 0;
+
+    @Override
+    protected int inputCount() {
+        return super.inputCount() + INPUT_COUNT;
+    }
+
+    @Override
+    protected int successorCount() {
+        return super.successorCount() + SUCCESSOR_COUNT;
+    }
+
+    /**
+     * The instruction that produces the object tested against null.
+     */
+     public Value object() {
+        return (Value) inputs().get(super.inputCount() + INPUT_OBJECT);
+    }
+
+    public Value setObject(Value n) {
+        return (Value) inputs().set(super.inputCount() + INPUT_OBJECT, n);
+    }
 
     /**
      * Constructs a new NullCheck instruction.
-     * @param obj the instruction producing the object to check against null
+     * @param object the instruction producing the object to check against null
      * @param stateBefore the state before executing the null check
+     * @param graph
      */
-    public NullCheck(Value obj, FrameState stateBefore) {
-        super(obj.kind, stateBefore);
-        this.object = obj;
+    public NullCheck(Value object, FrameState stateBefore, Graph graph) {
+        super(object.kind, stateBefore, INPUT_COUNT, SUCCESSOR_COUNT, graph);
         setFlag(Flag.NonNull);
-    }
-
-    /**
-     * Gets the instruction that produces the object tested against null.
-     * @return the instruction producing the object
-     */
-    public Value object() {
-        return object;
-    }
-
-    @Override
-    public void inputValuesDo(ValueClosure closure) {
-        object = closure.apply(object);
+        setObject(object);
     }
 
     @Override
@@ -66,14 +79,14 @@
 
     @Override
     public int valueNumber() {
-        return Util.hash1(Bytecodes.IFNONNULL, object);
+        return Util.hash1(Bytecodes.IFNONNULL, object());
     }
 
     @Override
     public boolean valueEqual(Instruction i) {
         if (i instanceof NullCheck) {
             NullCheck o = (NullCheck) i;
-            return object == o.object;
+            return object() == o.object();
         }
         return false;
     }
@@ -81,13 +94,13 @@
     @Override
     public RiType declaredType() {
         // null check does not alter the type of the object
-        return object.declaredType();
+        return object().declaredType();
     }
 
     @Override
     public RiType exactType() {
         // null check does not alter the type of the object
-        return object.exactType();
+        return object().exactType();
     }
 
     @Override