RFR: 8373898: RepeatCompilation does not repeat compilation after bailout [v2]
Christian Hagedorn
chagedorn at openjdk.org
Thu Jan 29 11:29:02 UTC 2026
On Thu, 29 Jan 2026 10:07:14 GMT, Marc Chevalier <mchevalier at openjdk.org> wrote:
>> Repeat compilation happens here:
>>
>> https://github.com/openjdk/jdk/blob/b59f49a1c3e370f794291a1f948e67d2651ece11/src/hotspot/share/compiler/compileBroker.cpp#L2347-L2355
>>
>> and in `C2Compiler::compile_method` which does
>>
>> https://github.com/openjdk/jdk/blob/b59f49a1c3e370f794291a1f948e67d2651ece11/src/hotspot/share/opto/c2compiler.cpp#L136-L147
>>
>> In case of failure `_failure_reason` in `ci_env`/`env` is populated, and so the big loop in `compile_method` makes no iteration, and in particular, no compilation happens. Bailouts in `Compile::Compile` and `Compile::Optimize` checks this `_failure_reason`, but also the `Compile` object's one. This is fine since the `Compile` object doesn't survive across compilation, and thus the field in it is fresh at each iteration in `compile_method`.
>>
>> A direct solution is to reset `ci_env._failure_reason` at each iteration of compilation repeat. We could also create a fresh `ci_env` like hinted in the JBS issue, but `ci_env` undergoes a bit of setup. It might be ok not to do this setup for the purpose of repeated compilation, but it's not clear to me.
>>
>> Since repeated compilation do not install code (and thus, cannot mark the task as successful), to get consistent values between `ci_env.failing()` and `task->is_success()`, I copy the original failing reason and restore it at the end.
>>
>> Using IGV output, we can see that we get as many re-compilation as requested, even when some are (artificially) bailing out.
>>
>> Thanks,
>> Marc
>
> Marc Chevalier has updated the pull request incrementally with one additional commit since the last revision:
>
> Copyright
Marked as reviewed by chagedorn (Reviewer).
-------------
PR Review: https://git.openjdk.org/jdk/pull/29419#pullrequestreview-3722128349
More information about the hotspot-compiler-dev
mailing list