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
24 /**
25 * @test
26 * @bug 8386676
27 * @summary [lworld] Infinite loop when pushing inline types down though phis during IGVN
28 * @enablePreview
29 * @modules java.base/jdk.internal.value
30 * java.base/jdk.internal.vm.annotation
31 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+StressIGVN
32 * -XX:CompileCommand=compileonly,${test.main.class}::test -Xbatch
33 * -XX:-UseOnStackReplacement -XX:StressSeed=3696073068 -XX:CompileTaskTimeout=8000 ${test.main.class}
34 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+StressIGVN
35 * -XX:CompileCommand=compileonly,${test.main.class}::test -Xbatch
36 * -XX:-UseOnStackReplacement -XX:CompileTaskTimeout=8000 ${test.main.class}
37 */
38
39 package compiler.valhalla.inlinetypes;
40
41 import jdk.internal.vm.annotation.LooselyConsistentValue;
42 import jdk.internal.vm.annotation.NullRestricted;
43
44 public class TestInlineTypeInfinitePushThruPhi {
45 static V2 v2 = new V2(3);
46
47 public static void main(String[] args) {
48 for (int i = 0; i < 20_000; i++) {
49 test();
50 }
51 }
52
53 public static void test() {
54 V1 v1 = new V1(null, v2);
55 for (int i = 0; i < 100; i++) {
56 v1 = new V1(v1.x, v1.y);
57 }
58 }
59
60 @LooselyConsistentValue
61 static value class V1 {
62 V2 x;
63 @NullRestricted
64 V2 y;
65
66 V1(V2 x, V2 y) {
67 this.x = x;
68 this.y = y;
69 }
70 }
71
72 static value class V2 {
73 int i;
74
75 V2(int i) {
76 this.i = i;
77 }
78 }
79 }