# HG changeset patch # User Doug Simon # Date 1431100264 -7200 # Node ID d2f31470806719b9e9c6e1a45359f673903bbef5 # Parent b2e0a485daf08c39555f350ff6dd05c0f5acf4d5 added extra test for arraycopy snippet using StubRoutines::_checkcast_arraycopy diff -r b2e0a485daf0 -r d2f314708067 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ArrayCopyIntrinsificationTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ArrayCopyIntrinsificationTest.java Fri May 08 17:47:28 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ArrayCopyIntrinsificationTest.java Fri May 08 17:51:04 2015 +0200 @@ -31,6 +31,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.graph.*; +import com.oracle.graal.hotspot.replacements.arraycopy.*; import com.oracle.graal.nodes.*; /** @@ -52,9 +53,14 @@ Assert.assertTrue(invoke.callTarget() instanceof DirectCallTargetNode); LoweredCallTargetNode directCall = (LoweredCallTargetNode) invoke.callTarget(); JavaMethod callee = directCall.targetMethod(); - Assert.assertTrue(callee.getName().equals("")); - Assert.assertTrue(getMetaAccess().lookupJavaType(ArrayIndexOutOfBoundsException.class).equals(callee.getDeclaringClass()) || - getMetaAccess().lookupJavaType(NullPointerException.class).equals(callee.getDeclaringClass())); + if (callee.getDeclaringClass().equals(getMetaAccess().lookupJavaType(System.class)) && callee.getName().equals("arraycopy")) { + // A partial snippet (e.g., ArrayCopySnippets.checkcastArraycopy) may + // call the original arraycopy method + } else { + Assert.assertTrue(callee.toString(), callee.getName().equals("")); + Assert.assertTrue(getMetaAccess().lookupJavaType(ArrayIndexOutOfBoundsException.class).equals(callee.getDeclaringClass()) || + getMetaAccess().lookupJavaType(NullPointerException.class).equals(callee.getDeclaringClass())); + } } } } else { @@ -145,25 +151,28 @@ @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; + /** + * Tests {@link ArrayCopySnippets#checkcastArraycopySnippet}. + */ + @Test + public void testArrayStoreException() { + Object[] src = {"one", "two", "three", new ArrayList<>(), new HashMap<>()}; + Object[] dst = new CharSequence[src.length]; + // Will throw ArrayStoreException for 4th element + test("objectArraycopy", src, 0, dst, 0, src.length); } @Test public void testDisjointObject() { - mustIntrinsify = false; // a generic call to arraycopy will not be intrinsified - Integer[] src1 = {1, 2, 3, 4}; test("objectArraycopy", src1, 0, src1, 1, src1.length - 1); Integer[] src2 = {1, 2, 3, 4}; test("objectArraycopy", src2, 1, src2, 0, src2.length - 1); - - mustIntrinsify = true; } @Test