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

Igor Veresov iveresov at openjdk.org
Mon Aug 12 15:01:30 UTC 2024


On Mon, 12 Aug 2024 13:12:01 GMT, Evgeny Nikitin <enikitin at openjdk.org> wrote:

> > Why would it generate a break if there is no enclosing loop?
> 
> That's the essence of the change - the static initialisation block creates an inner body (Block node) at [factories/StaticConstructorDefinitionFactory.java#L58](https://github.com/openjdk/jdk/blob/89a15f1414f89d2dd32eac791e9155fcb4207e56/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/factories/StaticConstructorDefinitionFactory.java#L58), with `canHaveBreaks` enabled. The inner blocks/nodes just inherit that. Well, majority of them:
> 
> ```
>             body = new IRNodeBuilder()
> ..
>                     .setCanHaveBreaks(true)              // <- Children inherit this "can"
> ...
>                     .produce();
> ...
>         return new StaticConstructorDefinition(body);
> ```
> 
> That behaviour has been checked and current version happily creates such erroneous blocks.

What I mean is - loops with breaks are totally legal in static initializers. So, the bug, I think, is actually that we generated a break outside of the loop. Disabling breaks of course solves it, but it doesn't look like it fixes the underlying problem, does it?

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

PR Comment: https://git.openjdk.org/jdk/pull/20310#issuecomment-2284215303


More information about the hotspot-compiler-dev mailing list