# HG changeset patch # User Lukas Stadler # Date 1398241579 -7200 # Node ID f37a81a76000509ecc9331db8b0df5cc57c2a035 # Parent d9c64f6a11c7f9e329bb1eb83c84dd38ba39d795 handle array length in PEAReadElimination diff -r d9c64f6a11c7 -r f37a81a76000 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 Wed Apr 23 10:26:19 2014 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationBlockState.java Wed Apr 23 10:26:19 2014 +0200 @@ -34,10 +34,10 @@ static class ReadCacheEntry { - public final ResolvedJavaField identity; + public final LocationIdentity identity; public final ValueNode object; - public ReadCacheEntry(ResolvedJavaField identity, ValueNode object) { + public ReadCacheEntry(LocationIdentity identity, ValueNode object) { this.identity = identity; this.object = object; } @@ -95,7 +95,7 @@ return super.equivalentTo(other); } - public void addReadCache(ValueNode object, ResolvedJavaField identity, ValueNode value, PartialEscapeClosure closure) { + public void addReadCache(ValueNode object, LocationIdentity identity, ValueNode value, PartialEscapeClosure closure) { ValueNode cacheObject; ObjectState obj = closure.getObjectState(this, object); if (obj != null) { @@ -107,7 +107,7 @@ readCache.put(new ReadCacheEntry(identity, cacheObject), value); } - public ValueNode getReadCache(ValueNode object, ResolvedJavaField identity, PartialEscapeClosure closure) { + public ValueNode getReadCache(ValueNode object, LocationIdentity identity, PartialEscapeClosure closure) { ValueNode cacheObject; ObjectState obj = closure.getObjectState(this, object); if (obj != null) { diff -r d9c64f6a11c7 -r f37a81a76000 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 Wed Apr 23 10:26:19 2014 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java Wed Apr 23 10:26:19 2014 +0200 @@ -83,6 +83,17 @@ } else { processIdentity(state, ANY_LOCATION); } + } else if (node instanceof ArrayLengthNode) { + ArrayLengthNode length = (ArrayLengthNode) node; + ValueNode array = GraphUtil.unproxify(length.array()); + ValueNode cachedValue = state.getReadCache(array, ARRAY_LENGTH_LOCATION, this); + if (cachedValue != null) { + effects.replaceAtUsages(length, cachedValue); + addScalarAlias(length, cachedValue); + deleted = true; + } else { + state.addReadCache(array, ARRAY_LENGTH_LOCATION, length, this); + } } else if (node instanceof MemoryCheckpoint.Single) { METRIC_MEMORYCHECKPOINT.increment(); LocationIdentity identity = ((MemoryCheckpoint.Single) node).getLocationIdentity(); @@ -183,7 +194,7 @@ } } - private void mergeReadCachePhi(PhiNode phi, ResolvedJavaField identity, List states) { + private void mergeReadCachePhi(PhiNode phi, LocationIdentity identity, List states) { ValueNode[] values = new ValueNode[phi.valueCount()]; for (int i = 0; i < phi.valueCount(); i++) { ValueNode value = states.get(i).getReadCache(phi.valueAt(i), identity, PEReadEliminationClosure.this);