RFR: JDK-8297660: x86: Redundant test+jump in C1 allocateArray [v2]

Thomas Stuefe stuefe at openjdk.org
Sat Nov 26 10:47:11 UTC 2022


> In `C1_MacroAssembler::initialize_body()` we test the input array length for 0. We do this again in `MacroAssembler::zero_memory()`. This results in a redundant test+jump instruction:
> 
> 
>  13442   0x00007f58a8ca2f02:   sub    $0x10,%rsi                 
>  13443   0x00007f58a8ca2f06:   je     0x00007f58a8ca2f26   <<
>  13444   0x00007f58a8ca2f0c:   test   %rsi,%rsi                     
>  13445   0x00007f58a8ca2f0f:   je     0x00007f58a8ca2f26    <<
>  13446   0x00007f58a8ca2f15:   xor    %rbx,%rbx
>  13447   0x00007f58a8ca2f18:   shr    $0x3,%rsi
>  13448   0x00007f58a8ca2f1c:   mov    %rbx,0x8(%rax,%rsi,8)
>  13449   0x00007f58a8ca2f21:   dec    %rsi
>  13450   0x00007f58a8ca2f24:   jne    0x00007f58a8ca2f1c           ;*anewarray {reexecute=0 rethrow=0 return_oop=0}
>  13451                                                             ; - java.lang.invoke.MethodHandles::<clinit>@24 (line 5109)
> 
> 
> Since `MacroAssembler::zero_memory()` is only ever called from `C1_MacroAssembler::initialize_body()`, it does not need to test for len=0, since its caller already does.
> 
> ---
> 
> Patch removes one test+jump and adds an assertion for len>0 to zero_memory.
> 
> Patch ran through SAP nightlies and GHAs.

Thomas Stuefe has updated the pull request incrementally with two additional commits since the last revision:

 - remove outer conditional jump
 - Revert "remove-redundant-test-from-zeromemory"
   
   This reverts commit 4f95969d4d3026ce2310230c37f469579dc32e88.

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/11372/files
  - new: https://git.openjdk.org/jdk/pull/11372/files/4f95969d..3372e965

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=11372&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=11372&range=00-01

  Stats: 12 lines in 2 files changed: 3 ins; 8 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/11372.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/11372/head:pull/11372

PR: https://git.openjdk.org/jdk/pull/11372


More information about the hotspot-dev mailing list