changeset 19843:c2124d859d91

Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 14 Mar 2015 01:02:08 +0100
parents 80d48cc80222
children 426461951938
files graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaField.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaFieldImpl.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationBlockState.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java
diffstat 6 files changed, 54 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaField.java	Fri Mar 13 22:59:50 2015 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaField.java	Sat Mar 14 01:02:08 2015 +0100
@@ -29,7 +29,7 @@
  * Represents a reference to a resolved Java field. Fields, like methods and types, are resolved
  * through {@link ConstantPool constant pools}.
  */
-public interface ResolvedJavaField extends JavaField, LocationIdentity, ModifiersProvider {
+public interface ResolvedJavaField extends JavaField, ModifiersProvider {
 
     /**
      * {@inheritDoc}
@@ -65,4 +65,11 @@
      *         else {@code null}
      */
     <T extends Annotation> T getAnnotation(Class<T> annotationClass);
+
+    /**
+     * Returns an object representing the unique location identity of this resolved Java field.
+     * 
+     * @return the location identity of the field
+     */
+    LocationIdentity getLocationIdentity();
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaFieldImpl.java	Fri Mar 13 22:59:50 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaFieldImpl.java	Sat Mar 14 01:02:08 2015 +0100
@@ -48,6 +48,35 @@
      * This value contains all flags as stored in the VM including internal ones.
      */
     private final int modifiers;
+    private final LocationIdentity locationIdentity = new LocationIdentity() {
+
+    };
+
+    public static class FieldLocationIdentity {
+        HotSpotResolvedJavaFieldImpl inner;
+
+        public FieldLocationIdentity(HotSpotResolvedJavaFieldImpl inner) {
+            this.inner = inner;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj instanceof FieldLocationIdentity) {
+                FieldLocationIdentity fieldLocationIdentity = (FieldLocationIdentity) obj;
+                return inner.equals(fieldLocationIdentity.inner);
+
+            }
+            return false;
+        }
+
+        @Override
+        public int hashCode() {
+            return inner.hashCode();
+        }
+    }
 
     public HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, String name, JavaType type, long offset, int modifiers) {
         this.holder = holder;
@@ -229,4 +258,8 @@
             }
         }
     }
+
+    public LocationIdentity getLocationIdentity() {
+        return locationIdentity;
+    }
 }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java	Fri Mar 13 22:59:50 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java	Sat Mar 14 01:02:08 2015 +0100
@@ -590,7 +590,7 @@
     protected ConstantLocationNode createFieldLocation(StructuredGraph graph, ResolvedJavaField field, boolean initialization) {
         int offset = fieldOffset(field);
         if (offset >= 0) {
-            LocationIdentity loc = initialization ? initLocationIdentity() : field;
+            LocationIdentity loc = initialization ? initLocationIdentity() : field.getLocationIdentity();
             return graph.unique(new ConstantLocationNode(loc, offset));
         } else {
             return null;
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationBlockState.java	Fri Mar 13 22:59:50 2015 +0100
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationBlockState.java	Sat Mar 14 01:02:08 2015 +0100
@@ -83,7 +83,7 @@
         if (virtual instanceof VirtualInstanceNode) {
             VirtualInstanceNode instance = (VirtualInstanceNode) virtual;
             for (int i = 0; i < instance.entryCount(); i++) {
-                readCache.put(new ReadCacheEntry(instance.field(i), representation), values.get(i));
+                readCache.put(new ReadCacheEntry(instance.field(i).getLocationIdentity(), representation), values.get(i));
             }
         }
     }
@@ -133,7 +133,7 @@
         readCache.clear();
     }
 
-    public void killReadCache(ResolvedJavaField identity) {
+    public void killReadCache(LocationIdentity identity) {
         Iterator<Map.Entry<ReadCacheEntry, ValueNode>> iter = readCache.entrySet().iterator();
         while (iter.hasNext()) {
             Map.Entry<ReadCacheEntry, ValueNode> entry = iter.next();
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java	Fri Mar 13 22:59:50 2015 +0100
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java	Sat Mar 14 01:02:08 2015 +0100
@@ -89,7 +89,7 @@
     private boolean processStoreField(StoreFieldNode store, PEReadEliminationBlockState state, GraphEffectList effects) {
         if (!store.isVolatile()) {
             ValueNode object = GraphUtil.unproxify(store.object());
-            ValueNode cachedValue = state.getReadCache(object, store.field(), this);
+            ValueNode cachedValue = state.getReadCache(object, store.field().getLocationIdentity(), this);
 
             ValueNode value = getScalarAlias(store.value());
             boolean result = false;
@@ -97,8 +97,8 @@
                 effects.deleteNode(store);
                 result = true;
             }
-            state.killReadCache(store.field());
-            state.addReadCache(object, store.field(), value, this);
+            state.killReadCache(store.field().getLocationIdentity());
+            state.addReadCache(object, store.field().getLocationIdentity(), value, this);
             return result;
         } else {
             processIdentity(state, ANY_LOCATION);
@@ -109,13 +109,13 @@
     private boolean processLoadField(LoadFieldNode load, PEReadEliminationBlockState state, GraphEffectList effects) {
         if (!load.isVolatile()) {
             ValueNode object = GraphUtil.unproxify(load.object());
-            ValueNode cachedValue = state.getReadCache(object, load.field(), this);
+            ValueNode cachedValue = state.getReadCache(object, load.field().getLocationIdentity(), this);
             if (cachedValue != null) {
                 effects.replaceAtUsages(load, cachedValue);
                 addScalarAlias(load, cachedValue);
                 return true;
             } else {
-                state.addReadCache(object, load.field(), load, this);
+                state.addReadCache(object, load.field().getLocationIdentity(), load, this);
             }
         } else {
             processIdentity(state, ANY_LOCATION);
@@ -124,10 +124,10 @@
     }
 
     private static void processIdentity(PEReadEliminationBlockState state, LocationIdentity identity) {
-        if (identity instanceof ResolvedJavaField) {
-            state.killReadCache((ResolvedJavaField) identity);
-        } else if (identity.equals(ANY_LOCATION)) {
+        if (identity.equals(ANY_LOCATION)) {
             state.killReadCache();
+        } else {
+            state.killReadCache(identity);
         }
     }
 
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java	Fri Mar 13 22:59:50 2015 +0100
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java	Sat Mar 14 01:02:08 2015 +0100
@@ -60,7 +60,7 @@
                 processIdentity(state, ANY_LOCATION);
             } else {
                 ValueNode object = GraphUtil.unproxify(access.object());
-                LoadCacheEntry identifier = new LoadCacheEntry(object, access.field());
+                LoadCacheEntry identifier = new LoadCacheEntry(object, access.field().getLocationIdentity());
                 ValueNode cachedValue = state.getCacheEntry(identifier);
                 if (node instanceof LoadFieldNode) {
                     if (cachedValue != null && access.stamp().isCompatible(cachedValue.stamp())) {
@@ -78,7 +78,7 @@
                         effects.deleteNode(store);
                         deleted = true;
                     }
-                    state.killReadCache(store.field());
+                    state.killReadCache(store.field().getLocationIdentity());
                     state.addCacheEntry(identifier, value);
                 }
             }