Path: blob/master/test/hotspot/jtreg/gc/shenandoah/compiler/LRBRightAfterMemBar.java
41155 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 8237007 826063726* @summary Shenandoah: assert(_base == Tuple) failure during C2 compilation27* @requires vm.flavor == "server"28* @requires vm.gc.Shenandoah29*30* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-BackgroundCompilation -XX:+UseShenandoahGC LRBRightAfterMemBar31*32*/3334public class LRBRightAfterMemBar {35private static A field1;36private static Object field2;37static volatile int barrier;3839public static void main(String[] args) {40for (int i = 0; i < 20_000; i++) {41test1(true, true, new Object());42test1(false, false, new Object());43test2(new Object(), 0, 10);44}45}4647private static Object test1(boolean flag, boolean flag2, Object o2) {48for (int i = 0; i < 10; i++) {49barrier = 0x42; // Membar50if (o2 == null) { // hoisted out of loop51}52// The following line is converted to a CMove with an out53// of loop control once the null check above is54// hoisted. The CMove is pinned right after the membar and55// assigned the membar as control.56Object o = flag ? field1 : field2;57if (flag2) {58return o;59}60}6162return null;63}6465private static int test2(Object o2, int start, int stop) {66A a1 = null;67A a2 = null;68int v = 0;69for (int i = start; i < stop; i++) {70a2 = new A();71a1 = new A();72a1.a = a2;73barrier = 0x42; // Membar74if (o2 == null) { // hoisted out of loop75}76A a3 = a1.a;77v = a3.f; // null check optimized out by EA but CastPP left in78}7980a1.f = 0x42;81a2.f = 0x42;8283return v;84}8586static class A {87A a;88int f;89}90}919293