RFR: 8353290: C2: Refactor PhaseIdealLoop::is_counted_loop() [v28]

Christian Hagedorn chagedorn at openjdk.org
Fri Jan 16 16:19:24 UTC 2026


On Wed, 14 Jan 2026 23:20:13 GMT, Kangcheng Xu <kxu at openjdk.org> wrote:

>> There are quite some failures with the same assert (probably all related). Can be triggered, for example, by running `compiler/predicates/assertion/TestAssertionPredicates.java#NoLoopPredicationXbatch` with `-XX:+UseSerialGC`:
>> 
>> 
>> #
>> # A fatal error has been detected by the Java Runtime Environment:
>> #
>> #  Internal Error (/opt/mach5/mesos/work_dir/slaves/da1065b5-7b94-4f0d-85e9-a3a252b9a32e-S11864/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/c6afc1de-b432-44d4-bd71-2c035e46dc9e/runs/88cff2b5-6582-4c32-8cb2-92c8c5d2feeb/workspace/open/src/hotspot/share/opto/loopnode.hpp:1450), pid=182310, tid=182326
>> #  Error: assert(!has_ctrl(n)) failed
>> ..........
>> Current CompileTask:
>> C2:300   95    b  4       compiler.predicates.assertion.TestAssertionPredicates::testTrySplitUpNonOpaqueExpressionNode (163 bytes)
>> 
>> Stack: [0x00007f27d75cc000,0x00007f27d76cc000],  sp=0x00007f27d76c6b00,  free space=1002k
>> Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
>> V  [libjvm.so+0x156bff8]  PhaseIdealLoop::get_loop(Node const*) const+0x68  (loopnode.hpp:1450)
>> V  [libjvm.so+0x15a07f7]  IdealLoopTree::remove_safepoints(PhaseIdealLoop*, bool)+0x167  (loopnode.cpp:4672)
>> V  [libjvm.so+0x15b7dee]  IdealLoopTree::counted_loop(PhaseIdealLoop*)+0x11e  (loopnode.cpp:4700)
>> V  [libjvm.so+0x15b7d7a]  IdealLoopTree::counted_loop(PhaseIdealLoop*)+0xaa  (loopnode.cpp:4719)
>> V  [libjvm.so+0x15b7d7a]  IdealLoopTree::counted_loop(PhaseIdealLoop*)+0xaa  (loopnode.cpp:4719)
>> V  [libjvm.so+0x15bcc07]  PhaseIdealLoop::build_and_optimize()+0xaf7  (loopnode.cpp:5285)
>> V  [libjvm.so+0xbb8130]  PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x4c0  (loopnode.hpp:1226)
>> V  [libjvm.so+0xbb1995]  Compile::Optimize()+0x685  (compile.cpp:2466)
>> V  [libjvm.so+0xbb5173]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x2023  (compile.cpp:862)
>> V  [libjvm.so+0x9cc3e8]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x498  (c2compiler.cpp:147)
>> V  [libjvm.so+0xbc4660]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x780  (compileBroker.cpp:2345)
>> V  [libjvm.so+0xbc5ec0]  CompileBroker::compiler_thread_loop()+0x530  (compileBroker.cpp:1989)
>> V  [libjvm.so+0x112635b]  JavaThread::thread_main_inner()+0x13b  (javaThread.cpp:776)
>> V  [libjvm.so+0x1bb30b6]  Thread::call_run()+0xb6  (thread.cpp:242)
>> V  [libjvm.so+0x1808c98]  thread_native_entry(Thread*)+0x118  (os_linux.cpp:860)
>> 
>>...
>
> @chhagedorn Sorry I made a mistake with safepoint detection. Upon inspecting the original code, `_safepoint` should be set to `null` if `.opcode() != Op_SafePoint`. This logic is missing from my refactored code. How the test only fails with `-XX:+UseSerialGC` is beyond me.
> 
>> I will check next week if I can extract a reproducer to share.
> Yes it is curious regarding the diff assert. I'll appreciate if you can share more information. Thank you very much!

Thanks for addressing the issue @tabjy! Unfortunately, the closed test triggering the DIFF assert uses a closed jar that cannot be shared and does not provide source information. I will try to have a look myself at the failure and report back what I found next week.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/24458#issuecomment-3760795417


More information about the hotspot-compiler-dev mailing list