changeset 11802:82c4106741f7

SnippetTemplate: avoid two getNodes() in assertions. comment fix and renames
author Bernhard Urban <bernhard.urban@jku.at>
date Wed, 25 Sep 2013 16:55:03 +0200
parents 63ee8dea4b80
children eb2def6529bc
files graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java
diffstat 1 files changed, 13 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Thu Sep 26 03:04:38 2013 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Wed Sep 25 16:55:03 2013 +0200
@@ -551,6 +551,8 @@
         ReturnNode retNode = null;
         StartNode entryPointNode = snippet.start();
         nodes = new ArrayList<>(snippet.getNodeCount());
+        boolean seenReturn = false;
+        boolean containsMemoryState = false;
         for (Node node : snippet.getNodes()) {
             if (node == entryPointNode || node == entryPointNode.stateAfter()) {
                 // Do nothing.
@@ -562,11 +564,14 @@
                         this.memoryMap = memstate.getMemoryMap();
                         memstate.safeDelete();
                     }
-                    assert snippet.getNodes().filter(ReturnNode.class).count() == 1;
+                    assert !seenReturn : "can handle only one ReturnNode";
+                    seenReturn = true;
+                } else if (node instanceof MemoryState) {
+                    containsMemoryState = true;
                 }
             }
         }
-        assert !containsMemoryState(snippet);
+        assert !containsMemoryState;
 
         this.sideEffectNodes = curSideEffectNodes;
         this.deoptNodes = curDeoptNodes;
@@ -577,10 +582,6 @@
         this.instantiationTimer = Debug.timer("SnippetInstantiationTime[" + method.getName() + "]");
     }
 
-    private static boolean containsMemoryState(StructuredGraph snippet) {
-        return snippet.getNodes().filter(MemoryState.class).count() > 0;
-    }
-
     private static boolean checkAllVarargPlaceholdersAreDeleted(int parameterCount, ConstantNode[] placeholders) {
         for (int i = 0; i < parameterCount; i++) {
             if (placeholders[i] != null) {
@@ -654,7 +655,7 @@
     private final ArrayList<Node> nodes;
 
     /**
-     * mapping of killing locations to memory checkpoints (nodes).
+     * map of killing locations to memory checkpoints (nodes).
      */
     private MemoryMap<Node> memoryMap;
 
@@ -771,11 +772,11 @@
 
                     // lastLocationAccess points into the snippet graph. find a proper
                     // MemoryCheckPoint inside the snippet graph
-                    FloatingReadNode frn = (FloatingReadNode) usage;
-                    Node newlla = mmap.getLastLocationAccess(frn.location().getLocationIdentity());
+                    FloatingReadNode read = (FloatingReadNode) usage;
+                    Node lastAccess = mmap.getLastLocationAccess(read.location().getLocationIdentity());
 
-                    assert newlla != null : "no mapping found for lowerable node " + oldNode + ". (No node in the snippet kill the same location as the lowerable node?)";
-                    frn.setLastLocationAccess(newlla);
+                    assert lastAccess != null : "no mapping found for lowerable node " + oldNode + ". (No node in the snippet kill the same location as the lowerable node?)";
+                    read.setLastLocationAccess(lastAccess);
                 }
             }
         }
@@ -804,7 +805,7 @@
         }
         assert !(replacee instanceof MemoryCheckpoint.Multi) : replacee + " multi not supported (yet)";
 
-        Debug.log("WARNING: %s is not a MemoryCheckpoint, but the snippet graph contains kills (%s). you might want %s to be a MemoryCheckpoint\n", replacee, kills, replacee);
+        Debug.log("WARNING: %s is not a MemoryCheckpoint, but the snippet graph contains kills (%s). You might want %s to be a MemoryCheckpoint", replacee, kills, replacee);
 
         // remove ANY_LOCATION if it's just a kill by the start node
         if (memoryMap.getLastLocationAccess(ANY_LOCATION) instanceof StartNode) {