Mercurial > hg > graal-compiler
changeset 7511:b5316e551965
reapply fix from 8f7be0c45a82
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Tue, 22 Jan 2013 15:08:08 +0100 |
parents | 225002aba5a5 |
children | 9b2262afcb0d |
files | graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/ArrayCopyIntrinsificationTest.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ArrayCopyNode.java |
diffstat | 2 files changed, 22 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/ArrayCopyIntrinsificationTest.java Tue Jan 22 11:29:40 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/ArrayCopyIntrinsificationTest.java Tue Jan 22 15:08:08 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;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ArrayCopyNode.java Tue Jan 22 11:29:40 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ArrayCopyNode.java Tue Jan 22 15:08:08 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)); } }