Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/shenandoah/compiler/LRBRightAfterMemBar.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 823700726* @summary Shenandoah: assert(_base == Tuple) failure during C2 compilation27* @key gc28*29* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-BackgroundCompilation -XX:+UseShenandoahGC LRBRightAfterMemBar30*31*/3233public class LRBRightAfterMemBar {34private static Object field1;35private static Object field2;36static volatile int barrier;3738public static void main(String[] args) {39for (int i = 0; i < 20_000; i++) {40test(true, true, new Object());41test(false, false, new Object());42}43}4445private static Object test(boolean flag, boolean flag2, Object o2) {46for (int i = 0; i < 10; i++) {47barrier = 0x42; // Membar48if (o2 == null) { // hoisted out of loop49}50// The following line is converted to a CMove with an out51// of loop control once the null check above is52// hoisted. The CMove is pinned right after the membar and53// assigned the membar as control.54Object o = flag ? field1 : field2;55if (flag2) {56return o;57}58}5960return null;61}62}636465