|
1 /* |
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 */ |
|
23 |
|
24 /* |
|
25 * @test |
|
26 * @bug 8055153 |
|
27 * @summary missing control on LoadRange and LoadKlass when array copy macro node is expanded |
|
28 * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:-TieredCompilation TestMissingControl |
|
29 * |
|
30 */ |
|
31 public class TestMissingControl { |
|
32 |
|
33 static int[] m1(int[] a2) { |
|
34 int[] a1 = new int[10]; |
|
35 System.arraycopy(a1, 0, a2, 0, 10); |
|
36 return a1; |
|
37 } |
|
38 |
|
39 static class A { |
|
40 } |
|
41 |
|
42 static Object m2(Object[] a2) { |
|
43 A[] a1 = new A[10]; |
|
44 System.arraycopy(a1, 0, a2, 0, 10); |
|
45 return a1; |
|
46 } |
|
47 |
|
48 static void test1() { |
|
49 int[] a2 = new int[10]; |
|
50 int[] a3 = new int[5]; |
|
51 |
|
52 // compile m1 with arraycopy intrinsified |
|
53 for (int i = 0; i < 20000; i++) { |
|
54 m1(a2); |
|
55 } |
|
56 |
|
57 // make m1 trap |
|
58 for (int i = 0; i < 10; i++) { |
|
59 try { |
|
60 m1(a3); |
|
61 } catch(IndexOutOfBoundsException ioobe) { |
|
62 } |
|
63 } |
|
64 |
|
65 // recompile m1 |
|
66 for (int i = 0; i < 20000; i++) { |
|
67 m1(a2); |
|
68 } |
|
69 |
|
70 try { |
|
71 m1(null); |
|
72 } catch(NullPointerException npe) {} |
|
73 } |
|
74 |
|
75 static void test2() { |
|
76 A[] a2 = new A[10]; |
|
77 A[] a3 = new A[5]; |
|
78 |
|
79 // compile m2 with arraycopy intrinsified |
|
80 for (int i = 0; i < 20000; i++) { |
|
81 m2(a2); |
|
82 } |
|
83 |
|
84 // make m2 trap |
|
85 for (int i = 0; i < 10; i++) { |
|
86 try { |
|
87 m2(a3); |
|
88 } catch(IndexOutOfBoundsException ioobe) { |
|
89 } |
|
90 } |
|
91 |
|
92 // recompile m2 |
|
93 for (int i = 0; i < 20000; i++) { |
|
94 m2(a2); |
|
95 } |
|
96 |
|
97 try { |
|
98 m2(null); |
|
99 } catch(NullPointerException npe) {} |
|
100 } |
|
101 |
|
102 static public void main(String[] args) { |
|
103 test1(); |
|
104 test2(); |
|
105 } |
|
106 } |