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.
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 }
|
1 /*
2 * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
54 if (flag) {
55 flag2 = true;
56 } else {
57 flag2 = false;
58 obj = obj_field;
59 }
60
61 // This loop will be unswitched. The condition becomes candidate for split if
62 for (int i = 0; i < 100; i++) {
63 if (flag2) {
64 field = true;
65 } else {
66 field = false;
67 }
68 synchronized (obj) {
69 field = true;
70 }
71 }
72 }
73
74 static class MyBox {
75 int val;
76
77 public MyBox(int val) {
78 this.val = val;
79 }
80 }
81
82 private static Object test2(boolean flag) {
83 int integer;
84 if (flag) {
85 field = true;
86 integer = 1;
87 } else {
88 field = false;
89 integer = 2;
90 }
91
92 Object obj = new MyBox(integer);
93
94 // This loop will be unswitched. The condition becomes candidate for split if
95 for (int i = 0; i < 100; i++) {
96 if (integer == 1) {
97 field = true;
98 } else {
99 field = false;
100 }
101 synchronized (obj) {
102 field = true;
103 }
104 }
105 return obj;
106 }
107
108 private static final class A {
109 }
110 }
|