RFR: 8337102: JITTester: Fix breaks in static initialization blocks

Vladimir Kozlov kvn at openjdk.org
Tue Jul 30 16:59:31 UTC 2024


On Wed, 24 Jul 2024 10:28:54 GMT, Evgeny Nikitin <enikitin at openjdk.org> wrote:

> Static initialisation blocks (SIBs) should not have `break`s in their code, as well as their descendants. Currently, StaticConstructorDefinitionFactory allows them, causing non-compilable constructions like this:
> 
> 
> class Test_0 {
>     static {
>         if (true) {
>             break; // <- compilation error here
>         }
>     }
> }
> 
> 
> It seems like previously an attempt have been made to resolve this by disabling SIBs whatsoever.
> 
> Currently, out of 100 generated tests we have 2-3 compilation errors.
> Allowing SIBs raises this to 80 out of 100 tests failing due to erroneous 'break' blocks.
> Disabling breaks in StaticConstructorDefinition gives us SIBs, and returns failure rate to the same 2-3%.
> Disabling breaks in StaticConstructorDefinition doesn't prevent breaks from happening, as loop factories (`ForFactory`, `WhileFactory`, etc.) explicitly allow for breaks in their descendant trees.
> 
> Testing: 
> 1. 200-300 generations in various setups to get the numbers mentioned above;
> 2. I checked manually that breaks do not disappear from code,
> 3. ... and appear in loops' (for, while, do-while) descendants.

I can approve it based on description which sounds right.
Someone who more familiar with this code have to review it.

-------------

Marked as reviewed by kvn (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/20310#pullrequestreview-2208222137


More information about the hotspot-compiler-dev mailing list