changeset 16461:be0ad9b9aefe

do not create proxy nodes if the graph doesn't need them
author Lukas Stadler <lukas.stadler@oracle.com>
date Thu, 10 Jul 2014 17:11:57 +0200
parents 1da834bdfda2
children 1a6989c482f6
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 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java
diffstat 3 files changed, 42 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java	Thu Jul 10 17:07:35 2014 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java	Thu Jul 10 17:11:57 2014 +0200
@@ -120,13 +120,15 @@
     protected void processLoopExit(LoopExitNode exitNode, PEReadEliminationBlockState initialState, PEReadEliminationBlockState exitState, GraphEffectList effects) {
         super.processLoopExit(exitNode, initialState, exitState, effects);
 
-        for (Map.Entry<ReadCacheEntry, ValueNode> entry : exitState.getReadCache().entrySet()) {
-            if (initialState.getReadCache().get(entry.getKey()) != entry.getValue()) {
-                ValueNode value = exitState.getReadCache(entry.getKey().object, entry.getKey().identity, this);
-                if (!(value instanceof ProxyNode) || ((ProxyNode) value).proxyPoint() != exitNode) {
-                    ProxyNode proxy = new ValueProxyNode(value, exitNode);
-                    effects.addFloatingNode(proxy, "readCacheProxy");
-                    entry.setValue(proxy);
+        if (exitNode.graph().hasValueProxies()) {
+            for (Map.Entry<ReadCacheEntry, ValueNode> entry : exitState.getReadCache().entrySet()) {
+                if (initialState.getReadCache().get(entry.getKey()) != entry.getValue()) {
+                    ValueNode value = exitState.getReadCache(entry.getKey().object, entry.getKey().identity, this);
+                    if (!(value instanceof ProxyNode) || ((ProxyNode) value).proxyPoint() != exitNode) {
+                        ProxyNode proxy = new ValueProxyNode(value, exitNode);
+                        effects.addFloatingNode(proxy, "readCacheProxy");
+                        entry.setValue(proxy);
+                    }
                 }
             }
         }
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java	Thu Jul 10 17:07:35 2014 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java	Thu Jul 10 17:11:57 2014 +0200
@@ -229,33 +229,35 @@
                 proxies.put(obj.virtual, proxy);
             }
         }
-        for (ObjectState obj : exitState.getStates()) {
-            ObjectState initialObj = initialState.getObjectStateOptional(obj.virtual);
-            if (obj.isVirtual()) {
-                for (int i = 0; i < obj.getEntries().length; i++) {
-                    ValueNode value = obj.getEntry(i);
-                    if (!(value instanceof VirtualObjectNode || value.isConstant())) {
-                        if (exitNode.loopBegin().isPhiAtMerge(value) || initialObj == null || !initialObj.isVirtual() || initialObj.getEntry(i) != value) {
-                            ProxyNode proxy = new ValueProxyNode(value, exitNode);
-                            obj.setEntry(i, proxy);
-                            effects.addFloatingNode(proxy, "virtualProxy");
+        if (exitNode.graph().hasValueProxies()) {
+            for (ObjectState obj : exitState.getStates()) {
+                ObjectState initialObj = initialState.getObjectStateOptional(obj.virtual);
+                if (obj.isVirtual()) {
+                    for (int i = 0; i < obj.getEntries().length; i++) {
+                        ValueNode value = obj.getEntry(i);
+                        if (!(value instanceof VirtualObjectNode || value.isConstant())) {
+                            if (exitNode.loopBegin().isPhiAtMerge(value) || initialObj == null || !initialObj.isVirtual() || initialObj.getEntry(i) != value) {
+                                ProxyNode proxy = new ValueProxyNode(value, exitNode);
+                                obj.setEntry(i, proxy);
+                                effects.addFloatingNode(proxy, "virtualProxy");
+                            }
                         }
                     }
-                }
-            } else {
-                if (initialObj == null || initialObj.isVirtual()) {
-                    ProxyNode proxy = proxies.get(obj.virtual);
-                    if (proxy == null) {
-                        proxy = new ValueProxyNode(obj.getMaterializedValue(), exitNode);
-                        effects.addFloatingNode(proxy, "proxy");
+                } else {
+                    if (initialObj == null || initialObj.isVirtual()) {
+                        ProxyNode proxy = proxies.get(obj.virtual);
+                        if (proxy == null) {
+                            proxy = new ValueProxyNode(obj.getMaterializedValue(), exitNode);
+                            effects.addFloatingNode(proxy, "proxy");
+                        } else {
+                            effects.replaceFirstInput(proxy, proxy.value(), obj.getMaterializedValue());
+                            // nothing to do - will be handled in processNode
+                        }
+                        obj.updateMaterializedValue(proxy);
                     } else {
-                        effects.replaceFirstInput(proxy, proxy.value(), obj.getMaterializedValue());
-                        // nothing to do - will be handled in processNode
-                    }
-                    obj.updateMaterializedValue(proxy);
-                } else {
-                    if (initialObj.getMaterializedValue() == obj.getMaterializedValue()) {
-                        Debug.log("materialized value changes within loop: %s vs. %s at %s", initialObj.getMaterializedValue(), obj.getMaterializedValue(), exitNode);
+                        if (initialObj.getMaterializedValue() == obj.getMaterializedValue()) {
+                            Debug.log("materialized value changes within loop: %s vs. %s at %s", initialObj.getMaterializedValue(), obj.getMaterializedValue(), exitNode);
+                        }
                     }
                 }
             }
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java	Thu Jul 10 17:07:35 2014 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java	Thu Jul 10 17:11:57 2014 +0200
@@ -171,11 +171,13 @@
 
     @Override
     protected void processLoopExit(LoopExitNode exitNode, ReadEliminationBlockState initialState, ReadEliminationBlockState exitState, GraphEffectList effects) {
-        for (Map.Entry<CacheEntry<?>, ValueNode> entry : exitState.getReadCache().entrySet()) {
-            if (initialState.getReadCache().get(entry.getKey()) != entry.getValue()) {
-                ProxyNode proxy = new ValueProxyNode(exitState.getCacheEntry(entry.getKey()), exitNode);
-                effects.addFloatingNode(proxy, "readCacheProxy");
-                entry.setValue(proxy);
+        if (exitNode.graph().hasValueProxies()) {
+            for (Map.Entry<CacheEntry<?>, ValueNode> entry : exitState.getReadCache().entrySet()) {
+                if (initialState.getReadCache().get(entry.getKey()) != entry.getValue()) {
+                    ProxyNode proxy = new ValueProxyNode(exitState.getCacheEntry(entry.getKey()), exitNode);
+                    effects.addFloatingNode(proxy, "readCacheProxy");
+                    entry.setValue(proxy);
+                }
             }
         }
     }