[jdk19] RFR: 8280320: C2: Loop opts are missing during OSR compilation
Vladimir Ivanov
vlivanov at openjdk.org
Fri Jul 1 23:01:45 UTC 2022
On Fri, 17 Jun 2022 21:29:41 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
> 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
Thanks for the reviews, Tobias & Vladimir.
I addressed your comments.
-------------
PR: https://git.openjdk.org/jdk19/pull/38
More information about the hotspot-compiler-dev
mailing list