Path: blob/master/test/hotspot/jtreg/compiler/escapeAnalysis/TestValAtSafepointOverflowsInt.java
41152 views
/*1* Copyright (c) 2021, 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 826181226* @summary C2 compilation fails with assert(!had_error) failed: bad dominance27*28* @run main/othervm -XX:-BackgroundCompilation TestValAtSafepointOverflowsInt29*30*/3132public class TestValAtSafepointOverflowsInt {33private static volatile int volatileField;3435public static void main(String[] args) {36for (int i = 0; i < 20_000; i++) {37testByte(true, false);38testByte(false, false);39testShort(true, false);40testShort(false, false);41testChar(true, false);42testChar(false, false);43}44testByte(true, true);45testShort(true, true);46testChar(true, true);47}4849private static Object testByte(boolean flag, boolean flag2) {50int i;51// loop to delay constant folding52for (i = 0; i < 9; i++) {53}54C obj = new C();55if (flag) {56obj.byteField = (byte)(1 << i);57} else {58obj.byteField = (byte)(1 << (i+1));59}60// Phi for byte here for uncommon trap in never taken path below61// Phi inputs don't fit in a byte. Phi transfomed to top.62if (flag2) {63return obj;64}65return null;66}6768private static Object testShort(boolean flag, boolean flag2) {69int i;70for (i = 0; i < 17; i++) {71}72C obj = new C();73if (flag) {74obj.shortField = (short)(1 << i);75} else {76obj.shortField = (short)(1 << (i+1));77}78if (flag2) {79return obj;80}81return null;82}8384private static Object testChar(boolean flag, boolean flag2) {85int i;86for (i = 0; i < 17; i++) {87}88C obj = new C();89if (flag) {90obj.charField = (char)(1 << i);91} else {92obj.charField = (char)(1 << (i+1));93}94if (flag2) {95return obj;96}97return null;98}99100101static class C {102byte byteField;103short shortField;104char charField;105}106107}108109110