|
| 1 | +/* |
| 2 | + * Copyright (c) 2026, Oracle 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 | +package compiler.escapeAnalysis; |
| 24 | + |
| 25 | +import java.util.Objects; |
| 26 | + |
| 27 | +/* |
| 28 | + * @test |
| 29 | + * @bug 8374435 |
| 30 | + * @summary assert during escape analysis when splitting a Load through a Phi because the input of |
| 31 | + * the result Phi is a Load not from an AddP |
| 32 | + * @run main/othervm -XX:-UseOnStackReplacement -XX:-UseCompressedOops ${test.main.class} |
| 33 | + */ |
| 34 | +public class TestSplitLoadThroughPhiDuringEA { |
| 35 | + static class Holder { |
| 36 | + Object o; |
| 37 | + } |
| 38 | + |
| 39 | + public static void main(String[] args) { |
| 40 | + Object o = new Object(); |
| 41 | + Holder h = new Holder(); |
| 42 | + for (int i = 0; i < 20000; i++) { |
| 43 | + test(true, h, o); |
| 44 | + test(false, h, o); |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + private static Object test(boolean b, Holder h, Object o) { |
| 49 | + h = Objects.requireNonNull(h); |
| 50 | + if (b) { |
| 51 | + h = new Holder(); |
| 52 | + // This access has the pattern LoadP -> LoadP, which upsets the compiler because the |
| 53 | + // pointer input of a LoadP is not an AddP |
| 54 | + h.o = o.getClass(); |
| 55 | + } |
| 56 | + return h.o; |
| 57 | + } |
| 58 | +} |
0 commit comments