1 /*
2 * Copyright (c) 2019, Red Hat, Inc. 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 8231620
27 * @summary assert(bol->is_Bool()) crash during split if due to FastLockNode
28 *
29 * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement SplitIfSharedFastLockBehindCastPP
30 */
31
32
33 public class SplitIfSharedFastLockBehindCastPP {
34 private static boolean field;
35 private static A obj_field;
36
37 public static void main(String[] args) {
38 A lock = new A();
39 obj_field = lock;
40 for (int i = 0; i < 20_000; i++) {
41 test1(true, lock);
42 test1(false, lock);
43 test2(true);
44 test2(false);
45 }
46 }
47
48 private static void test1(boolean flag, Object obj) {
49 if (obj == null) {
50 }
51
52 boolean flag2;
53 if (flag) {
54 flag2 = true;
55 } else {
56 flag2 = false;
57 obj = obj_field;
58 }
59
60 // This loop will be unswitched. The condition becomes candidate for split if
61 for (int i = 0; i < 100; i++) {
62 if (flag2) {
63 field = true;
64 } else {
65 field = false;
66 }
67 synchronized (obj) {
68 field = true;
69 }
70 }
71 }
72
73 private static Object test2(boolean flag) {
74 int integer;
75 if (flag) {
76 field = true;
77 integer = 1;
78 } else {
79 field = false;
80 integer = 2;
81 }
82
83 Object obj = integer;
84
85 // This loop will be unswitched. The condition becomes candidate for split if
86 for (int i = 0; i < 100; i++) {
87 if (integer == 1) {
88 field = true;
89 } else {
90 field = false;
91 }
92 synchronized (obj) {
93 field = true;
94 }
95 }
96 return obj;
97 }
98
99 private static final class A {
100 }
101 }
--- EOF ---