changeset 2538:e1ba5a93e997

Clean up on Value class and LIRGenerator/LIRItem-related things.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Apr 2011 20:13:54 +0200
parents 4a016ff4d2df
children fa3bda50cbfd
files graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java graal/GraalCompiler/src/com/sun/c1x/ir/BlockEnd.java graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java graal/GraalCompiler/src/com/sun/c1x/ir/StoreField.java graal/GraalCompiler/src/com/sun/c1x/ir/TypeCheck.java graal/GraalCompiler/src/com/sun/c1x/ir/Value.java graal/GraalCompiler/src/com/sun/c1x/ir/ValueClosure.java graal/GraalCompiler/src/com/sun/c1x/ir/ValueVisitor.java
diffstat 12 files changed, 30 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Wed Apr 27 19:53:46 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Wed Apr 27 20:13:54 2011 +0200
@@ -1649,7 +1649,7 @@
 
     private CiValue emitInvokeKnown(RiMethod method, FrameState stateBefore, Value... args) {
         boolean isStatic = Modifier.isStatic(method.accessFlags());
-        Invoke invoke = new Invoke(isStatic ? Bytecodes.INVOKESTATIC : Bytecodes.INVOKESPECIAL, method.signature().returnKind(), args, isStatic, method, null, stateBefore);
+        Invoke invoke = new Invoke(isStatic ? Bytecodes.INVOKESTATIC : Bytecodes.INVOKESPECIAL, method.signature().returnKind(), args, method, null, stateBefore);
         visitInvoke(invoke);
         return invoke.operand();
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Wed Apr 27 19:53:46 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Wed Apr 27 20:13:54 2011 +0200
@@ -691,9 +691,6 @@
         if (!type.isResolved() || type.isArrayClass()) {
             return;
         }
-        if (assumeLeafClass(type)) {
-            check.setDirectCompare();
-        }
     }
 
     void genNewInstance(int cpi) {
@@ -736,7 +733,7 @@
         // Must copy the state here, because the field holder must still be on the stack.
         FrameState stateBefore = curState.immutableCopy(bci());
         boolean isLoaded = !C1XOptions.TestPatching && field.isResolved();
-        LoadField load = new LoadField(apop(), field, false, stateBefore, isLoaded);
+        LoadField load = new LoadField(apop(), field, stateBefore, isLoaded);
         appendOptimizedLoadField(field.kind(), load);
     }
 
@@ -745,7 +742,7 @@
         FrameState stateBefore = curState.immutableCopy(bci());
         boolean isLoaded = !C1XOptions.TestPatching && field.isResolved();
         Value value = pop(field.kind().stackKind());
-        appendOptimizedStoreField(new StoreField(apop(), field, value, false, stateBefore, isLoaded));
+        appendOptimizedStoreField(new StoreField(apop(), field, value, stateBefore, isLoaded));
     }
 
     void genGetStatic(int cpi, RiField field) {
@@ -759,7 +756,7 @@
             push(constantValue.kind.stackKind(), appendConstant(constantValue));
         } else {
             Value container = genResolveClass(RiType.Representation.StaticFields, holder, isInitialized, cpi);
-            LoadField load = new LoadField(container, field, true, null, isInitialized);
+            LoadField load = new LoadField(container, field, null, isInitialized);
             appendOptimizedLoadField(field.kind(), load);
         }
     }
@@ -769,7 +766,7 @@
         boolean isInitialized = !C1XOptions.TestPatching && field.isResolved() && holder.isResolved() && holder.isInitialized();
         Value container = genResolveClass(RiType.Representation.StaticFields, holder, isInitialized, cpi);
         Value value = pop(field.kind().stackKind());
-        StoreField store = new StoreField(container, field, value, true, null, isInitialized);
+        StoreField store = new StoreField(container, field, value, null, isInitialized);
         appendOptimizedStoreField(store);
     }
 
@@ -824,7 +821,7 @@
 
         Value[] args = curState.popArguments(target.signature().argumentSlots(false));
         if (!tryInline(target, args)) {
-            appendInvoke(INVOKESTATIC, target, args, true, cpi, constantPool);
+            appendInvoke(INVOKESTATIC, target, args, cpi, constantPool);
         }
     }
 
@@ -924,7 +921,7 @@
             }
         }
         // devirtualization failed, produce an actual invokevirtual
-        appendInvoke(opcode, target, args, false, cpi, constantPool);
+        appendInvoke(opcode, target, args, cpi, constantPool);
     }
 
     private CiKind returnKind(RiMethod target) {
@@ -934,13 +931,13 @@
     private void invokeDirect(RiMethod target, Value[] args, RiType knownHolder, int cpi, RiConstantPool constantPool) {
         if (!tryInline(target, args)) {
             // could not optimize or inline the method call
-            appendInvoke(INVOKESPECIAL, target, args, false, cpi, constantPool);
+            appendInvoke(INVOKESPECIAL, target, args, cpi, constantPool);
         }
     }
 
-    private void appendInvoke(int opcode, RiMethod target, Value[] args, boolean isStatic, int cpi, RiConstantPool constantPool) {
+    private void appendInvoke(int opcode, RiMethod target, Value[] args, int cpi, RiConstantPool constantPool) {
         CiKind resultType = returnKind(target);
-        Value result = append(new Invoke(opcode, resultType.stackKind(), args, isStatic, target, target.signature().returnType(compilation.method.holder()), null));
+        Value result = append(new Invoke(opcode, resultType.stackKind(), args, target, target.signature().returnType(compilation.method.holder()), null));
         pushReturn(resultType, result);
     }
 
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java	Wed Apr 27 19:53:46 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java	Wed Apr 27 20:13:54 2011 +0200
@@ -31,8 +31,6 @@
 
 /**
  * The base class of all instructions that access fields.
- *
- * @author Ben L. Titzer
  */
 public abstract class AccessField extends StateSplit {
 
@@ -48,7 +46,7 @@
      * @param stateBefore the state before the field access
      * @param isLoaded indicates if the class is loaded
      */
-    public AccessField(CiKind kind, Value object, RiField field, boolean isStatic, FrameState stateBefore, boolean isLoaded) {
+    public AccessField(CiKind kind, Value object, RiField field, FrameState stateBefore, boolean isLoaded) {
         super(kind, stateBefore);
         this.object = object;
         this.field = field;
@@ -58,7 +56,6 @@
             setFlag(Flag.NeedsPatching);
         }
         initFlag(Flag.IsLoaded, isLoaded);
-        initFlag(Flag.IsStatic, isStatic);
         if (isLoaded && object.isNonNull()) {
             eliminateNullCheck();
         }
@@ -87,7 +84,7 @@
      * @return {@code true} if this field access is to a static field
      */
     public boolean isStatic() {
-        return checkFlag(Flag.IsStatic);
+        return Modifier.isStatic(field.accessFlags());
     }
 
     /**
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java	Wed Apr 27 19:53:46 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java	Wed Apr 27 20:13:54 2011 +0200
@@ -36,6 +36,7 @@
 public final class ArithmeticOp extends Op2 {
 
     private FrameState stateBefore;
+    private boolean isStrictFP;
 
     /**
      * Creates a new arithmetic operation.
@@ -48,7 +49,7 @@
      */
     public ArithmeticOp(int opcode, CiKind kind, Value x, Value y, boolean isStrictFP, FrameState stateBefore) {
         super(kind, opcode, x, y);
-        initFlag(Flag.IsStrictFP, isStrictFP);
+        this.isStrictFP = isStrictFP;
         if (stateBefore != null) {
             // state before is only used in the case of a division or remainder,
             // and isn't needed if the zero check is redundant
@@ -60,10 +61,6 @@
                 } else {
                     this.stateBefore = stateBefore;
                 }
-                if (divisor != -1) {
-                    C1XMetrics.DivideSpecialChecksRedundant++;
-                    setFlag(Flag.NoDivSpecialCase);
-                }
             } else {
                 this.stateBefore = stateBefore;
             }
@@ -80,7 +77,7 @@
      * @return {@code true} if this instruction has strict fp semantics
      */
     public boolean isStrictFP() {
-        return checkFlag(Flag.IsStrictFP);
+        return isStrictFP;
     }
 
     /**
@@ -112,10 +109,6 @@
 
     @Override
     public void print(LogStream out) {
-        out.print(x()).
-             print(' ').
-             print(Bytecodes.operator(opcode)).
-             print(' ').
-             print(y());
+        out.print(x()).print(' ').print(Bytecodes.operator(opcode)).print(' ').print(y());
     }
 }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/BlockEnd.java	Wed Apr 27 19:53:46 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/BlockEnd.java	Wed Apr 27 20:13:54 2011 +0200
@@ -39,6 +39,7 @@
     BlockBegin begin;
     final List<BlockBegin> successors;
     FrameState stateAfter;
+    boolean isSafepoint;
 
     /**
      * Constructs a new block end with the specified value type.
@@ -51,9 +52,7 @@
         super(kind);
         this.successors = successors == null ? new ArrayList<BlockBegin>(2) : successors;
         setStateAfter(stateAfter);
-        if (isSafepoint) {
-            setFlag(Value.Flag.IsSafepoint);
-        }
+        this.isSafepoint = isSafepoint;
     }
 
     public BlockEnd(CiKind kind, FrameState stateAfter, boolean isSafepoint) {
@@ -77,7 +76,7 @@
      * @return {@code true} if this instruction is a safepoint
      */
     public boolean isSafepoint() {
-        return checkFlag(Value.Flag.IsSafepoint);
+        return isSafepoint;
     }
 
     /**
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java	Wed Apr 27 19:53:46 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java	Wed Apr 27 20:13:54 2011 +0200
@@ -22,16 +22,17 @@
  */
 package com.sun.c1x.ir;
 
+import java.lang.reflect.*;
+
 import com.sun.c1x.debug.*;
 import com.sun.c1x.util.*;
 import com.sun.c1x.value.*;
+import com.sun.cri.bytecode.*;
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
 
 /**
  * The {@code Invoke} instruction represents all kinds of method calls.
- *
- * @author Ben L. Titzer
  */
 public final class Invoke extends StateSplit {
 
@@ -50,16 +51,13 @@
      * @param target the target method being called
      * @param stateBefore the state before executing the invocation
      */
-    public Invoke(int opcode, CiKind result, Value[] args, boolean isStatic, RiMethod target, RiType returnType, FrameState stateBefore) {
+    public Invoke(int opcode, CiKind result, Value[] args, RiMethod target, RiType returnType, FrameState stateBefore) {
         super(result, stateBefore);
         this.opcode = opcode;
         this.arguments = args;
         this.target = target;
         this.returnType = returnType;
-        if (isStatic) {
-            setFlag(Flag.IsStatic);
-            eliminateNullCheck();
-        } else if (args[0].isNonNull() || args[0].kind.isWord()) {
+        if (isStatic() || args[0].isNonNull() || args[0].kind.isWord()) {
             eliminateNullCheck();
         }
     }
@@ -77,7 +75,7 @@
      * @return {@code true} if the invocation is a static invocation
      */
     public boolean isStatic() {
-        return checkFlag(Flag.IsStatic);
+        return opcode == Bytecodes.INVOKESTATIC;
     }
 
     @Override
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java	Wed Apr 27 19:53:46 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java	Wed Apr 27 20:13:54 2011 +0200
@@ -29,8 +29,6 @@
 
 /**
  * The {@code LoadField} instruction represents a read of a static or instance field.
- *
- * @author Ben L. Titzer
  */
 public final class LoadField extends AccessField {
 
@@ -42,8 +40,8 @@
      * @param stateBefore the state before the field access
      * @param isLoaded indicates if the class is loaded
      */
-    public LoadField(Value object, RiField field, boolean isStatic, FrameState stateBefore, boolean isLoaded) {
-        super(field.kind().stackKind(), object, field, isStatic, stateBefore, isLoaded);
+    public LoadField(Value object, RiField field, FrameState stateBefore, boolean isLoaded) {
+        super(field.kind().stackKind(), object, field, stateBefore, isLoaded);
     }
 
     /**
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/StoreField.java	Wed Apr 27 19:53:46 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/StoreField.java	Wed Apr 27 20:13:54 2011 +0200
@@ -29,8 +29,6 @@
 
 /**
  * The {@code StoreField} instruction represents a write to a static or instance field.
- *
- * @author Ben L. Titzer
  */
 public final class StoreField extends AccessField {
 
@@ -48,8 +46,8 @@
      * @param stateBefore the state before the field access
      * @param isLoaded indicates if the class is loaded
      */
-    public StoreField(Value object, RiField field, Value value, boolean isStatic, FrameState stateBefore, boolean isLoaded) {
-        super(CiKind.Void, object, field, isStatic, stateBefore, isLoaded);
+    public StoreField(Value object, RiField field, Value value, FrameState stateBefore, boolean isLoaded) {
+        super(CiKind.Void, object, field, stateBefore, isLoaded);
         this.value = value;
         setFlag(Flag.LiveStore);
         if (value.kind != CiKind.Object) {
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/TypeCheck.java	Wed Apr 27 19:53:46 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/TypeCheck.java	Wed Apr 27 20:13:54 2011 +0200
@@ -101,19 +101,4 @@
         object = closure.apply(object);
         targetClassInstruction = closure.apply(targetClassInstruction);
     }
-
-    /**
-     * Sets this type check operation to be a direct compare.
-     */
-    public void setDirectCompare() {
-        setFlag(Flag.DirectCompare);
-    }
-
-    /**
-     * Checks where this comparison is a direct compare, because the class compared to is a leaf class.
-     * @return {@code true} if this typecheck is a direct compare
-     */
-    public boolean isDirectCompare() {
-        return checkFlag(Flag.DirectCompare);
-    }
 }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java	Wed Apr 27 19:53:46 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java	Wed Apr 27 20:13:54 2011 +0200
@@ -33,13 +33,9 @@
 /**
  * This class represents a value within the HIR graph, including local variables, phis, and
  * all other instructions.
- *
- * @author Ben L. Titzer
  */
 public abstract class Value {
-    /**
-     * An enumeration of flags on values.
-     */
+
     public enum Flag {
         NonNull,            // this value is non-null
 
@@ -50,14 +46,7 @@
 
         NoReadBarrier,      // does not require read barrier
         NoWriteBarrier,     // does not require write barrier
-        NoDivSpecialCase,   // divide or modulus cannot be special case of MIN_INT / -1
-        DirectCompare,
         IsLoaded,           // field or method is resolved and class is loaded and initialized
-        IsStatic,           // field or method access is static
-        IsSafepoint,        // branch is backward (safepoint)
-        IsStrictFP,
-        PreservesState,     // intrinsic preserves state
-        UnorderedIsTrue,
         NeedsPatching,
         LiveValue,          // live because value is used
         LiveDeopt,          // live for deoptimization
@@ -94,11 +83,6 @@
     protected CiValue operand = CiValue.IllegalValue;
 
     /**
-     * A cache for analysis information. Every optimization must reset this field to {@code null} once it has completed.
-     */
-    public Object optInfo;
-
-    /**
      * Used by {@link InstructionSubstituter}.
      */
     public Value subst;
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/ValueClosure.java	Wed Apr 27 19:53:46 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ValueClosure.java	Wed Apr 27 20:13:54 2011 +0200
@@ -25,8 +25,6 @@
 /**
  * The {@code ValueClosure} interface represents a first-class
  * function that can be applied to a value.
- *
- * @author Ben L. Titzer
  */
 public interface ValueClosure {
     Value apply(Value i);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/ValueVisitor.java	Wed Apr 27 19:53:46 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ValueVisitor.java	Wed Apr 27 20:13:54 2011 +0200
@@ -26,8 +26,6 @@
  * The {@link ValueVisitor} implements one half of the visitor
  * pattern for {@linkplain Value IR values}, allowing clients to implement functionality
  * depending on the type of an value without doing type tests.
- *
- * @author Ben L. Titzer
  */
 public abstract class ValueVisitor {
     // Checkstyle: stop