# HG changeset patch # User Bernhard Urban # Date 1380120903 -7200 # Node ID 82c4106741f77f0f244652e0447683aad438d174 # Parent 63ee8dea4b80d8d7ce7df2fb7d9b25a0c9c84ff3 SnippetTemplate: avoid two getNodes() in assertions. comment fix and renames diff -r 63ee8dea4b80 -r 82c4106741f7 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- 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 nodes; /** - * mapping of killing locations to memory checkpoints (nodes). + * map of killing locations to memory checkpoints (nodes). */ private MemoryMap 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) {