# HG changeset patch # User Tom Rodriguez # Date 1408669342 25200 # Node ID 3d190fc2e081f88d671cfa4d0b72aa890d18f165 # Parent 8f4150982bc3624431c2216abea56022aa731b6c Consider the offset when performing read elimination on unsafes diff -r 8f4150982bc3 -r 3d190fc2e081 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationBlockState.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationBlockState.java Thu Aug 21 17:50:00 2014 -0700 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationBlockState.java Thu Aug 21 18:02:22 2014 -0700 @@ -84,6 +84,32 @@ } } + /** + * CacheEntry describing an Unsafe memory reference. The memory location and the location + * identity are separate so both must be considered when looking for optimizable memory + * accesses. + * + */ + static class UnsafeLoadCacheEntry extends CacheEntry { + + private LocationIdentity locationIdentity; + + public UnsafeLoadCacheEntry(ValueNode object, ValueNode location, LocationIdentity locationIdentity) { + super(object, location); + this.locationIdentity = locationIdentity; + } + + @Override + public CacheEntry duplicateWithObject(ValueNode newObject) { + return new UnsafeLoadCacheEntry(newObject, identity, locationIdentity); + } + + @Override + public boolean conflicts(LocationIdentity other) { + return locationIdentity == other; + } + } + static class ReadCacheEntry extends CacheEntry { public ReadCacheEntry(ValueNode object, LocationNode identity) { diff -r 8f4150982bc3 -r 3d190fc2e081 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 Thu Aug 21 17:50:00 2014 -0700 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java Thu Aug 21 18:02:22 2014 -0700 @@ -37,6 +37,7 @@ import com.oracle.graal.virtual.phases.ea.ReadEliminationBlockState.CacheEntry; import com.oracle.graal.virtual.phases.ea.ReadEliminationBlockState.LoadCacheEntry; import com.oracle.graal.virtual.phases.ea.ReadEliminationBlockState.ReadCacheEntry; +import com.oracle.graal.virtual.phases.ea.ReadEliminationBlockState.UnsafeLoadCacheEntry; public class ReadEliminationClosure extends EffectsClosure { @@ -121,7 +122,7 @@ UnsafeLoadNode load = (UnsafeLoadNode) node; if (load.offset().isConstant() && load.getLocationIdentity() != LocationIdentity.ANY_LOCATION) { ValueNode object = GraphUtil.unproxify(load.object()); - LoadCacheEntry identifier = new LoadCacheEntry(object, load.getLocationIdentity()); + UnsafeLoadCacheEntry identifier = new UnsafeLoadCacheEntry(object, load.offset(), load.getLocationIdentity()); ValueNode cachedValue = state.getCacheEntry(identifier); if (cachedValue != null) { effects.replaceAtUsages(load, cachedValue); @@ -136,7 +137,7 @@ UnsafeStoreNode write = (UnsafeStoreNode) node; if (write.offset().isConstant() && write.getLocationIdentity() != LocationIdentity.ANY_LOCATION) { ValueNode object = GraphUtil.unproxify(write.object()); - LoadCacheEntry identifier = new LoadCacheEntry(object, write.getLocationIdentity()); + UnsafeLoadCacheEntry identifier = new UnsafeLoadCacheEntry(object, write.offset(), write.getLocationIdentity()); ValueNode cachedValue = state.getCacheEntry(identifier); ValueNode value = getScalarAlias(write.value());