author | alanb |
Thu, 01 Dec 2016 15:54:39 +0000 | |
changeset 42309 | 21f9f3fbc302 |
parent 40059 | c2304140ed64 |
permissions | -rw-r--r-- |
30629
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
1 |
/* |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
4 |
* |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
8 |
* |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
13 |
* accompanied this code). |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
14 |
* |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
18 |
* |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
21 |
* questions. |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
22 |
*/ |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
23 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
24 |
/* |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
25 |
* @test |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
26 |
* @bug 8076188 |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
27 |
* @summary arraycopy to non escaping destination may be eliminated |
40059 | 28 |
* @library / |
29 |
* |
|
30 |
* @run main/othervm -ea -XX:-BackgroundCompilation -XX:-UseOnStackReplacement |
|
31 |
* -XX:CompileCommand=dontinline,compiler.arraycopy.TestEliminateArrayCopy*::m* |
|
32 |
* compiler.arraycopy.TestEliminateArrayCopy |
|
30629
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
33 |
* |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
34 |
*/ |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
35 |
|
40059 | 36 |
package compiler.arraycopy; |
37 |
||
30629
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
38 |
public class TestEliminateArrayCopy { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
39 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
40 |
static class CloneTests extends TestInstanceCloneUtils { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
41 |
// object allocation and ArrayCopyNode should be eliminated |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
42 |
static void m1(E src) throws CloneNotSupportedException { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
43 |
src.clone(); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
44 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
45 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
46 |
// both object allocations and ArrayCopyNode should be eliminated |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
47 |
static void m2(Object dummy) throws CloneNotSupportedException { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
48 |
E src = new E(false); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
49 |
src.clone(); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
50 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
51 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
52 |
// object allocation and ArrayCopyNode should be eliminated. Fields should be loaded from src. |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
53 |
static int m3(E src) throws CloneNotSupportedException { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
54 |
E dest = (E)src.clone(); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
55 |
return dest.i1 + dest.i2 + dest.i3 + dest.i4 + dest.i5 + |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
56 |
dest.i6 + dest.i7 + dest.i8 + dest.i9; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
57 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
58 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
59 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
60 |
static class ArrayCopyTests extends TestArrayCopyUtils { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
61 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
62 |
// object allocation and ArrayCopyNode should be eliminated. |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
63 |
@Args(src=ArraySrc.LARGE) |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
64 |
static int m1() throws CloneNotSupportedException { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
65 |
int[] array_clone = (int[])large_int_src.clone(); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
66 |
return array_clone[0] + array_clone[1] + array_clone[2] + |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
67 |
array_clone[3] + array_clone[4] + array_clone[5] + |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
68 |
array_clone[6] + array_clone[7] + array_clone[8] + |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
69 |
array_clone[9]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
70 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
71 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
72 |
// object allocation and ArrayCopyNode should be eliminated. |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
73 |
@Args(src=ArraySrc.LARGE) |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
74 |
static int m2() { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
75 |
int[] dest = new int[10]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
76 |
System.arraycopy(large_int_src, 0, dest, 0, 10); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
77 |
return dest[0] + dest[1] + dest[2] + dest[3] + dest[4] + |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
78 |
dest[5] + dest[6] + dest[7] + dest[8] + dest[9]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
79 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
80 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
81 |
// object allocations and ArrayCopyNodes should be eliminated. |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
82 |
@Args(src=ArraySrc.LARGE) |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
83 |
static int m3() { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
84 |
int[] dest1 = new int[10]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
85 |
System.arraycopy(large_int_src, 0, dest1, 0, 10); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
86 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
87 |
int[] dest2 = new int[10]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
88 |
System.arraycopy(dest1, 0, dest2, 0, 10); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
89 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
90 |
return dest2[0] + dest2[1] + dest2[2] + dest2[3] + dest2[4] + |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
91 |
dest2[5] + dest2[6] + dest2[7] + dest2[8] + dest2[9]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
92 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
93 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
94 |
static class m4_class { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
95 |
Object f; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
96 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
97 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
98 |
static void m4_helper() {} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
99 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
100 |
// allocations eliminated and arraycopy optimized out |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
101 |
@Args(src=ArraySrc.LARGE) |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
102 |
static int m4() { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
103 |
int[] dest = new int[10]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
104 |
m4_class o = new m4_class(); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
105 |
o.f = dest; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
106 |
m4_helper(); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
107 |
System.arraycopy(large_int_src, 0, o.f, 0, 10); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
108 |
return dest[0] + dest[1] + dest[2] + dest[3] + dest[4] + |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
109 |
dest[5] + dest[6] + dest[7] + dest[8] + dest[9]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
110 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
111 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
112 |
static void m5_helper() {} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
113 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
114 |
// Small copy cannot be converted to loads/stores because |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
115 |
// allocation is not close enough to arraycopy but arraycopy |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
116 |
// itself can be eliminated |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
117 |
@Args(src=ArraySrc.SMALL, dst=ArrayDst.NEW) |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
118 |
static void m5(A[] src, A[] dest) { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
119 |
A[] temp = new A[5]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
120 |
m5_helper(); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
121 |
System.arraycopy(src, 0, temp, 0, 5); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
122 |
dest[0] = temp[0]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
123 |
dest[1] = temp[1]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
124 |
dest[2] = temp[2]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
125 |
dest[3] = temp[3]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
126 |
dest[4] = temp[4]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
127 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
128 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
129 |
// object allocation and ArrayCopyNode should be eliminated. |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
130 |
@Args(src=ArraySrc.LARGE) |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
131 |
static int m6(int [] src) { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
132 |
int res = src[0] + src[1] + src[2] + src[3] + src[4] + |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
133 |
src[5] + src[6] + src[7] + src[8] + src[9]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
134 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
135 |
int[] dest = new int[10]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
136 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
137 |
System.arraycopy(src, 0, dest, 0, 10); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
138 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
139 |
res += dest[0] + dest[1] + dest[2] + dest[3] + dest[4] + |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
140 |
dest[5] + dest[6] + dest[7] + dest[8] + dest[9]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
141 |
return res/2; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
142 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
143 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
144 |
@Args(src=ArraySrc.LARGE) |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
145 |
static int m7() { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
146 |
int[] dest = new int[10]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
147 |
dest[0] = large_int_src[8]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
148 |
dest[1] = large_int_src[9]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
149 |
System.arraycopy(large_int_src, 0, dest, 2, 8); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
150 |
return dest[0] + dest[1] + dest[2] + dest[3] + dest[4] + |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
151 |
dest[5] + dest[6] + dest[7] + dest[8] + dest[9]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
152 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
153 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
154 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
155 |
// test that OptimizePtrCompare still works |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
156 |
static final Object[] m1_array = new Object[10]; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
157 |
static boolean m1_array_null_element = false; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
158 |
static void m1(int i) { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
159 |
Object[] array_clone = (Object[])m1_array.clone(); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
160 |
if (array_clone[i] == null) { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
161 |
m1_array_null_element = true; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
162 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
163 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
164 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
165 |
static public void main(String[] args) throws Exception { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
166 |
CloneTests clone_tests = new CloneTests(); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
167 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
168 |
clone_tests.doTest(clone_tests.e, "m1"); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
169 |
clone_tests.doTest(null, "m2"); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
170 |
clone_tests.doTest(clone_tests.e, "m3"); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
171 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
172 |
ArrayCopyTests ac_tests = new ArrayCopyTests(); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
173 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
174 |
ac_tests.doTest("m1"); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
175 |
ac_tests.doTest("m2"); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
176 |
ac_tests.doTest("m3"); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
177 |
ac_tests.doTest("m4"); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
178 |
ac_tests.doTest("m5"); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
179 |
ac_tests.doTest("m6"); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
180 |
ac_tests.doTest("m7"); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
181 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
182 |
if (!clone_tests.success || !ac_tests.success) { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
183 |
throw new RuntimeException("some tests failed"); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
184 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
185 |
|
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
186 |
// Make sure both branches of the if in m1() appear taken |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
187 |
for (int i = 0; i < 7000; i++) { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
188 |
m1(0); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
189 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
190 |
m1_array[0] = new Object(); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
191 |
for (int i = 0; i < 20000; i++) { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
192 |
m1(0); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
193 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
194 |
m1_array_null_element = false; |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
195 |
m1(0); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
196 |
if (m1_array_null_element) { |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
197 |
throw new RuntimeException("OptimizePtrCompare test failed"); |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
198 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
199 |
} |
b6e5ad2f18d5
8076188: Optimize arraycopy out for non escaping destination
roland
parents:
diff
changeset
|
200 |
} |