Mercurial > hg > graal-compiler
changeset 10914:3e407b9c3b13
GRAAL-375: volatile read is moved out of loop
author | twisti |
---|---|
date | Tue, 30 Jul 2013 16:16:42 -0700 |
parents | 19a7856e3ab9 |
children | bc70ae12be39 |
files | 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 | 2 files changed, 52 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java Tue Jul 30 16:15:01 2013 -0700 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java Tue Jul 30 16:16:42 2013 -0700 @@ -55,27 +55,35 @@ if (!deleted) { if (node instanceof LoadFieldNode) { LoadFieldNode load = (LoadFieldNode) node; - ValueNode object = GraphUtil.unproxify(load.object()); - ValueNode cachedValue = state.getReadCache(object, load.field()); - if (cachedValue != null) { - effects.replaceAtUsages(load, cachedValue); - state.addScalarAlias(load, cachedValue); - deleted = true; + if (!load.isVolatile()) { + ValueNode object = GraphUtil.unproxify(load.object()); + ValueNode cachedValue = state.getReadCache(object, load.field()); + if (cachedValue != null) { + effects.replaceAtUsages(load, cachedValue); + state.addScalarAlias(load, cachedValue); + deleted = true; + } else { + state.addReadCache(object, load.field(), load); + } } else { - state.addReadCache(object, load.field(), load); + processIdentity(state, ANY_LOCATION); } } else if (node instanceof StoreFieldNode) { StoreFieldNode store = (StoreFieldNode) node; - ValueNode object = GraphUtil.unproxify(store.object()); - ValueNode cachedValue = state.getReadCache(object, store.field()); + if (!store.isVolatile()) { + ValueNode object = GraphUtil.unproxify(store.object()); + ValueNode cachedValue = state.getReadCache(object, store.field()); - ValueNode value = state.getScalarAlias(store.value()); - if (GraphUtil.unproxify(value) == GraphUtil.unproxify(cachedValue)) { - effects.deleteFixedNode(store); - deleted = true; + ValueNode value = state.getScalarAlias(store.value()); + if (GraphUtil.unproxify(value) == GraphUtil.unproxify(cachedValue)) { + effects.deleteFixedNode(store); + deleted = true; + } + state.killReadCache(store.field()); + state.addReadCache(object, store.field(), value); + } else { + processIdentity(state, ANY_LOCATION); } - state.killReadCache(store.field()); - state.addReadCache(object, store.field(), value); } else if (node instanceof MemoryCheckpoint.Single) { METRIC_MEMORYCHECKOINT.increment(); LocationIdentity identity = ((MemoryCheckpoint.Single) node).getLocationIdentity();
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java Tue Jul 30 16:15:01 2013 -0700 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java Tue Jul 30 16:16:42 2013 -0700 @@ -55,29 +55,37 @@ boolean deleted = false; if (node instanceof LoadFieldNode) { LoadFieldNode load = (LoadFieldNode) node; - ValueNode object = GraphUtil.unproxify(load.object()); - LoadCacheEntry identifier = new LoadCacheEntry(object, load.field()); - ValueNode cachedValue = state.getCacheEntry(identifier); - if (cachedValue != null) { - effects.replaceAtUsages(load, cachedValue); - state.addScalarAlias(load, cachedValue); - deleted = true; + if (!load.isVolatile()) { + ValueNode object = GraphUtil.unproxify(load.object()); + LoadCacheEntry identifier = new LoadCacheEntry(object, load.field()); + ValueNode cachedValue = state.getCacheEntry(identifier); + if (cachedValue != null) { + effects.replaceAtUsages(load, cachedValue); + state.addScalarAlias(load, cachedValue); + deleted = true; + } else { + state.addCacheEntry(identifier, load); + } } else { - state.addCacheEntry(identifier, load); + processIdentity(state, ANY_LOCATION); } } else if (node instanceof StoreFieldNode) { StoreFieldNode store = (StoreFieldNode) node; - ValueNode object = GraphUtil.unproxify(store.object()); - LoadCacheEntry identifier = new LoadCacheEntry(object, store.field()); - ValueNode cachedValue = state.getCacheEntry(identifier); + if (!store.isVolatile()) { + ValueNode object = GraphUtil.unproxify(store.object()); + LoadCacheEntry identifier = new LoadCacheEntry(object, store.field()); + ValueNode cachedValue = state.getCacheEntry(identifier); - ValueNode value = state.getScalarAlias(store.value()); - if (GraphUtil.unproxify(value) == GraphUtil.unproxify(cachedValue)) { - effects.deleteFixedNode(store); - deleted = true; + ValueNode value = state.getScalarAlias(store.value()); + if (GraphUtil.unproxify(value) == GraphUtil.unproxify(cachedValue)) { + effects.deleteFixedNode(store); + deleted = true; + } + state.killReadCache((LocationIdentity) store.field()); + state.addCacheEntry(identifier, value); + } else { + processIdentity(state, ANY_LOCATION); } - state.killReadCache((LocationIdentity) store.field()); - state.addCacheEntry(identifier, value); } else if (node instanceof ReadNode) { ReadNode read = (ReadNode) node; if (read.location() instanceof ConstantLocationNode) { @@ -104,13 +112,14 @@ effects.deleteFixedNode(write); deleted = true; } - state.killReadCache(write.location().getLocationIdentity()); + processIdentity(state, write.location().getLocationIdentity()); state.addCacheEntry(identifier, value); } else { - state.killReadCache(write.location().getLocationIdentity()); + processIdentity(state, write.location().getLocationIdentity()); } } else if (node instanceof MemoryCheckpoint.Single) { - processIdentity(state, ((MemoryCheckpoint.Single) node).getLocationIdentity()); + LocationIdentity identity = ((MemoryCheckpoint.Single) node).getLocationIdentity(); + processIdentity(state, identity); } else if (node instanceof MemoryCheckpoint.Multi) { for (LocationIdentity identity : ((MemoryCheckpoint.Multi) node).getLocationIdentities()) { processIdentity(state, identity);