RFR: 8373898: RepeatCompilation does not repeat compilation after bailout
Christian Hagedorn
chagedorn at openjdk.org
Tue Jan 27 06:51:02 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
You're right, `PrintCompilation` does not repeatedly print the compilation (should it?). I think it's okay to leave out a regression test but thanks for having another look!
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29419#issuecomment-3803414601
More information about the hotspot-compiler-dev
mailing list