RFR: 8280320: C2: Loop opts are missing during OSR compilation
Vladimir Ivanov
vlivanov at openjdk.org
Fri Jun 17 21:44:30 UTC 2022
After [JDK-8272330](https://bugs.openjdk.org/browse/JDK-8272330), OSR compilations may completely miss loop optimizations pass due to misleading profiling data. The cleanup changed how profile counts are scaled and it had surprising effect on OSR compilations.
For a long-running loop it's common to have an MDO allocated during the first invocation while running in the loop. Also, OSR compilation may be scheduled while running the very first method invocation. In such case, `MethodData::invocation_counter() == 0` while `MethodData::backedge_counter() > 0`. Before JDK-8272330 went in, `ciMethod::scale_count()` took into account both `invocation_counter()` and `backedge_counter()`. Now `MethodData::invocation_counter()` is taken by `ciMethod::scale_count()` as is and it forces all counts to be unconditionally scaled to `1`.
It misleads `IdealLoopTree::beautify_loops()` to believe there are no hot
backedges in the loop being compiled and `IdealLoopTree::split_outer_loop()`
doesn't kick in thus effectively blocking any further loop optimizations.
Proposed fix bumps `MethodData::invocation_counter()` from `0` to `1` and
enables `ciMethod::scale_count()` to report sane numbers.
Testing:
- hs-tier1 - hs-tier4
-------------
Commit messages:
- 8280320: C2: Loop opts are missing during OSR compilation
Changes: https://git.openjdk.org/jdk19/pull/38/files
Webrev: https://webrevs.openjdk.org/?repo=jdk19&pr=38&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8280320
Stats: 4 lines in 1 file changed: 3 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk19/pull/38.diff
Fetch: git fetch https://git.openjdk.org/jdk19 pull/38/head:pull/38
PR: https://git.openjdk.org/jdk19/pull/38
More information about the hotspot-compiler-dev
mailing list