Mercurial > hg > graal-compiler
changeset 18972:b648ac155f1b
Only cache in MergeProcessor of PEA when processing loop begin blocks.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 27 Jan 2015 16:16:06 +0100 |
parents | e349dfa54db1 |
children | 78f9a57525af |
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/PartialEscapeClosure.java |
diffstat | 2 files changed, 43 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java Tue Jan 27 16:01:48 2015 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java Tue Jan 27 16:16:06 2015 +0100 @@ -190,7 +190,7 @@ } } if (phi) { - PhiNode phiNode = getCachedPhi(entry, value.stamp().unrestricted()); + PhiNode phiNode = getPhi(entry, value.stamp().unrestricted()); mergeEffects.addFloatingNode(phiNode, "mergeReadCache"); for (int i = 0; i < states.size(); i++) { afterMergeEffects.addPhiInput(phiNode, states.get(i).getReadCache(key.object, key.identity, PEReadEliminationClosure.this)); @@ -222,7 +222,7 @@ values[i] = value; } - PhiNode phiNode = getCachedPhi(new ReadCacheEntry(identity, phi), values[0].stamp().unrestricted()); + PhiNode phiNode = getPhi(new ReadCacheEntry(identity, phi), values[0].stamp().unrestricted()); mergeEffects.addFloatingNode(phiNode, "mergeReadCachePhi"); for (int i = 0; i < values.length; i++) { afterMergeEffects.addPhiInput(phiNode, values[i]);
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java Tue Jan 27 16:01:48 2015 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java Tue Jan 27 16:16:06 2015 +0100 @@ -313,15 +313,28 @@ protected class MergeProcessor extends EffectsClosure<BlockT>.MergeProcessor { - private final HashMap<Object, ValuePhiNode> materializedPhis = CollectionsFactory.newMap(); - private final Map<ValueNode, ValuePhiNode[]> valuePhis = Node.newIdentityMap(); - private final Map<ValuePhiNode, VirtualObjectNode> valueObjectVirtuals = Node.newIdentityMap(); + private HashMap<Object, ValuePhiNode> materializedPhis; + private Map<ValueNode, ValuePhiNode[]> valuePhis; + private Map<ValuePhiNode, VirtualObjectNode> valueObjectVirtuals; + private final boolean needsCaching; public MergeProcessor(Block mergeBlock) { super(mergeBlock); + needsCaching = mergeBlock.isLoopHeader(); } - protected <T> PhiNode getCachedPhi(T virtual, Stamp stamp) { + protected <T> PhiNode getPhi(T virtual, Stamp stamp) { + if (needsCaching) { + return getPhiCached(virtual, stamp); + } else { + return new ValuePhiNode(stamp, merge); + } + } + + private <T> PhiNode getPhiCached(T virtual, Stamp stamp) { + if (materializedPhis == null) { + materializedPhis = CollectionsFactory.newMap(); + } ValuePhiNode result = materializedPhis.get(virtual); if (result == null) { result = new ValuePhiNode(stamp, merge); @@ -331,6 +344,17 @@ } private PhiNode[] getValuePhis(ValueNode key, int entryCount) { + if (needsCaching) { + return getValuePhisCached(key, entryCount); + } else { + return new ValuePhiNode[entryCount]; + } + } + + private PhiNode[] getValuePhisCached(ValueNode key, int entryCount) { + if (valuePhis == null) { + valuePhis = Node.newIdentityMap(); + } ValuePhiNode[] result = valuePhis.get(key); if (result == null) { result = new ValuePhiNode[entryCount]; @@ -341,6 +365,17 @@ } private VirtualObjectNode getValueObjectVirtual(ValuePhiNode phi, VirtualObjectNode virtual) { + if (needsCaching) { + return getValueObjectVirtualCached(phi, virtual); + } else { + return virtual.duplicate(); + } + } + + private VirtualObjectNode getValueObjectVirtualCached(ValuePhiNode phi, VirtualObjectNode virtual) { + if (valueObjectVirtuals == null) { + valueObjectVirtuals = Node.newIdentityMap(); + } VirtualObjectNode result = valueObjectVirtuals.get(phi); if (result == null) { result = virtual.duplicate(); @@ -395,7 +430,7 @@ if (uniqueMaterializedValue != null) { newState.addObject(object, new ObjectState(object, uniqueMaterializedValue, EscapeState.Materialized, null)); } else { - PhiNode materializedValuePhi = getCachedPhi(object, StampFactory.forKind(Kind.Object)); + PhiNode materializedValuePhi = getPhi(object, StampFactory.forKind(Kind.Object)); mergeEffects.addFloatingNode(materializedValuePhi, "materializedPhi"); for (int i = 0; i < objStates.length; i++) { ObjectState obj = objStates[i]; @@ -538,7 +573,7 @@ return materialized; } else { // not compatible: materialize in all predecessors - PhiNode materializedValuePhi = getCachedPhi(object, StampFactory.forKind(Kind.Object)); + PhiNode materializedValuePhi = getPhi(object, StampFactory.forKind(Kind.Object)); for (int i = 0; i < blockStates.size(); i++) { ObjectState obj = objStates[i]; Block predecessor = mergeBlock.getPredecessors().get(i);