# HG changeset patch # User Lukas Stadler # Date 1400860064 -7200 # Node ID 387b15da0f681ebc48bec0f1b5f07c98eb8bce5a # Parent e626b112aa3da6e24cd34706b781ce46dd4240d4 small cleanup in ReadElimination diff -r e626b112aa3d -r 387b15da0f68 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 Fri May 23 17:47:15 2014 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationBlockState.java Fri May 23 17:47:44 2014 +0200 @@ -132,13 +132,7 @@ } public void killReadCache(LocationIdentity identity) { - Iterator, ValueNode>> iter = readCache.entrySet().iterator(); - while (iter.hasNext()) { - Map.Entry, ValueNode> entry = iter.next(); - if (entry.getKey().conflicts(identity)) { - iter.remove(); - } - } + readCache.entrySet().removeIf(entry -> entry.getKey().conflicts(identity)); } public Map, ValueNode> getReadCache() { diff -r e626b112aa3d -r 387b15da0f68 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 May 23 17:47:15 2014 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java Fri May 23 17:47:44 2014 +0200 @@ -80,70 +80,75 @@ state.addCacheEntry(identifier, value); } } - } else if (node instanceof ReadNode) { - ReadNode read = (ReadNode) node; - if (read.location() instanceof ConstantLocationNode) { - ValueNode object = GraphUtil.unproxify(read.object()); - ReadCacheEntry identifier = new ReadCacheEntry(object, read.location()); - ValueNode cachedValue = state.getCacheEntry(identifier); - if (cachedValue != null) { - if (read.getGuard() != null && !(read.getGuard() instanceof FixedNode)) { - effects.addFixedNodeBefore(new ValueAnchorNode((ValueNode) read.getGuard()), read); + } else if (node instanceof FixedAccessNode) { + if (node instanceof ReadNode) { + ReadNode read = (ReadNode) node; + if (read.location() instanceof ConstantLocationNode) { + ValueNode object = GraphUtil.unproxify(read.object()); + ReadCacheEntry identifier = new ReadCacheEntry(object, read.location()); + ValueNode cachedValue = state.getCacheEntry(identifier); + if (cachedValue != null) { + if (read.getGuard() != null && !(read.getGuard() instanceof FixedNode)) { + effects.addFixedNodeBefore(new ValueAnchorNode((ValueNode) read.getGuard()), read); + } + effects.replaceAtUsages(read, cachedValue); + addScalarAlias(read, cachedValue); + deleted = true; + } else { + state.addCacheEntry(identifier, read); } - effects.replaceAtUsages(read, cachedValue); - addScalarAlias(read, cachedValue); - deleted = true; + } + } else if (node instanceof WriteNode) { + WriteNode write = (WriteNode) node; + if (write.location() instanceof ConstantLocationNode) { + ValueNode object = GraphUtil.unproxify(write.object()); + ReadCacheEntry identifier = new ReadCacheEntry(object, write.location()); + ValueNode cachedValue = state.getCacheEntry(identifier); + + ValueNode value = getScalarAlias(write.value()); + if (GraphUtil.unproxify(value) == GraphUtil.unproxify(cachedValue)) { + effects.deleteFixedNode(write); + deleted = true; + } + processIdentity(state, write.location().getLocationIdentity()); + state.addCacheEntry(identifier, value); } else { - state.addCacheEntry(identifier, read); - } - } - } else if (node instanceof UnsafeLoadNode) { - 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()); - ValueNode cachedValue = state.getCacheEntry(identifier); - if (cachedValue != null) { - effects.replaceAtUsages(load, cachedValue); - addScalarAlias(load, cachedValue); - deleted = true; - } else { - state.addCacheEntry(identifier, load); + processIdentity(state, write.location().getLocationIdentity()); } } - } else if (node instanceof WriteNode) { - WriteNode write = (WriteNode) node; - if (write.location() instanceof ConstantLocationNode) { - ValueNode object = GraphUtil.unproxify(write.object()); - ReadCacheEntry identifier = new ReadCacheEntry(object, write.location()); - ValueNode cachedValue = state.getCacheEntry(identifier); - - ValueNode value = getScalarAlias(write.value()); - if (GraphUtil.unproxify(value) == GraphUtil.unproxify(cachedValue)) { - effects.deleteFixedNode(write); - deleted = true; + } else if (node instanceof UnsafeAccessNode) { + if (node instanceof UnsafeLoadNode) { + 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()); + ValueNode cachedValue = state.getCacheEntry(identifier); + if (cachedValue != null) { + effects.replaceAtUsages(load, cachedValue); + addScalarAlias(load, cachedValue); + deleted = true; + } else { + state.addCacheEntry(identifier, load); + } } - processIdentity(state, write.location().getLocationIdentity()); - state.addCacheEntry(identifier, value); } else { - processIdentity(state, write.location().getLocationIdentity()); - } - } else if (node instanceof UnsafeStoreNode) { - 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()); - ValueNode cachedValue = state.getCacheEntry(identifier); + assert node instanceof UnsafeStoreNode; + 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()); + ValueNode cachedValue = state.getCacheEntry(identifier); - ValueNode value = getScalarAlias(write.value()); - if (GraphUtil.unproxify(value) == GraphUtil.unproxify(cachedValue)) { - effects.deleteFixedNode(write); - deleted = true; + ValueNode value = getScalarAlias(write.value()); + if (GraphUtil.unproxify(value) == GraphUtil.unproxify(cachedValue)) { + effects.deleteFixedNode(write); + deleted = true; + } + processIdentity(state, write.getLocationIdentity()); + state.addCacheEntry(identifier, value); + } else { + processIdentity(state, write.getLocationIdentity()); } - processIdentity(state, write.getLocationIdentity()); - state.addCacheEntry(identifier, value); - } else { - processIdentity(state, write.getLocationIdentity()); } } else if (node instanceof MemoryCheckpoint.Single) { LocationIdentity identity = ((MemoryCheckpoint.Single) node).getLocationIdentity();