Path: blob/master/test/hotspot/jtreg/gc/shenandoah/compiler/BarrierInInfiniteLoop.java
41153 views
/*1* Copyright (c) 2020, Red Hat, Inc. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 8237837 824472126* @summary Shenandoah: assert(mem == __null) failed: only one safepoint27* @requires vm.flavor == "server"28* @requires vm.gc.Shenandoah29*30* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xcomp -XX:CompileOnly=BarrierInInfiniteLoop::test131* -XX:CompileOnly=BarrierInInfiniteLoop::test2 -XX:CompileOnly=BarrierInInfiniteLoop::test3 -XX:CompileCommand=quiet BarrierInInfiniteLoop32* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -Xcomp -XX:CompileOnly=BarrierInInfiniteLoop::test133* -XX:CompileOnly=BarrierInInfiniteLoop::test2 -XX:CompileOnly=BarrierInInfiniteLoop::test3 -XX:CompileCommand=quiet BarrierInInfiniteLoop34*35*/3637public class BarrierInInfiniteLoop {38private static Object field1 = new Object();39private static Object field2 = new Object();40private static int field3;4142public static void main(String[] args) {43test1(false);44test2(false, false);45test3(false);46}4748private static void test1(boolean flag) {49if (flag) {50for (;;) {51field1 = field2;52}53}54}5556private static void test2(boolean flag1, boolean flag2) {57if (flag1) {58for (;;) {59for (;;) {60if (flag2) {61break;62}63field1 = field2;64}65}66}67}6869private static void test3(boolean flag) {70if (flag) {71for (;;) {72for (;;) {73field3 = 42;74if (field1 == field2) {75break;76}77}78}79}80}81}828384