Path: blob/master/test/hotspot/jtreg/compiler/loopopts/SplitIfSharedFastLockBehindCastPP.java
41152 views
/*1* Copyright (c) 2019, 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 823162026* @summary assert(bol->is_Bool()) crash during split if due to FastLockNode27*28* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement SplitIfSharedFastLockBehindCastPP29*/303132public class SplitIfSharedFastLockBehindCastPP {33private static boolean field;34private static A obj_field;3536public static void main(String[] args) {37A lock = new A();38obj_field = lock;39for (int i = 0; i < 20_000; i++) {40test1(true, lock);41test1(false, lock);42test2(true);43test2(false);44}45}4647private static void test1(boolean flag, Object obj) {48if (obj == null) {49}5051boolean flag2;52if (flag) {53flag2 = true;54} else {55flag2 = false;56obj = obj_field;57}5859// This loop will be unswitched. The condition becomes candidate for split if60for (int i = 0; i < 100; i++) {61if (flag2) {62field = true;63} else {64field = false;65}66synchronized (obj) {67field = true;68}69}70}7172private static Object test2(boolean flag) {73int integer;74if (flag) {75field = true;76integer = 1;77} else {78field = false;79integer = 2;80}8182Object obj = integer;8384// This loop will be unswitched. The condition becomes candidate for split if85for (int i = 0; i < 100; i++) {86if (integer == 1) {87field = true;88} else {89field = false;90}91synchronized (obj) {92field = true;93}94}95return obj;96}9798private static final class A {99}100}101102103