# HG changeset patch # User Doug Simon # Date 1339535142 -7200 # Node ID 13624e51918ac5e698e589d4f1b3e706b37f4925 # Parent f5cfb62f17b8ee67fdff5019350a75b8e22df9f5 allow null for @ConstantParameter values diff -r f5cfb62f17b8 -r 13624e51918a graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetTemplate.java --- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetTemplate.java Tue Jun 12 22:59:40 2012 +0200 +++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetTemplate.java Tue Jun 12 23:05:42 2012 +0200 @@ -68,10 +68,12 @@ } public Key add(String name, Object value) { - assert value != null; assert !map.containsKey(name); map.put(name, value); - hash = hash ^ name.hashCode() * (value.hashCode() + 1); + hash = hash ^ name.hashCode(); + if (value != null) { + hash *= (value.hashCode() + 1); + } return this; } @@ -194,7 +196,6 @@ if (c != null) { String name = c.value(); Object arg = key.get(name); - assert arg != null : method + ": requires a constant named " + name; Kind kind = signature.argumentKindAt(i); assert checkConstantArgument(method, signature, i, name, arg, kind); replacements.put(snippetGraph.getLocal(i), ConstantNode.forConstant(Constant.forBoxed(kind, arg), runtime, snippetCopy)); @@ -327,11 +328,11 @@ private static boolean checkConstantArgument(final ResolvedJavaMethod method, Signature signature, int i, String name, Object arg, Kind kind) { if (kind.isObject()) { Class type = signature.argumentTypeAt(i, method.holder()).resolve(method.holder()).toJava(); - assert type.isInstance(arg) : + assert arg == null || type.isInstance(arg) : method + ": wrong value type for " + name + ": expected " + type.getName() + ", got " + arg.getClass().getName(); } else { - assert kind.toBoxedJavaClass() == arg.getClass() : - method + ": wrong value kind for " + name + ": expected " + kind + ", got " + arg.getClass().getSimpleName(); + assert arg != null && kind.toBoxedJavaClass() == arg.getClass() : + method + ": wrong value kind for " + name + ": expected " + kind + ", got " + (arg == null ? "null" : arg.getClass().getSimpleName()); } return true; }