RFR: 8373898: RepeatCompilation does not repeat compilation after bailout
Marc Chevalier
mchevalier at openjdk.org
Mon Jan 26 14:49:21 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
-------------
Commit messages:
- Restore first message
- Reset failing reason
Changes: https://git.openjdk.org/jdk/pull/29419/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29419&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8373898
Stats: 12 lines in 1 file changed: 6 ins; 0 del; 6 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