# HG changeset patch # User Doug Simon # Date 1357948509 -3600 # Node ID 11a9f50f34e467ce667ff2f08c748547e51b096c # Parent 62554b96c6827743cb4fa932cadb3732b5570dd1 reverted recent changes to arraycopy intrinsification diff -r 62554b96c682 -r 11a9f50f34e4 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/ArrayCopyIntrinsificationTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/ArrayCopyIntrinsificationTest.java Sat Jan 12 00:49:20 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/ArrayCopyIntrinsificationTest.java Sat Jan 12 00:55:09 2013 +0100 @@ -153,24 +153,9 @@ } @Test - public void testObjectExact() { + public void testObject() { Object[] src = {"one", "two", "three", new ArrayList<>(), new HashMap<>()}; - test("exactObjectArraycopy", (Object) src); - } - - @Test - public void testString() { - String[] src = {"one", "two", "three"}; - test("stringArraycopy", src, 0, new String[src.length], 0, src.length); - } - - @Test - public void testObject() { - mustIntrinsify = false; // a call to arraycopy where dest is not an exact type will not be intrinsified - Object[] src = {"one", "two", "three", new ArrayList<>(), new HashMap<>()}; - test("objectArraycopy", src, 0, new Object[src.length], 0, src.length); - // Expect ArrayStoreException - test("objectArraycopy", src, 0, new String[src.length], 0, src.length); + testHelper("objectArraycopy", src); } private static Object newArray(Object proto, int length) { @@ -203,17 +188,6 @@ return dst; } - public static Object[] exactObjectArraycopy(Object[] src) { - Object[] dst = new Object[src.length]; - System.arraycopy(src, 0, dst, 0, src.length); - return dst; - } - - public static Object[] stringArraycopy(String[] src, int srcPos, String[] dst, int dstPos, int length) { - System.arraycopy(src, srcPos, dst, dstPos, length); - return dst; - } - public static boolean[] booleanArraycopy(boolean[] src, int srcPos, boolean[] dst, int dstPos, int length) { System.arraycopy(src, srcPos, dst, dstPos, length); return dst; diff -r 62554b96c682 -r 11a9f50f34e4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/IntrinsifyArrayCopyPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/IntrinsifyArrayCopyPhase.java Sat Jan 12 00:49:20 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/IntrinsifyArrayCopyPhase.java Sat Jan 12 00:55:09 2013 +0100 @@ -31,7 +31,6 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; @@ -83,33 +82,34 @@ ValueNode src = methodCallTarget.arguments().get(0); ValueNode dest = methodCallTarget.arguments().get(2); assert src != null && dest != null; - ObjectStamp srcStamp = src.objectStamp(); - ObjectStamp destStamp = dest.objectStamp(); - ResolvedJavaType srcType = srcStamp.type(); - ResolvedJavaType destType = destStamp.type(); + ResolvedJavaType srcType = src.objectStamp().type(); + ResolvedJavaType destType = dest.objectStamp().type(); if (srcType != null && srcType.isArray() && destType != null && destType.isArray()) { Kind componentKind = srcType.getComponentType().getKind(); - if (componentKind != Kind.Object) { - if (srcType.getComponentType() == destType.getComponentType()) { - if (componentKind == Kind.Int) { - snippetMethod = intArrayCopy; - } else if (componentKind == Kind.Char) { - snippetMethod = charArrayCopy; - } else if (componentKind == Kind.Long) { - snippetMethod = longArrayCopy; - } else if (componentKind == Kind.Byte) { - snippetMethod = byteArrayCopy; - } else if (componentKind == Kind.Short) { - snippetMethod = shortArrayCopy; - } else if (componentKind == Kind.Float) { - snippetMethod = floatArrayCopy; - } else if (componentKind == Kind.Double) { - snippetMethod = doubleArrayCopy; - } + if (srcType.getComponentType() == destType.getComponentType()) { + if (componentKind == Kind.Int) { + snippetMethod = intArrayCopy; + } else if (componentKind == Kind.Char) { + snippetMethod = charArrayCopy; + } else if (componentKind == Kind.Long) { + snippetMethod = longArrayCopy; + } else if (componentKind == Kind.Byte) { + snippetMethod = byteArrayCopy; + } else if (componentKind == Kind.Short) { + snippetMethod = shortArrayCopy; + } else if (componentKind == Kind.Float) { + snippetMethod = floatArrayCopy; + } else if (componentKind == Kind.Double) { + snippetMethod = doubleArrayCopy; + } else if (componentKind == Kind.Object) { + snippetMethod = objectArrayCopy; } + } else if (componentKind == Kind.Object + && destType.getComponentType().isAssignableFrom(srcType.getComponentType())) { + snippetMethod = objectArrayCopy; } } }