RFR: 8357531: The `SegmentBulkOperations::fill` method can be improved using overlaps [v5]

Archie Cobbs archie.cobbs at gmail.com
Thu May 22 20:58:03 UTC 2025


On Thu, May 22, 2025 at 3:31 PM John R Rose <jrose at openjdk.org> wrote:

> >   Update benchmark to reflect new fill method
>
> Related discussion at the hardware level:
>
> https://github.com/openjdk/jdk/pull/25147#issuecomment-2902463076
>

This discussion spurred me to ask a dumb question. Apologies in advance,
just trying to learn here...

If I do this:

import java.util.Arrays;
public class ArrayFiller {
    public static void main(String[] args) {
        while (true) {
            final byte[] array = new byte[1000000];
            Arrays.fill(array, (byte)0x42);
        }
    }
}

Will C2 compile Arrays.fill()
<https://github.com/openjdk/jdk/blob/139a05d05959a84541a29dfae6151f92ce579ae6/src/java.base/share/classes/java/util/Arrays.java#L3275-L3308>
into something that is more efficient than a byte-at-a-time loop like what
appears in the source code?

Thanks,
-Archie

-- 
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250522/a15e1b6e/attachment.htm>


More information about the core-libs-dev mailing list