Skip to content

8336003: [lworld] TestLWorld::test151 triggers "Should have been buffered" assert #1489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: lworld
Choose a base branch
from

Conversation

merykitty
Copy link
Member

@merykitty merykitty commented Jun 13, 2025

Hi,

The issue here is that the IGVN cannot deduce that the IsBuffered input is a constant 1. This is because after the InlineTypeNode is pushed down through a Phi cluster, the IsBuffered input is a Phi cluster with loop phis, which makes it difficult for the IGVN to see through. A solution is to do another round of CCP after loop opts, but it is rather a big hammer. In this PR, I propose to make it possible for a PhiNode to look through its Phi inputs to discover the unique non-phi input of a Phi cluster. The test still fails but it seems more like an expected behaviour rather than an issue this time, I have modified the test a little bit for it to pass.

Please take a look and share your thoughts, thanks very much.


Progress

  • Change must not contain extraneous whitespace

Issue

  • JDK-8336003: [lworld] TestLWorld::test151 triggers "Should have been buffered" assert (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/1489/head:pull/1489
$ git checkout pull/1489

Update a local copy of the PR:
$ git checkout pull/1489
$ git pull https://git.openjdk.org/valhalla.git pull/1489/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1489

View PR using the GUI difftool:
$ git pr show -t 1489

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1489.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 13, 2025

👋 Welcome back qamai! A progress list of the required criteria for merging this PR into lworld will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jun 13, 2025

@merykitty This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8336003: [lworld] TestLWorld::test151 triggers "Should have been buffered" assert

Reviewed-by: thartmann

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 8 new commits pushed to the lworld branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@TobiHartmann) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk
Copy link

openjdk bot commented Jun 13, 2025

@merykitty Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

@mlbridge
Copy link

mlbridge bot commented Jun 13, 2025

Webrevs

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

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

Thanks for working on this Quan-Anh!

compiler/c2/TestDeadLoopSplitIfLoop.java now fails with -XX:-EnableValhalla:

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/open/src/hotspot/share/opto/phaseX.cpp:784), pid=1729076, tid=1729093
#  assert(no_dead_loop) failed: dead loop detected
#
# JRE version: Java(TM) SE Runtime Environment (25.0) (fastdebug build 25-lworld5ea-LTS-2025-06-16-1157190.tobias.hartmann.valhalla2)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 25-lworld5ea-LTS-2025-06-16-1157190.tobias.hartmann.valhalla2, compiled mode, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x184ec45]  PhaseGVN::dead_loop_check(Node*) [clone .part.0]+0x1d5
Current CompileTask:
C2:309   14    b        compiler.c2.TestDeadLoopSplitIfLoop::test (88 bytes)

Stack: [0x00007f1323dff000,0x00007f1323eff000],  sp=0x00007f1323efa0e0,  free space=1004k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x184ec45]  PhaseGVN::dead_loop_check(Node*) [clone .part.0]+0x1d5  (phaseX.cpp:784)
V  [libjvm.so+0x185fe39]  PhaseIterGVN::transform_old(Node*)+0x529  (phaseX.cpp:767)
V  [libjvm.so+0x1854c54]  PhaseIterGVN::optimize()+0xb4  (phaseX.cpp:1054)
V  [libjvm.so+0xb54796]  Compile::Optimize()+0x326  (compile.cpp:2779)
V  [libjvm.so+0xb583bf]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1fef  (compile.cpp:874)
V  [libjvm.so+0x96de34]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x484  (c2compiler.cpp:142)
V  [libjvm.so+0xb66078]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xb58  (compileBroker.cpp:2307)
V  [libjvm.so+0xb67238]  CompileBroker::compiler_thread_loop()+0x568  (compileBroker.cpp:1951)
V  [libjvm.so+0x10e17fb]  JavaThread::thread_main_inner()+0x13b  (javaThread.cpp:774)
V  [libjvm.so+0x1b5b146]  Thread::call_run()+0xb6  (thread.cpp:231)
V  [libjvm.so+0x17c6e38]  thread_native_entry(Thread*)+0x128  (os_linux.cpp:875)


Node* phi_in = current->in(i);
if (phi_in->is_Phi()) {
visited.append_if_missing(phi_in->as_Phi());
Copy link
Member

Choose a reason for hiding this comment

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

Would a Unique_Node_List be more appropriate here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unique_Node_List cannot work with const Node* so GrowableArray is the only option here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Update: Changed it to a Unique_Node_List.

@merykitty
Copy link
Member Author

Thanks for your testing, the failure is due to the fact that when traversing the Phi inputs, I decided to skip dead inputs. This may lead to a case like an iv with a dead backedge: Phi = Phi + 1. However, since the backedge is dead, the function only finds the entry node, leading to entry = entry + 1. I fixed this by traversing all the inputs instead of only the live ones.

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants