RFR: 8370519: C2: Hit MemLimit when running with +VerifyLoopOptimizations [v6]

Benoît Maillard bmaillard at openjdk.org
Tue Jan 20 12:32:18 UTC 2026


On Mon, 19 Jan 2026 13:55:53 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> I think we should use the following test, which is quite concise and only takes a few seconds to execute thanks to setting `memlimit` to `100M`.
>> 
>> ```c++
>> /**
>>  * @test
>>  * @key stress randomness
>>  * @bug 8370519
>>  * @summary C2: Hit MemLimit when running with +VerifyLoopOptimizations
>>  * @run main/othervm -XX:CompileCommand=compileonly,${test.main.class}::* -XX:-TieredCompilation -Xbatch
>>  *                   -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions
>>  *                   -XX:+StressLoopPeeling -XX:+VerifyLoopOptimizations
>>  *                   -XX:CompileCommand=memlimit,${test.main.class}::*,100M~crash
>>  *                   -XX:StressSeed=3106998670 ${test.main.class}
>>  * @run main ${test.main.class}
>>  */
>> 
>> package compiler.c2;
>> 
>> public class TestVerifyLoopOptimizationsHighMemUsage {
>> 
>>     static int b = 400;
>>     static long c;
>>     static boolean d;
>> 
>>     static long lMeth(int e) {
>>         int f, g, h, k[] = new int[b];
>>         long l[] = new long[b];
>>         boolean m[] = new boolean[b];
>>         for (f = 5; f < 330; ++f)
>>         for (g = 1; g < 5; ++g)
>>             for (h = 2; h > 1; h -= 3)
>>             switch (f * 5 + 54) {
>>             case 156:
>>             case 354:
>>             case 98:
>>             case 173:
>>             case 120:
>>             case 374:
>>             case 140:
>>             case 57:
>>             case 106:
>>             case 306:
>>             case 87:
>>             case 399:
>>                 k[1] = (int)c;
>>             case 51:
>>             case 287:
>>             case 148:
>>             case 70:
>>             case 74:
>>             case 59:
>>                 m[h] = d;
>>             }
>>         long n = p(l);
>>         return n;
>>     }
>> 
>>     public static long p(long[] a) {
>>         long o = 0;
>>         for (int j = 0; j < a.length; j++)
>>         o += j;
>>         return o;
>>     }
>> 
>>     public static void main(String[] args) {
>>         for (int i = 0; i < 10; i++)
>>         lMeth(9);
>>     }
>> }
>
> @benoitmaillard how feasible/time consuming would it be to find a more robust test case? Do you agree with my concern above?

Apologies for the delay @rwestrel, this somehow got under the radar after Christmas. I agree 100% with your concerns. I think it's worth it to give it a try, I will launch another run of creduce and come back to you with the results (this should go a bit faster this time).

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

PR Comment: https://git.openjdk.org/jdk/pull/28581#issuecomment-3772652281


More information about the hotspot-compiler-dev mailing list