RFR: 8373898: RepeatCompilation does not repeat compilation after bailout [v2]
Marc Chevalier
mchevalier at openjdk.org
Thu Jan 29 10:07:14 UTC 2026
> 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
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/29419/files
- new: https://git.openjdk.org/jdk/pull/29419/files/c8d4648a..b604d39b
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=29419&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=29419&range=00-01
Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/29419.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/29419/head:pull/29419
PR: https://git.openjdk.org/jdk/pull/29419
More information about the hotspot-compiler-dev
mailing list