On Sun, 6 Oct 2024 15:11:19 GMT, Chen Liang <li...@openjdk.org> wrote:

>> It's actually not less overhead in my tests, since `checkIndex` is intrinsic 
>> and mostly disappears, while with `checkFromIndexSize` performance gets 
>> significantly worse (on par with baseline). It's on my todo to investigate 
>> this in-depth but I think `checkFromIndexSize` needs to be given similar 
>> intrinsification treatment as `checkIndex`.
>
> Actually if we trust the input index to be nonnegative, we can just check our 
> end index for out of bounds too.

Sure, I think the JIT is pretty good at eliminating the (intrinsic) 
`checkIndex` calls when they are redundant though. Performance with and without 
these `checkIndex`es are the same in my testing, so we can eat and have the 
cake on this one.

FWIW I wouldn't mind giving similar treatment to `ByteArray(-LittleEndian)` and 
avoid the `VarHandles` dependency in those utility classes, but I have no urge 
to get into the sort of discussions that were spawned in #19616

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21377#discussion_r1789137335

Reply via email to