On Fri, 19 Apr 2024 16:25:28 GMT, Scott Gibbons <sgibb...@openjdk.org> wrote:

>> This code makes an intrinsic stub for `Unsafe::setMemory` for x86_64.  See 
>> [this PR](https://github.com/openjdk/jdk/pull/16760) for discussion around 
>> this change.
>> 
>> Overall, making this an intrinsic improves overall performance of 
>> `Unsafe::setMemory` by up to 4x for all buffer sizes.
>> 
>> Tested with tier-1 (and full CI).  I've added a table of the before and 
>> after numbers for the JMH I ran (`MemorySegmentZeroUnsafe`).
>> 
>> [setMemoryBM.txt](https://github.com/openjdk/jdk/files/14808974/setMemoryBM.txt)
>
> Scott Gibbons has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Address review comments; update copyright years

I'm not really qualified as a compiler code reviewer, but I've left some 
comments to try and help this along.

src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp line 2523:

> 2521:   // Number of (8*X)-byte chunks into rScratch1
> 2522:   __ movq(tmp, size);
> 2523:   __ shrq(tmp, 3);

`shr` [sets the zero flag][1], so I think you can just move the jump to after 
the shift and avoid a separate comparison?

```suggestion  
  // Number of (8*X)-byte chunks into rScratch1
  __ movq(tmp, size);
  __ shrq(tmp, 3);
  __ jccb(Assembler::zero, L_Tail);


[1]: https://www.felixcloutier.com/x86/sal:sar:shl:shr#flags-affected

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

PR Review: https://git.openjdk.org/jdk/pull/18555#pullrequestreview-2011751831
PR Review Comment: https://git.openjdk.org/jdk/pull/18555#discussion_r1572712233

Reply via email to