changeset 7513:9b2262afcb0d

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 22 Jan 2013 16:54:50 +0100
parents 4c269aec7d62 (current diff) b5316e551965 (diff)
children 6bf569d50989
files
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 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;
--- 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));
             }
         }