On Tue, 17 Nov 2026 17:29:21 GMT, Ruben Ayrapetyan <[email protected]> wrote:

>> Extend MOVK-based scheme to MOVK/MOVZ allowing to store 19 bits of metadata 
>> directly. Where metadata does not fit into one MOVK/MOVZ, for C2-compiled 
>> code attempt storing it after the main code and refer to the location via 18 
>> bits of offset value stored within MOVN.
>> 
>> The measurements have been run on Arm Neoverse V2 CPU.
>> 
>> Each workload has been run in 20 interleaved pairs of the baseline and the 
>> patched versions. Order of the configurations in each pair was chosen 
>> randomly. Each of these runs has been run as one JMH fork with 30 warm-up 
>> iterations and 30 measurement iterations. Only the final score reported by 
>> JMH has been considered a data point, while all per-iteration measurement 
>> results were ignored.
>> 
>> In order to reduce impact on performance comparison from possible profile 
>> differences, the same AOT-cached profile was used in each run of the same 
>> workload. Each AOT-cached profile was collected using a training run with 
>> 100 warm-up iterations and 100 measurement iterations.
>> 
>> The values in the tables are geometric means across all pairs for the same 
>> workload. Positive values indicate improvements.
>> 
>> The * symbol marks performance measurements which, based on additional 
>> analysis, appear to be statistically significant.
>> 
>> The ~ symbol marks workloads with performance behaviour that appears to be 
>> multi-modal.
>> 
>>   |     Workload      | Performance |
>>   | ----------------- | -------------- |
>>   | JmhAkkaUct        |   +0.189%   |
>>   | JmhAls            |   +0.580%   |
>>   | JmhChiSquare      |   +0.458%   |
>>   | JmhDbShootout     |   +0.937%   |
>>   | JmhDecTree        | * +0.493%   |
>>   | JmhDotty          |   +0.267%   |
>>   | JmhFinagleChirper |   +0.471%   |
>>   | JmhFinagleHttp    |   +1.067%   |
>>   | JmhFjKmeans       |   -0.023%   |
>>   | JmhFutureGenetic  | ~ +4.047%   |
>>   | JmhGaussMix       |   -2.929%   |
>>   | JmhLogRegression  | * +0.534%   |
>>   | JmhMnemonics      |   -0.092%   |
>>   | JmhMovieLens      |   +2.595%   |
>>   | JmhNaiveBayes     | * +1.249%   |
>>   | JmhNeo4jAnalytics |   +1.136%   |
>>   | JmhPageRank       |   +0.471%   |
>>   | JmhParMnemonics   |   -0.379%   |
>>   | JmhPhilosophers   |   -1.045%   |
>>   | JmhReactors       |   -0.029%   |
>>   | JmhRxScrabble     |   +0.170%   |
>>   | JmhScalaDoku      | ~ +3.930%   |
>>   | JmhScalaKmeans    | ~ +1.952%   |
>>   | JmhScalaStmBench7 | * +0.714%   |
>>   | JmhScrabble       |   -0.081%   |
>> 
>> ---------
>> 
>> - [x] I confirm that I make this contri...
>
> Ruben Ayrapetyan has updated the pull request with a new target base due to a 
> merge or a rebase. The pull request now contains five commits:
> 
>  - Address review comments
>  - Merge from mainline
>  - Revert "8373696: AArch64: C1: Embed FP constants into the main code"
>    
>    This reverts commit df380b25e9d4417869b4344b129439ec5a557a3e.
>  - 8373696: AArch64: Refine post-call NOPs
>    
>    Extend MOVK-based scheme to MOVK/MOVZ allowing to store 19 bits
>    of metadata.
>    
>    Choose number of metadata slots in post-call NOP sequence between 1
>    and 2 depending on the offset from the CodeBlob header.
>    
>    Additionally, implement ADR/ADRP-based metadata storage - that
>    provides 22 bits instead of 16 bits to store metadata. This can
>    be enabled via UsePostCallSequenceWithADRP option.
>  - 8373696: AArch64: C1: Embed FP constants into the main code
>    
>    The constants section for C1 on AArch64 is only used for fp32/fp64
>    constants. Embed the values into the instruction section like for
>    the integers.
>    
>    Use immediates where it doesn't require more memory than would have
>    been with the constants section. This is always the case for fp32.
>    Otherwise, use LDR + B skip_label + <int64>.
>    
>    This removes the constants section - saving memory which otherwise
>    would be used for padding to align the entry point to CodeEntryAlignment.
>    
>    Also, this enables further potential optimizations that require size of
>    the constants section to be known before code is emitted.

src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp line 386:

> 384: #endif
> 385: 
> 386:   const int32_t cb_blocks_offset = compute_cb_blocks_offset(cb_offset);

The logic here is complex, but it's also inflexible in that it's hard to change 
the boundary between the oopmap slot and the call offset.

It's simpler if you treat it as arithmetic rather than shifting and bit bashing.

First, define a bunch of constants:


        constexpr int field_width = 19;
        double oopmap_slot_bits = 9.0;
        int oopmap_slot_range = pow(2, oopmap_slot_bits);
        int offset_range = pow(2, field_width) / oopmap_slot_range;


then

`         uint32_t slot_value = oopmap_slot_adjusted * offset_range + 
cb_blocks_offset;`

Decoding is easy


        div_t result = div(slot_value,  offset_range);
        assert(oopmap_slot == result.quot &&  cb_blocks_offset == result.rem, 
"must be");


Of course we need to do some range checks:


  if (oopmap_slot_adjusted >= oopmap_slot_range ||
      cb_blocks_offset >= offset_range) {
    return false;
  }


If we want to allocate 8.5 `oopmap_slot_bits` we can do so, and it's easy to 
experiment.

src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp line 391:

> 389:   if (cb_blocks_offset == 0) {
> 390:     // Distinguish from the case when the fields are empty.
> 391:     oopmap_slot_adjusted++;

Is this for when both fields are exactly zero? Does that ever happen?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28855#discussion_r4633056438
PR Review Comment: https://git.openjdk.org/jdk/pull/28855#discussion_r4633070182

Reply via email to