RFR: 8373898: RepeatCompilation does not repeat compilation after bailout

Christian Hagedorn chagedorn at openjdk.org
Mon Jan 26 16:19:56 UTC 2026


On Mon, 26 Jan 2026 14:39:11 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

That looks reasonable to me. Not sure if it's worth but did you try to come up with a regression test for that? It would probably just mean matching the failure reason for `RepeatCompilation + 1` many times when run with `PrintCompilation`.

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

Marked as reviewed by chagedorn (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29419#pullrequestreview-3706821656


More information about the hotspot-compiler-dev mailing list