# HG changeset patch # User Thomas Wuerthinger # Date 1358870090 -3600 # Node ID 9b2262afcb0dce60747148eab6226ac400759ef4 # Parent 4c269aec7d62eff884349223f25b6adf814fcb2a# Parent b5316e5519656b6e210ebeef5054a511c6291b0b Merge. diff -r 4c269aec7d62 -r 9b2262afcb0d 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 Tue Jan 22 16:54:40 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/ArrayCopyIntrinsificationTest.java Tue Jan 22 16:54:50 2013 +0100 @@ -88,6 +88,8 @@ // Array store checks test("genericArraycopy", new Object(), 0, new Object[0], 0, 0); test("genericArraycopy", new Object[0], 0, new Object(), 0, 0); + + mustIntrinsify = true; } @Test @@ -146,8 +148,18 @@ @Test public void testObject() { + mustIntrinsify = false; // a generic call to arraycopy will not be intrinsified + Object[] src = {"one", "two", "three", new ArrayList<>(), new HashMap<>()}; testHelper("objectArraycopy", src); + + mustIntrinsify = true; + } + + @Test + public void testObjectExact() { + Integer[] src = {1, 2, 3, 4}; + testHelper("objectArraycopyExact", src); } private static Object newArray(Object proto, int length) { @@ -180,6 +192,11 @@ return dst; } + public static Object[] objectArraycopyExact(Integer[] src, int srcPos, Integer[] 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 4c269aec7d62 -r 9b2262afcb0d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ArrayCopyNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ArrayCopyNode.java Tue Jan 22 16:54:40 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ArrayCopyNode.java Tue Jan 22 16:54:50 2013 +0100 @@ -65,9 +65,11 @@ ResolvedJavaType destType = dest().objectStamp().type(); if (srcType != null && srcType.isArray() && destType != null && destType.isArray()) { Kind componentKind = srcType.getComponentType().getKind(); - if (srcType.getComponentType() == destType.getComponentType()) { - snippetMethod = tool.getRuntime().lookupJavaMethod(ArrayCopySnippets.getSnippetForKind(componentKind)); - } else if (componentKind == Kind.Object && destType.getComponentType().isAssignableFrom(srcType.getComponentType())) { + if (componentKind != Kind.Object) { + if (srcType.getComponentType() == destType.getComponentType()) { + snippetMethod = tool.getRuntime().lookupJavaMethod(ArrayCopySnippets.getSnippetForKind(componentKind)); + } + } else if (destType.getComponentType().isAssignableFrom(srcType.getComponentType()) && dest().objectStamp().isExactType()) { snippetMethod = tool.getRuntime().lookupJavaMethod(ArrayCopySnippets.getSnippetForKind(Kind.Object)); } }