|
| 1 | +/* |
| 2 | + * Copyright (c) 2024, Red Hat and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | + * accompanied this code). |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License version |
| 16 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | + * |
| 19 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | + * or visit www.oracle.com if you need additional information or have any |
| 21 | + * questions. |
| 22 | + */ |
| 23 | + |
| 24 | +/* |
| 25 | + * @test |
| 26 | + * @bug 8335843 |
| 27 | + * @summary C2 hits assert(_print_inlining_stream->size() > 0) failed: missing inlining msg |
| 28 | + * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:-BackgroundCompilation -XX:+PrintCompilation -XX:+PrintInlining TestPrintInliningLateMHCall |
| 29 | + */ |
| 30 | + |
| 31 | +import java.lang.invoke.MethodHandle; |
| 32 | +import java.lang.invoke.MethodHandles; |
| 33 | +import java.lang.invoke.MethodType; |
| 34 | + |
| 35 | +public class TestPrintInliningLateMHCall { |
| 36 | + static final MethodHandle mh1; |
| 37 | + static MethodHandle mh2; |
| 38 | + |
| 39 | + static { |
| 40 | + try { |
| 41 | + MethodHandles.Lookup lookup = MethodHandles.lookup(); |
| 42 | + mh1 = lookup.findStatic(TestPrintInliningLateMHCall.class, "lateResolved", MethodType.methodType(void.class)); |
| 43 | + mh2 = mh1; |
| 44 | + } catch (NoSuchMethodException | IllegalAccessException e) { |
| 45 | + e.printStackTrace(); |
| 46 | + throw new RuntimeException("Method handle lookup failed"); |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + public static void main(String[] args) throws Throwable { |
| 51 | + for (int i = 0; i < 20_000; i++) { |
| 52 | + testHelper(0); |
| 53 | + testHelper(10); |
| 54 | + test(); |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + private static void testHelper(int i) throws Throwable { |
| 59 | + MethodHandle mh = null; |
| 60 | + if (i == 10) { |
| 61 | + mh = mh1; |
| 62 | + } else { |
| 63 | + mh = mh2; |
| 64 | + } |
| 65 | + mh.invokeExact(); |
| 66 | + } |
| 67 | + |
| 68 | + private static void test() throws Throwable { |
| 69 | + int i; |
| 70 | + for (i = 0; i < 10; i++) { |
| 71 | + |
| 72 | + } |
| 73 | + testHelper(i); |
| 74 | + } |
| 75 | + |
| 76 | + private static void lateResolved() { |
| 77 | + // noop |
| 78 | + } |
| 79 | +} |
0 commit comments