On Mon, 8 Apr 2024 19:11:19 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:
> 
>   Add movq to locate_operand

src/hotspot/cpu/x86/macroAssembler_x86.cpp line 5988:

> 5986:     movw(Address(to, 0), value);
> 5987:     addptr(to, 2);
> 5988:     subptr(count, 1<<(shift-1));

At line 5968 also we need the change from cmpl to cmpptr.
cmpl(count, 2<<shift); // Short arrays (< 8 bytes) fill by element

src/hotspot/cpu/x86/macroAssembler_x86.cpp line 6050:

> 6048:           vpbroadcastd(xtmp, xtmp, Assembler::AVX_512bit);
> 6049: 
> 6050:           subptr(count, 16 << shift);

At line 6045 also the cmpl should change to cmpptr:
cmpl(count, VM_Version::avx3_threshold());

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18555#discussion_r1560205702
PR Review Comment: https://git.openjdk.org/jdk/pull/18555#discussion_r1560213265

Reply via email to