Path: blob/master/test/hotspot/jtreg/compiler/exceptions/TestLateMHInlineExceptions.java
64474 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 8275638 827896626* @summary GraphKit::combine_exception_states fails with "matching stack sizes" assert27*28* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:CompileCommand=dontinline,TestLateMHInlineExceptions::m29* -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline TestLateMHInlineExceptions30* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacements -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline31* TestLateMHInlineExceptions32*33*/3435import java.lang.invoke.MethodHandle;36import java.lang.invoke.MethodHandles;37import java.lang.invoke.MethodType;3839public class TestLateMHInlineExceptions {40public static void main(String[] args) throws Throwable {41TestLateMHInlineExceptions test = new TestLateMHInlineExceptions();42for (int i = 0; i < 20_000; i++) {43test1(test);44try {45test1(null);46} catch (NullPointerException npe) {47}48test2(test);49test2(null);50test3(test);51try {52test3(null);53} catch (NullPointerException npe) {54}55test4(test);56test4(null);57test5(test);58try {59test5(null);60} catch (NullPointerException npe) {61}62test6(test);63try {64test6(null);65} catch (NullPointerException npe) {66}67}68}6970void m() {71}7273static void nothing(Throwable t) {74}7576static final MethodHandle mh;77static final MethodHandle mh_nothing;78static final MethodHandle mh2;79static final MethodHandle mh3;8081static {82MethodHandles.Lookup lookup = MethodHandles.lookup();83try {84mh = lookup.findVirtual(TestLateMHInlineExceptions.class, "m", MethodType.methodType(void.class));85mh_nothing = lookup.findStatic(TestLateMHInlineExceptions.class, "nothing", MethodType.methodType(void.class, Throwable.class));86mh2 = MethodHandles.tryFinally(mh, mh_nothing);87mh3 = MethodHandles.catchException(mh, Throwable.class, mh_nothing);88} catch (NoSuchMethodException e) {89e.printStackTrace();90throw new RuntimeException("Method handle lookup failed");91} catch (IllegalAccessException e) {92e.printStackTrace();93throw new RuntimeException("Method handle lookup failed");94}95}9697private static void test1(TestLateMHInlineExceptions test) throws Throwable {98mh.invokeExact(test);99}100101private static void test2(TestLateMHInlineExceptions test) throws Throwable {102try {103mh.invokeExact(test);104} catch (NullPointerException npe) {105}106}107108private static void inlined(TestLateMHInlineExceptions test) throws Throwable {109mh.invokeExact(test);110}111112113private static void test3(TestLateMHInlineExceptions test) throws Throwable {114inlined(test);115}116117private static void test4(TestLateMHInlineExceptions test) throws Throwable {118try {119inlined(test);120} catch (NullPointerException npe) {121}122}123124private static void test5(TestLateMHInlineExceptions test) throws Throwable {125mh2.invokeExact(test);126}127128private static void test6(TestLateMHInlineExceptions test) throws Throwable {129mh3.invokeExact(test);130}131}132133134