Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/hotspot/share/opto/cfgnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3108,17 +3108,11 @@ class PushInlineTypeDown {

Node* do_transform(PhiNode* phi) {
assert(_inline_klass != nullptr, "must be");
InlineTypeNode *vt = InlineTypeNode::make_null(*_phase, _inline_klass, /* transform = */ false)->clone_with_phis(
InlineTypeNode* vt = InlineTypeNode::make_null(*_phase, _inline_klass, /* transform = */ false)->clone_with_phis(
_phase, phi->in(0), nullptr, !phi->type()->maybe_null(), true);
if (_can_reshape) {
// Replace phi right away to be able to use the inline
// type node when reaching the phi again through data loops.
PhaseIterGVN* igvn = _phase->is_IterGVN();
igvn->replace_in_uses(phi, vt);
igvn->rehash_node_delayed(phi);
assert(phi->outcnt() == 0, "should be dead now");
}
ResourceMark rm;
// Record that vt was created to replace phi to be able to use the inline type node when reaching the phi again
// through data loops.
_clones.map(phi->_idx, vt);
Node_List casts;
for (uint i = 1; i < phi->req(); ++i) {
Node* n = phi->in(i);
Expand All @@ -3133,7 +3127,12 @@ class PushInlineTypeDown {
n = InlineTypeNode::make_null(*_phase, _inline_klass);
} else if (n->is_Phi()) {
assert(_can_reshape, "can only handle phis during IGVN");
n = _phase->transform(do_transform(n->as_Phi()));
Node* clone = get_clone(n);
if (clone != nullptr) {
n = clone;
} else {
n = _phase->transform(do_transform(n->as_Phi()));
}
}
while (casts.size() != 0) {
// Push the cast(s) through the InlineTypeNode
Expand Down Expand Up @@ -3228,10 +3227,10 @@ class PushInlineTypeDown {

Node* do_it() {
if (_can_reshape) {
Node_List clones;
collect_nodes_to_clone();
clone_subgraph();
DEBUG_ONLY(verify_clone());
_clones.clear();
}
return do_transform(_root_phi);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/**
* @test
* @bug 8386676
* @summary [lworld] Infinite loop when pushing inline types down though phis during IGVN
* @enablePreview
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+StressIGVN
* -XX:CompileCommand=compileonly,${test.main.class}::test -Xbatch
* -XX:-UseOnStackReplacement -XX:StressSeed=3696073068 -XX:CompileTaskTimeout=8000 ${test.main.class}
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+StressIGVN
* -XX:CompileCommand=compileonly,${test.main.class}::test -Xbatch
* -XX:-UseOnStackReplacement -XX:CompileTaskTimeout=8000 ${test.main.class}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And CompileTaskTimeout is debug only.

*/

package compiler.valhalla.inlinetypes;

import jdk.internal.vm.annotation.LooselyConsistentValue;
import jdk.internal.vm.annotation.NullRestricted;

public class TestInlineTypeInfinitePushThruPhi {
static V2 v2 = new V2(3);

public static void main(String[] args) {
for (int i = 0; i < 20_000; i++) {
test();
}
}

public static void test() {
V1 v1 = new V1(null, v2);
for (int i = 0; i < 100; i++) {
v1 = new V1(v1.x, v1.y);
}
}

@LooselyConsistentValue
static value class V1 {
V2 x;
@NullRestricted
V2 y;

V1(V2 x, V2 y) {
this.x = x;
this.y = y;
}
}

static value class V2 {
int i;

V2(int i) {
this.i = i;
}
}
}