From fea1abd660cc89b31d121c8700fae8d804178391 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Wed, 6 Jul 2016 12:09:12 +0100 Subject: Implement System.arraycopy intrinsic on x86. Also remove wrong comments when doing the raw copying. test:run-test, 537-checker-arraycopy, 610-arraycopy Change-Id: I2495bc03cde8ccad03c93f7722dd29bf85138525 --- test/537-checker-arraycopy/src/Main.java | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'test/537-checker-arraycopy/src') diff --git a/test/537-checker-arraycopy/src/Main.java b/test/537-checker-arraycopy/src/Main.java index 30ccc56b80..7c124caa8e 100644 --- a/test/537-checker-arraycopy/src/Main.java +++ b/test/537-checker-arraycopy/src/Main.java @@ -50,7 +50,7 @@ public class Main { } /// CHECK-START-X86_64: void Main.arraycopy() disassembly (after) - /// CHECK: InvokeStaticOrDirect + /// CHECK: InvokeStaticOrDirect intrinsic:SystemArrayCopy /// CHECK-NOT: test /// CHECK-NOT: call /// CHECK: ReturnVoid @@ -65,7 +65,36 @@ public class Main { System.arraycopy(obj, 1, obj, 0, 1); } + // Test case for having enough registers on x86 for the arraycopy intrinsic. + /// CHECK-START-X86: void Main.arraycopy(java.lang.Object[], int) disassembly (after) + /// CHECK: InvokeStaticOrDirect intrinsic:SystemArrayCopy + /// CHECK-NOT: mov {{[a-z]+}}, [esp + {{[0-9]+}}] + /// CHECK: ReturnVoid public static void arraycopy(Object[] obj, int pos) { System.arraycopy(obj, pos, obj, 0, obj.length); } + + // Test case for having enough registers on x86 for the arraycopy intrinsic + // when an input is passed twice. + /// CHECK-START-X86: int Main.arraycopy2(java.lang.Object[], int) disassembly (after) + /// CHECK: InvokeStaticOrDirect intrinsic:SystemArrayCopy + /// CHECK-NOT: mov {{[a-z]+}}, [esp + {{[0-9]+}}] + /// CHECK: Return + public static int arraycopy2(Object[] obj, int pos) { + System.arraycopy(obj, pos, obj, pos - 1, obj.length); + return pos; + } + + // Test case for not having enough registers on x86. The arraycopy intrinsic + // will ask for length to be in stack and load it. + /// CHECK-START-X86: int Main.arraycopy3(java.lang.Object[], java.lang.Object[], int, int, int) disassembly (after) + /// CHECK: InvokeStaticOrDirect intrinsic:SystemArrayCopy + /// CHECK: mov {{[a-z]+}}, [esp + {{[0-9]+}}] + /// CHECK: Return + public static int arraycopy3(Object[] obj1, Object[] obj2, int input1, int input3, int input4) { + System.arraycopy(obj1, input1, obj2, input3, input4); + System.out.println(obj1); + System.out.println(obj2); + return input1 + input3 + input4; + } } -- cgit v1.2.3-59-g8ed1b