changeset 2594:092e628ddd5d

changed Constant and Convert, more StoreIndexed changes
author Lukas Stadler <lukas.stadler@jku.at>
date Thu, 05 May 2011 15:43:23 +0200
parents 25c278ab287c
children 4a4dab936c1e
files graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java graal/GraalCompiler/src/com/sun/c1x/ir/AccessArray.java graal/GraalCompiler/src/com/sun/c1x/ir/Constant.java graal/GraalCompiler/src/com/sun/c1x/ir/Convert.java graal/GraalCompiler/src/com/sun/c1x/ir/IfOp.java graal/GraalCompiler/src/com/sun/c1x/ir/LoadIndexed.java graal/GraalCompiler/src/com/sun/c1x/ir/LogicOp.java graal/GraalCompiler/src/com/sun/c1x/ir/Op2.java graal/GraalCompiler/src/com/sun/c1x/ir/ShiftOp.java graal/GraalCompiler/src/com/sun/c1x/ir/StateSplit.java graal/GraalCompiler/src/com/sun/c1x/ir/StoreIndexed.java runscimark.sh
diffstat 12 files changed, 93 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Thu May 05 15:23:27 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Thu May 05 15:43:23 2011 +0200
@@ -425,7 +425,7 @@
             if (!riType.isResolved() || C1XOptions.TestPatching) {
                 push(CiKind.Object, append(new ResolveClass(riType, RiType.Representation.JavaClass, null)));
             } else {
-                push(CiKind.Object, append(new Constant(riType.getEncoding(Representation.JavaClass))));
+                push(CiKind.Object, append(new Constant(riType.getEncoding(Representation.JavaClass), graph)));
             }
         } else if (con instanceof CiConstant) {
             CiConstant constant = (CiConstant) con;
@@ -587,14 +587,14 @@
 
     void genConvert(int opcode, CiKind from, CiKind to) {
         CiKind tt = to.stackKind();
-        push(tt, append(new Convert(opcode, pop(from.stackKind()), tt)));
+        push(tt, append(new Convert(opcode, pop(from.stackKind()), tt, graph)));
     }
 
     void genIncrement() {
         int index = stream().readLocalIndex();
         int delta = stream().readIncrement();
         Value x = curState.localAt(index);
-        Value y = append(Constant.forInt(delta));
+        Value y = append(Constant.forInt(delta, graph));
         curState.storeLocal(index, append(new ArithmeticOp(IADD, CiKind.Int, x, y, isStrict(method().accessFlags()), null, graph)));
     }
 
@@ -1139,7 +1139,7 @@
     }
 
     private Value appendConstant(CiConstant type) {
-        return appendWithBCI(new Constant(type), bci());
+        return appendWithBCI(new Constant(type, graph), bci());
     }
 
     private Value append(Instruction x) {
@@ -1242,7 +1242,7 @@
 
     private Value synchronizedObject(FrameState curState2, RiMethod target) {
         if (isStatic(target.accessFlags())) {
-            Constant classConstant = new Constant(target.holder().getEncoding(Representation.JavaClass));
+            Constant classConstant = new Constant(target.holder().getEncoding(Representation.JavaClass), graph);
             return appendWithoutOptimization(classConstant, Instruction.SYNCHRONIZATION_ENTRY_BCI);
         } else {
             return curState2.localAt(0);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/AccessArray.java	Thu May 05 15:23:27 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/AccessArray.java	Thu May 05 15:43:23 2011 +0200
@@ -28,8 +28,6 @@
 
 /**
  * This the base class of all array operations.
- *
- * @author Ben L. Titzer
  */
 public abstract class AccessArray extends StateSplit {
 
@@ -59,7 +57,6 @@
         return (Value) inputs().set(super.inputCount() + INPUT_ARRAY, n);
     }
 
-
     /**
      * Creates a new AccessArray instruction.
      * @param kind the type of the result of this instruction
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Constant.java	Thu May 05 15:23:27 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Constant.java	Thu May 05 15:43:23 2011 +0200
@@ -24,6 +24,7 @@
 
 import static com.sun.c1x.C1XCompilation.*;
 
+import com.oracle.graal.graph.*;
 import com.sun.c1x.debug.*;
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
@@ -36,14 +37,18 @@
  */
 public final class Constant extends Instruction {
 
+    private static final int INPUT_COUNT = 0;
+    private static final int SUCCESSOR_COUNT = 0;
+
     public final CiConstant value;
 
     /**
      * Constructs a new instruction representing the specified constant.
      * @param value the constant
+     * @param graph
      */
-    public Constant(CiConstant value) {
-        super(value.kind.stackKind());
+    public Constant(CiConstant value, Graph graph) {
+        super(value.kind.stackKind(), INPUT_COUNT, SUCCESSOR_COUNT, graph);
         this.value = value;
         initFlag(Value.Flag.NonNull, value.isNonNull());
     }
@@ -56,10 +61,11 @@
     /**
      * Creates an instruction for a double constant.
      * @param d the double value for which to create the instruction
+     * @param graph
      * @return an instruction representing the double
      */
-    public static Constant forDouble(double d) {
-        return new Constant(CiConstant.forDouble(d));
+    public static Constant forDouble(double d, Graph graph) {
+        return new Constant(CiConstant.forDouble(d), graph);
     }
 
     /**
@@ -67,8 +73,8 @@
      * @param f the float value for which to create the instruction
      * @return an instruction representing the float
      */
-    public static Constant forFloat(float f) {
-        return new Constant(CiConstant.forFloat(f));
+    public static Constant forFloat(float f, Graph graph) {
+        return new Constant(CiConstant.forFloat(f), graph);
     }
 
     /**
@@ -76,8 +82,8 @@
      * @param i the long value for which to create the instruction
      * @return an instruction representing the long
      */
-    public static Constant forLong(long i) {
-        return new Constant(CiConstant.forLong(i));
+    public static Constant forLong(long i, Graph graph) {
+        return new Constant(CiConstant.forLong(i), graph);
     }
 
     /**
@@ -85,8 +91,8 @@
      * @param i the integer value for which to create the instruction
      * @return an instruction representing the integer
      */
-    public static Constant forInt(int i) {
-        return new Constant(CiConstant.forInt(i));
+    public static Constant forInt(int i, Graph graph) {
+        return new Constant(CiConstant.forInt(i), graph);
     }
 
     /**
@@ -94,8 +100,8 @@
      * @param i the boolean value for which to create the instruction
      * @return an instruction representing the boolean
      */
-    public static Constant forBoolean(boolean i) {
-        return new Constant(CiConstant.forBoolean(i));
+    public static Constant forBoolean(boolean i, Graph graph) {
+        return new Constant(CiConstant.forBoolean(i), graph);
     }
 
     /**
@@ -103,8 +109,8 @@
      * @param i the address value for which to create the instruction
      * @return an instruction representing the address
      */
-    public static Constant forJsr(int i) {
-        return new Constant(CiConstant.forJsr(i));
+    public static Constant forJsr(int i, Graph graph) {
+        return new Constant(CiConstant.forJsr(i), graph);
     }
 
     /**
@@ -112,8 +118,8 @@
      * @param o the object value for which to create the instruction
      * @return an instruction representing the object
      */
-    public static Constant forObject(Object o) {
-        return new Constant(CiConstant.forObject(o));
+    public static Constant forObject(Object o, Graph graph) {
+        return new Constant(CiConstant.forObject(o), graph);
     }
 
     /**
@@ -121,8 +127,8 @@
      * @param val the word value for which to create the instruction
      * @return an instruction representing the word
      */
-    public static Constant forWord(long val) {
-        return new Constant(CiConstant.forWord(val));
+    public static Constant forWord(long val, Graph graph) {
+        return new Constant(CiConstant.forWord(val), graph);
     }
 
     @Override
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Convert.java	Thu May 05 15:23:27 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Convert.java	Thu May 05 15:43:23 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.cri.bytecode.*;
@@ -29,41 +30,51 @@
 
 /**
  * The {@code Convert} class represents a conversion between primitive types.
- *
- * @author Ben L. Titzer
  */
 public final class Convert extends Instruction {
 
+    private static final int INPUT_COUNT = 1;
+    private static final int INPUT_VALUE = 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 which produces the input value to this instruction.
+     */
+     public Value value() {
+        return (Value) inputs().get(super.inputCount() + INPUT_VALUE);
+    }
+
+    public Value setValue(Value n) {
+        return (Value) inputs().set(super.inputCount() + INPUT_VALUE, n);
+    }
+
     /**
      * The opcode for this conversion operation.
      */
     public final int opcode;
 
-    Value value;
-
     /**
      * Constructs a new Convert instance.
      * @param opcode the bytecode representing the operation
      * @param value the instruction producing the input value
      * @param kind the result type of this instruction
+     * @param graph
      */
-    public Convert(int opcode, Value value, CiKind kind) {
-        super(kind);
+    public Convert(int opcode, Value value, CiKind kind, Graph graph) {
+        super(kind, INPUT_COUNT, SUCCESSOR_COUNT, graph);
         this.opcode = opcode;
-        this.value = value;
-    }
-
-    /**
-     * Gets the instruction which produces the input value to this instruction.
-     * @return the input value instruction
-     */
-    public Value value() {
-        return value;
-    }
-
-    @Override
-    public void inputValuesDo(ValueClosure closure) {
-        value = closure.apply(value);
+        setValue(value);
     }
 
     @Override
@@ -73,14 +84,14 @@
 
     @Override
     public int valueNumber() {
-        return Util.hash1(opcode, value);
+        return Util.hash1(opcode, value());
     }
 
     @Override
     public boolean valueEqual(Instruction i) {
         if (i instanceof Convert) {
             Convert o = (Convert) i;
-            return opcode == o.opcode && value == o.value;
+            return opcode == o.opcode && value() == o.value();
         }
         return false;
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/IfOp.java	Thu May 05 15:23:27 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/IfOp.java	Thu May 05 15:43:23 2011 +0200
@@ -31,8 +31,6 @@
  * The {@code IfOp} class represents a comparison that yields one of two values.
  * Note that these nodes are not built directly from the bytecode but are introduced
  * by conditional expression elimination.
- *
- * @author Ben L. Titzer
  */
 public final class IfOp extends Op2 {
 
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/LoadIndexed.java	Thu May 05 15:23:27 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/LoadIndexed.java	Thu May 05 15:43:23 2011 +0200
@@ -30,8 +30,6 @@
 
 /**
  * The {@code LoadIndexed} instruction represents a read from an element of an array.
- *
- * @author Ben L. Titzer
  */
 public final class LoadIndexed extends AccessIndexed {
 
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/LogicOp.java	Thu May 05 15:23:27 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/LogicOp.java	Thu May 05 15:43:23 2011 +0200
@@ -28,8 +28,6 @@
 
 /**
  * The {@code LogicOp} class definition.
- *
- * @author Ben L. Titzer
  */
 public final class LogicOp extends Op2 {
 
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Op2.java	Thu May 05 15:23:27 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Op2.java	Thu May 05 15:43:23 2011 +0200
@@ -29,8 +29,6 @@
 
 /**
  * The {@code Op2} class is the base of arithmetic and logic operations with two inputs.
- *
- * @author Ben L. Titzer
  */
 public abstract class Op2 extends Instruction {
 
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/ShiftOp.java	Thu May 05 15:23:27 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ShiftOp.java	Thu May 05 15:43:23 2011 +0200
@@ -28,8 +28,6 @@
 
 /**
  * The {@code ShiftOp} class represents shift operations.
- *
- * @author Ben L. Titzer
  */
 public final class ShiftOp extends Op2 {
 
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/StateSplit.java	Thu May 05 15:23:27 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/StateSplit.java	Thu May 05 15:43:23 2011 +0200
@@ -29,11 +29,12 @@
 /**
  * The {@code StateSplit} class is the abstract base class of all instructions
  * that store an immutable copy of the frame state.
- *
- * @author Ben L. Titzer
  */
 public abstract class StateSplit extends Instruction {
 
+    private static final int INPUT_COUNT = 0;
+    private static final int SUCCESSOR_COUNT = 0;
+
     /**
      * Sentinel denoting an explicitly cleared state.
      */
@@ -49,7 +50,7 @@
      * @param graph
      */
     public StateSplit(CiKind kind, FrameState stateBefore, int inputCount, int successorCount, Graph graph) {
-        super(kind, inputCount, successorCount, graph);
+        super(kind, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph);
         this.stateBefore = stateBefore;
     }
 
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/StoreIndexed.java	Thu May 05 15:23:27 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/StoreIndexed.java	Thu May 05 15:43:23 2011 +0200
@@ -29,18 +29,34 @@
 
 /**
  * The {@code StoreIndexed} instruction represents a write to an array element.
- *
- * @author Ben L. Titzer
  */
 public final class StoreIndexed extends AccessIndexed {
 
-    private static final int INPUT_COUNT = 0;
+    private static final int INPUT_COUNT = 1;
+    private static final int INPUT_VALUE = 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 value to store.
+     * The instruction that produces the value that is to be stored into the array.
      */
-    Value value;
+     public Value value() {
+        return (Value) inputs().get(super.inputCount() + INPUT_VALUE);
+    }
+
+    public Value setValue(Value n) {
+        return (Value) inputs().set(super.inputCount() + INPUT_VALUE, n);
+    }
 
     /**
      * Creates a new StoreIndexed instruction.
@@ -54,21 +70,7 @@
      */
     public StoreIndexed(Value array, Value index, Value length, CiKind elementType, Value value, FrameState stateBefore, Graph graph) {
         super(CiKind.Void, array, index, length, elementType, stateBefore, INPUT_COUNT, SUCCESSOR_COUNT, graph);
-        this.value = value;
-    }
-
-    /**
-     * Gets the instruction that produces the value that is to be stored into the array.
-     * @return the value to write into the array
-     */
-    public Value value() {
-        return value;
-    }
-
-    @Override
-    public void inputValuesDo(ValueClosure closure) {
-        super.inputValuesDo(closure);
-        value = closure.apply(value);
+        setValue(value);
     }
 
     @Override
--- a/runscimark.sh	Thu May 05 15:23:27 2011 +0200
+++ b/runscimark.sh	Thu May 05 15:43:23 2011 +0200
@@ -15,7 +15,11 @@
   echo "SCIMARK is not defined. It must point to a SciMark benchmark directory."
   exit 1;
 fi
-for (( i = 1; i <= 5000; i++ ))      ### Outer for loop ###
+COUNT=$1
+if [ -z "${COUNT}" ]; then
+  COUNT=5000
+fi
+for (( i = 1; i <= ${COUNT}; i++ ))      ### Outer for loop ###
 do
   echo "$i "
   ${JDK7}/jre/bin/java -client -graal -esa -ea -Xms32m -Xmx100m -Xbootclasspath/a:${SCIMARK} -C1X:+PrintTimers  jnt.scimark2.commandline -large