RFR: 8337102: JITTester: Fix breaks in static initialization blocks
Evgeny Nikitin
enikitin at openjdk.org
Mon Aug 12 17:37:32 UTC 2024
On Mon, 12 Aug 2024 14:58:51 GMT, Igor Veresov <iveresov at openjdk.org> wrote:
> What I mean is - loops with breaks are totally legal in static initializers.
Yes. But I cannot imagine a SIB defined inside a loop. Probably, you could give me a counterexample, but AFAIR they are only allowed on class level and one cannot define a class in a loop.
> So, the bug, I think, is actually that we generated a break outside of the loop.
Checking whether we have an enclosing cycle (and therefore breaks are allowed), AFAIU, is done via passing those `canHaveBreaks` through children constructors. For example, the [BlockFactory#L59](https://github.com/openjdk/jdk/blob/89a15f1414f89d2dd32eac791e9155fcb4207e56/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BlockFactory.java#L59):
BlockFactory(TypeKlass klass, Type returnType, long complexityLimit, int statementLimit,
int operatorLimit, int level, boolean subBlock,
boolean canHaveBreaks, // <-- passed down the children's tree
boolean canHaveContinues, boolean canHaveReturn, boolean canHaveThrows)
Loops, including those created in SIBs, explicitly define `canHaveBreaks=true` for their children. For example, ForLoop does this: https://github.com/openjdk/jdk/blob/89a15f1414f89d2dd32eac791e9155fcb4207e56/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ForFactory.java#L154
https://github.com/openjdk/jdk/blob/89a15f1414f89d2dd32eac791e9155fcb4207e56/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ForFactory.java#L169
https://github.com/openjdk/jdk/blob/89a15f1414f89d2dd32eac791e9155fcb4207e56/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ForFactory.java#L183
And neither SIB nor For/While/DoWhile factories do take `canHaveBreaks` in their constructors, as they control that themselves. Here's [WhileFactory](https://github.com/openjdk/jdk/blob/89a15f1414f89d2dd32eac791e9155fcb4207e56/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/factories/WhileFactory.java#L51), for example:
WhileFactory(TypeKlass ownerClass, Type returnType, long complexityLimit, int statementLimit,
int operatorLimit, int level, boolean canHaveReturn)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20310#issuecomment-2284569281
More information about the hotspot-compiler-dev
mailing list