RFR: 8361582: AArch64: Some ConH values cannot be replicated with SVE [v7]

Bhavana Kilambi bkilambi at openjdk.org
Tue Aug 26 13:30:39 UTC 2025


On Thu, 21 Aug 2025 08:58:42 GMT, Bhavana Kilambi <bkilambi at openjdk.org> wrote:

>> Ok, in general its advisable to use Generators for any initialization,  another suggestion, you can also generate constant dynamically through @Stable arrays, here is an example 
>> 
>> 
>> 
>> import jdk.internal.vm.annotation.Stable;
>> import java.util.concurrent.ThreadLocalRandom;
>> 
>> public class random_constants {
>>     public static final int idx = ThreadLocalRandom.current().nextInt(1023);
>> 
>>     @Stable
>>     public static int [] arr;
>> 
>>     public static void init() {
>>         arr = new int[1024];
>>         for (int i = 0; i < 1024; i++) {
>>             arr[i] = ThreadLocalRandom.current().nextInt();
>>         }
>>     }
>> 
>>     public static int yeild_number() {
>>         return arr[idx] + 10;
>>     }
>> 
>>     public static void main(String [] args) {
>>         int res = 0;
>>         init();
>>         for (int i = 0; i < 100000; i++) {
>>             res += yeild_number();
>>         }
>>         System.out.println("[res] " + res);
>>     }
>> }
>> 
>> PROMPT>java --add-exports=java.base/jdk.internal.vm.annotation=ALL-UNNAMED -Xbatch -XX:-TieredCompilation -Xbootclasspath/a:. -XX:CompileCommand=PrintIdealPhase,random_constants::yeild_number,BEFORE_MATCHING -cp .  random_constants
>> CompileCommand: PrintIdealPhase random_constants.yeild_number const char* PrintIdealPhase = 'BEFORE_MATCHING'
>> AFTER: BEFORE_MATCHING
>>   0  Root  === 0 32  [[ 0 1 3 31 ]] inner
>>   3  Start  === 3 0  [[ 3 5 6 7 8 9 ]]  #{0:control, 1:abIO, 2:memory, 3:rawptr:BotPTR, 4:return_address}
>>   5  Parm  === 3  [[ 32 ]] Control !jvms: random_constants::yeild_number @ bci:-1 (line 19)
>>   6  Parm  === 3  [[ 32 ]] I_O !jvms: random_constants::yeild_number @ bci:-1 (line 19)
>>   7  Parm  === 3  [[ 32 ]] Memory  Memory: @BotPTR *+bot, idx=Bot; !jvms: random_constants::yeild_number @ bci:-1 (line 19)
>>   8  Parm  === 3  [[ 32 ]] FramePtr !jvms: random_constants::yeild_number @ bci:-1 (line 19)
>>   9  Parm  === 3  [[ 32 ]] ReturnAdr !jvms: random_constants::yeild_number @ bci:-1 (line 19)
>>  31  ConI  === 0  [[ 32 ]]  #int:-753356878
>>  32  Return  === 5 6 7 8 9 returns 31  [[ 0 ]]
>> [res] -1961428160
>> 
>> 
>> You can directly pass arr[idx] as constant argument to relevant Float16 APIs.
>
> Thanks for sharing. This looks interesting.

Thanks a lot for the suggestion but I couldn't find any extra benefit of using `@Stable` for a constant variable. I feel it's more useful in case of arrays (maybe I could use an array of the two final fields in the testcase but I felt the current version is more understandable). I will keep this in mind going forward but just to not complicate a simple testcase, I have just kept the `final` keyword for the constants instead. Could you please review the new patch?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26589#discussion_r2300997957


More information about the hotspot-compiler-dev mailing list