On Tue, 18 Nov 2025 09:38:44 GMT, Igor Rudenko <[email protected]> wrote:

>> Logic for creating IndexOutOfBoundsException in MemorySegment is reworked:
>> - separate logic of checking bounds and constructing exception messages for 
>> both `access` and `slice` cases 
>> - idea presented in 
>> [JDK-8288534](https://bugs.openjdk.org/browse/JDK-8288534) slightly reworked 
>> with preservation of the original approach
>
> Igor Rudenko has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   improvements according to reviewer comments

src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java 
line 413:

> 411:     private void checkBounds(long offset, long length, BoundPolicy 
> policy) {
> 412:         if (length > 0) {
> 413:             Preconditions.checkIndex(offset, this.length - length + 1, 
> new BoundsCheckHandler(this, policy));

This is a very very hot path. Allocating here is gonna have negative effect, 
especially when this code cannot be inlined (in which case the allocation can't 
be scalar replaced).

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28124#discussion_r2537932200

Reply via email to