# HG changeset patch # User Doug Simon # Date 1427995319 -7200 # Node ID 80fda5775d0c6f94ddd00b86fa489cfa31d53b32 # Parent 921eeb012866f1033babdf5c45e54d7bbd25b12f folding a TypeCheckNode can only be done if the stamp of the input object denotes an exact type diff -r 921eeb012866 -r 80fda5775d0c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeCheckNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeCheckNode.java Thu Apr 02 17:32:26 2015 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeCheckNode.java Thu Apr 02 19:21:59 2015 +0200 @@ -100,7 +100,8 @@ return result; } if (type().equals(inputType)) { - if (!nonNull) { + boolean mightBeNull = !nonNull; + if (exactType && mightBeNull) { // the instanceof matches if the object is non-null, so return true // depending on the null-ness. return LogicNegationNode.create(new IsNullNode(forValue)); @@ -114,7 +115,7 @@ return null; } if (type.equals(inputType)) { - if (nonNull) { + if (nonNull && exactType) { // the type matches, so return true return LogicConstantNode.tautology(); } diff -r 921eeb012866 -r 80fda5775d0c graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/InstanceOfTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/InstanceOfTest.java Thu Apr 02 17:32:26 2015 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/InstanceOfTest.java Thu Apr 02 19:21:59 2015 +0200 @@ -396,4 +396,20 @@ test("isArrayOfD", cArray); test("isArrayOfD", dArray); } + + @SuppressWarnings("unchecked") + public static String arrayCopyTypeName(T[] original) { + Class newType = (Class) original.getClass(); + if (newType == (Object) Object[].class) { + return Object[].class.getName(); + } else { + return newType.getName(); + } + } + + @Test + public void testArrayCopy() { + test("arrayCopyTypeName", (Object) new Object[]{"one", "two", "three"}); + test("arrayCopyTypeName", (Object) new String[]{"one", "two", "three"}); + } }