RFR: 8351952: [IR Framework]: allow ignoring methods that are not compilable [v2]

Christian Hagedorn chagedorn at openjdk.org
Tue Mar 18 08:45:12 UTC 2025


On Tue, 18 Mar 2025 07:12:03 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> With the Template Framework, I'm generating IR tests randomly. But random code can always hit bailouts in compilation, and make code not compilable any more. We should have a way to disable this check, and just gracefully continue to execute the tests.
>> 
>> To allow a single test method to be `not compilable`:
>> https://github.com/openjdk/jdk/blob/ce40f1402387f75ea8627883979e3cbf63480941/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestNotCompilable.java#L160-L161
>> 
>> To allow all test methods to be `not compilable`:
>> https://github.com/openjdk/jdk/blob/ce40f1402387f75ea8627883979e3cbf63480941/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestNotCompilable.java#L140-L144
>> 
>> See also this documentation in the code:
>> https://github.com/openjdk/jdk/blob/ce40f1402387f75ea8627883979e3cbf63480941/test/hotspot/jtreg/compiler/lib/ir_framework/Test.java#L88-L94
>> 
>> ---------------------------------------
>> 
>> **Backrgound**
>> 
>> My random code seems to hit a bailout in the Register Allocator, and I cannot do much to predict if that bailout happens.
>> See https://bugs.openjdk.org/browse/JDK-8304328
>
> Emanuel Peter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   documentation from Christian

test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java line 418:

> 416:      * true, which allows any test to pass even if there is a compilation bailout. If only selected methods are prone
> 417:      * to bail out, it is preferred to use {@link Test#allowNotCompilable()} instead for more fine-grained control.
> 418:      * By setting this flag, any associated {@link IR} rule of a test is only executed if the test method was compiled, 

Whitespace error.

test/hotspot/jtreg/compiler/lib/ir_framework/test/AbstractTest.java line 122:

> 120:             tryCompileMethod(test);
> 121:         } catch (MethodNotCompilableException e) {
> 122:             TestRun.check(test.isAllowNotCompilable(), "Only allowNotCompilable methods should throw MethodNotCompilableException.");

Should we emit a log message here in case we have an expected compilation bailout here?

test/hotspot/jtreg/compiler/lib/ir_framework/test/AbstractTest.java line 175:

> 173:         }
> 174:         TestRun.check(WHITE_BOX.isMethodCompilable(testMethod, test.getCompLevel().getValue(), false),
> 175:                       "Method " + testMethod + " not compilable (anymore) at level " + test.getCompLevel());

You now check `isMethodCompilable()` twice. You could move the second check inside the `catch` block for `MethodNotCompilableException`. Then you can use this exception whenever there is a method that is not compilable (as the class name suggests) and then only do the separation between allowed and disallowed cases there.

test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestNotCompilable.java line 102:

> 100:             throw new RuntimeException("should have thrown TestRunException");
> 101:         } catch (TestVMException e) {
> 102:         } catch (IRViolationException e) {}

This is a mismatch. Which exceptions are now expected? Same below.

test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java line 403:

> 401:     @Override
> 402:     public void visitMethodNotCompilable(Method method, int failedIRRules) {
> 403:         throw new RuntimeException("Should not reach here");

Maybe change to:
Suggestion:

        throw new RuntimeException("No test should bailout from compilation");

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24049#discussion_r2000480128
PR Review Comment: https://git.openjdk.org/jdk/pull/24049#discussion_r2000446479
PR Review Comment: https://git.openjdk.org/jdk/pull/24049#discussion_r2000473330
PR Review Comment: https://git.openjdk.org/jdk/pull/24049#discussion_r2000477309
PR Review Comment: https://git.openjdk.org/jdk/pull/24049#discussion_r2000478578


More information about the hotspot-compiler-dev mailing list