# HG changeset patch # User Thomas Wuerthinger # Date 1426291328 -3600 # Node ID c2124d859d91779606fa631138fb6edc7bca7c76 # Parent 80d48cc802223eb39ab4b3fabf07b89e38f3b450 Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead. diff -r 80d48cc80222 -r c2124d859d91 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaField.java --- 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 getAnnotation(Class annotationClass); + + /** + * Returns an object representing the unique location identity of this resolved Java field. + * + * @return the location identity of the field + */ + LocationIdentity getLocationIdentity(); } diff -r 80d48cc80222 -r c2124d859d91 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaFieldImpl.java --- 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; + } } diff -r 80d48cc80222 -r c2124d859d91 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java --- 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; diff -r 80d48cc80222 -r c2124d859d91 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationBlockState.java --- 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> iter = readCache.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = iter.next(); diff -r 80d48cc80222 -r c2124d859d91 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java --- 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); } } diff -r 80d48cc80222 -r c2124d859d91 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java --- 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); } }