changeset 2540:3fc322165071

More flags clean up.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Apr 2011 20:27:43 +0200
parents fa3bda50cbfd
children 0f9eeb15e636
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/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/Value.java
diffstat 7 files changed, 17 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Wed Apr 27 20:22:05 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Wed Apr 27 20:27:43 2011 +0200
@@ -513,7 +513,7 @@
     @Override
     public void visitLoadField(LoadField x) {
         RiField field = x.field();
-        boolean needsPatching = x.needsPatching();
+        boolean needsPatching = !x.isLoaded();
         LIRDebugInfo info = null;
         if (needsPatching || x.needsNullCheck()) {
             info = stateFor(x, x.stateBefore());
@@ -804,7 +804,7 @@
     @Override
     public void visitStoreField(StoreField x) {
         RiField field = x.field();
-        boolean needsPatching = x.needsPatching();
+        boolean needsPatching = !x.isLoaded();
 
         LIRDebugInfo info = null;
         if (needsPatching || x.needsNullCheck()) {
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Wed Apr 27 20:22:05 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Wed Apr 27 20:27:43 2011 +0200
@@ -732,22 +732,20 @@
     void genGetField(int cpi, RiField field) {
         // 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, stateBefore, isLoaded);
+        LoadField load = new LoadField(apop(), field, stateBefore);
         appendOptimizedLoadField(field.kind(), load);
     }
 
     void genPutField(int cpi, RiField field) {
         // 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();
         Value value = pop(field.kind().stackKind());
-        appendOptimizedStoreField(new StoreField(apop(), field, value, stateBefore, isLoaded));
+        appendOptimizedStoreField(new StoreField(apop(), field, value, stateBefore));
     }
 
     void genGetStatic(int cpi, RiField field) {
         RiType holder = field.holder();
-        boolean isInitialized = !C1XOptions.TestPatching && field.isResolved() && holder.isResolved() && holder.isInitialized();
+        boolean isInitialized = !C1XOptions.TestPatching && field.isResolved();
         CiConstant constantValue = null;
         if (isInitialized) {
             constantValue = field.constantValue(null);
@@ -755,18 +753,17 @@
         if (constantValue != null) {
             push(constantValue.kind.stackKind(), appendConstant(constantValue));
         } else {
-            Value container = genResolveClass(RiType.Representation.StaticFields, holder, isInitialized, cpi);
-            LoadField load = new LoadField(container, field, null, isInitialized);
+            Value container = genResolveClass(RiType.Representation.StaticFields, holder, field.isResolved(), cpi);
+            LoadField load = new LoadField(container, field, null);
             appendOptimizedLoadField(field.kind(), load);
         }
     }
 
     void genPutStatic(int cpi, RiField field) {
         RiType holder = field.holder();
-        boolean isInitialized = !C1XOptions.TestPatching && field.isResolved() && holder.isResolved() && holder.isInitialized();
-        Value container = genResolveClass(RiType.Representation.StaticFields, holder, isInitialized, cpi);
+        Value container = genResolveClass(RiType.Representation.StaticFields, holder, field.isResolved(), cpi);
         Value value = pop(field.kind().stackKind());
-        StoreField store = new StoreField(container, field, value, null, isInitialized);
+        StoreField store = new StoreField(container, field, value, null);
         appendOptimizedStoreField(store);
     }
 
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java	Wed Apr 27 20:22:05 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java	Wed Apr 27 20:27:43 2011 +0200
@@ -24,7 +24,6 @@
 
 import java.lang.reflect.*;
 
-import com.sun.c1x.*;
 import com.sun.c1x.value.*;
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
@@ -36,7 +35,6 @@
 
     private Value object;
     protected final RiField field;
-    private boolean needsPatching;
 
     /**
      * Constructs a new access field object.
@@ -47,17 +45,11 @@
      * @param stateBefore the state before the field access
      * @param isLoaded indicates if the class is loaded
      */
-    public AccessField(CiKind kind, Value object, RiField field, FrameState stateBefore, boolean isLoaded) {
+    public AccessField(CiKind kind, Value object, RiField field, FrameState stateBefore) {
         super(kind, stateBefore);
         this.object = object;
         this.field = field;
-        if (!isLoaded || (C1XOptions.TestPatching && !Modifier.isVolatile(field.accessFlags()))) {
-            // require patching if the field is not loaded (i.e. resolved),
-            // or if patch testing is turned on (but not if the field is volatile)
-            needsPatching = true;
-        }
-        initFlag(Flag.IsLoaded, isLoaded);
-        if (isLoaded && object.isNonNull()) {
+        if (field.isResolved() && object.isNonNull()) {
             eliminateNullCheck();
         }
         assert object != null : "every field access must reference some object";
@@ -93,7 +85,7 @@
      * @return {@code true} if the class is loaded
      */
     public boolean isLoaded() {
-        return checkFlag(Flag.IsLoaded);
+        return field.isResolved();
     }
 
     /**
@@ -112,21 +104,13 @@
     }
 
     /**
-     * Checks whether this field access will require patching.
-     * @return {@code true} if this field access will require patching
-     */
-    public boolean needsPatching() {
-        return needsPatching;
-    }
-
-    /**
      * Checks whether this field access may cause a trap or an exception, which
      * is if it either requires a null check or needs patching.
      * @return {@code true} if this field access can cause a trap
      */
     @Override
     public boolean canTrap() {
-        return needsPatching() || needsNullCheck();
+        return !isLoaded() || needsNullCheck();
     }
 
     @Override
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java	Wed Apr 27 20:22:05 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java	Wed Apr 27 20:27:43 2011 +0200
@@ -22,8 +22,6 @@
  */
 package com.sun.c1x.ir;
 
-import java.lang.reflect.*;
-
 import com.sun.c1x.debug.*;
 import com.sun.c1x.util.*;
 import com.sun.c1x.value.*;
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java	Wed Apr 27 20:22:05 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java	Wed Apr 27 20:27:43 2011 +0200
@@ -40,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, FrameState stateBefore, boolean isLoaded) {
-        super(field.kind().stackKind(), object, field, stateBefore, isLoaded);
+    public LoadField(Value object, RiField field, FrameState stateBefore) {
+        super(field.kind().stackKind(), object, field, stateBefore);
     }
 
     /**
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/StoreField.java	Wed Apr 27 20:22:05 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/StoreField.java	Wed Apr 27 20:27:43 2011 +0200
@@ -46,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, FrameState stateBefore, boolean isLoaded) {
-        super(CiKind.Void, object, field, stateBefore, isLoaded);
+    public StoreField(Value object, RiField field, Value value, FrameState stateBefore) {
+        super(CiKind.Void, object, field, stateBefore);
         this.value = value;
         setFlag(Flag.LiveSideEffect);
         if (value.kind != CiKind.Object) {
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java	Wed Apr 27 20:22:05 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java	Wed Apr 27 20:27:43 2011 +0200
@@ -46,7 +46,6 @@
 
         NoReadBarrier,      // does not require read barrier
         NoWriteBarrier,     // does not require write barrier
-        IsLoaded,           // field or method is resolved and class is loaded and initialized
         LiveValue,          // live because value is used
         LiveDeopt,          // live for deoptimization
         LiveSideEffect,     // live for possible side-effects only