diff graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetTemplate.java @ 7271:9c06e8bd8769

added phase to remove unnecessary frame states from substitution snippets fixed debug scope used for snippet installation to capture all phases of installing a specific snippet with a filter (i.e. -G:MethodFilter) set for that snippet
author Doug Simon <doug.simon@oracle.com>
date Tue, 18 Dec 2012 17:32:44 +0100
parents c85aecfee9e4
children 2912b72d840a dc3e86fd3be1
line wrap: on
line diff
--- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetTemplate.java	Tue Dec 18 15:28:15 2012 +0100
+++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetTemplate.java	Tue Dec 18 17:32:44 2012 +0100
@@ -208,7 +208,9 @@
                 throw new GraalInternalError(e);
             }
         }
-}
+    }
+
+    private static final Object UNUSED_PARAMETER = "DEAD PARAMETER";
 
     /**
      * Determines if any parameter of a given method is annotated with {@link ConstantParameter}.
@@ -315,8 +317,12 @@
                 Parameter p = parameterAnnotations[i];
                 if (p != null) {
                     LocalNode local = snippetCopy.getLocal(i);
-                    assert local != null;
-                    parameters.put(p.value(), local);
+                    if (local == null) {
+                        // Parameter value was eliminated
+                        parameters.put(p.value(), UNUSED_PARAMETER);
+                    } else {
+                        parameters.put(p.value(), local);
+                    }
                 }
             }
         }
@@ -431,7 +437,9 @@
 
     /**
      * The named parameters of this template that must be bound to values during instantiation.
-     * Each value in this map is either a {@link LocalNode} instance or a {@link LocalNode} array.
+     * For a parameter that is still live after specialization, the value in this map is either
+     * a {@link LocalNode} instance or a {@link LocalNode} array. For an eliminated parameter,
+     * the value is identical to the key.
      */
     private final Map<String, Object> parameters;
 
@@ -477,8 +485,7 @@
                     Constant constant = Constant.forBoxed(kind, argument);
                     replacements.put((LocalNode) parameter, ConstantNode.forConstant(constant, runtime, replaceeGraph));
                 }
-            } else {
-                assert parameter instanceof LocalNode[];
+            } else if (parameter instanceof LocalNode[]) {
                 LocalNode[] locals = (LocalNode[]) parameter;
                 Object array = argument;
                 assert array != null && array.getClass().isArray();
@@ -496,6 +503,8 @@
                         replacements.put(local, element);
                     }
                 }
+            } else {
+                assert parameter == UNUSED_PARAMETER : "unexpected entry for parameter: " + name + " -> " + parameter;
             }
         }
         return replacements;
@@ -673,7 +682,9 @@
             Object value = e.getValue();
             buf.append(sep);
             sep = ", ";
-            if (value instanceof LocalNode) {
+            if (value == UNUSED_PARAMETER)  {
+                buf.append("<unused> ").append(name);
+            } else if (value instanceof LocalNode) {
                 LocalNode local = (LocalNode) value;
                 buf.append(local.kind().getJavaName()).append(' ').append(name);
             } else {