Path: blob/master/test/hotspot/jtreg/compiler/c2/SubsumingLoadsCauseFlagSpill.java
41149 views
/*1* Copyright (c) 2018, 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 820963926* @summary assert failure in coalesce.cpp: attempted to spill a non-spillable item27*28* @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,SubsumingLoadsCauseFlagSpill::not_inlined -Xmx1024m SubsumingLoadsCauseFlagSpill29*30*/3132public class SubsumingLoadsCauseFlagSpill {33private static Object field;34private static boolean do_throw;35private static volatile boolean barrier;3637public static void main(String[] args) {38for (int i = 0; i < 20_000; i++) {39do_throw = true;40field = null;41test(0);42do_throw = false;43field = new Object();44test(0);45}46}4748private static float test(float f) {49Object v = null;50try {51not_inlined();52v = field;53} catch (MyException me) {54v = field;55barrier = true;56}57if (v == null) {58return f * f;59}60return f;61}6263private static void not_inlined() throws MyException{64if (do_throw) {65throw new MyException();66}67}6869private static class MyException extends Throwable {70}71}727374