Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/shenandoah/compiler/BarrierInInfiniteLoop.java
32285 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* @key gc28*29* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xcomp -XX:CompileOnly=BarrierInInfiniteLoop::test130* -XX:CompileOnly=BarrierInInfiniteLoop::test2 -XX:CompileOnly=BarrierInInfiniteLoop::test3 -XX:CompileCommand=quiet BarrierInInfiniteLoop31*32*/3334public class BarrierInInfiniteLoop {35private static Object field1 = new Object();36private static Object field2 = new Object();37private static int field3;3839public static void main(String[] args) {40test1(false);41test2(false, false);42test3(false);43}4445private static void test1(boolean flag) {46if (flag) {47for (;;) {48field1 = field2;49}50}51}5253private static void test2(boolean flag1, boolean flag2) {54if (flag1) {55for (;;) {56for (;;) {57if (flag2) {58break;59}60field1 = field2;61}62}63}64}6566private static void test3(boolean flag) {67if (flag) {68for (;;) {69for (;;) {70field3 = 42;71if (field1 == field2) {72break;73}74}75}76}77}78}798081