RFR: 8365017: The SegmentBulkOperations::copy method can be improved using overlaps [v4]
Emanuel Peter
epeter at openjdk.org
Mon Aug 11 14:06:13 UTC 2025
On Fri, 8 Aug 2025 13:25:27 GMT, Per Minborg <pminborg at openjdk.org> wrote:
>> This PR proposes to use overlapping memory areas in `SegmentBulkOperations::copy`, similar to what is proposed for `SegmentBulkOperations::fill` in https://github.com/openjdk/jdk/pull/25383.
>>
>> This PR passes `tier1`, `tier2`, and `tier3`testing on multiple platforms.
>
> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
>
> Update copyright year
src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java line 270:
> 268: // We can subtract (non-negative) thatEnd on both sides:
> 269: // (thisStart < thatEnd) -> (thisStart - thatEnd < 0). In the same way we can say:
> 270: // (thatStart < thisEnd) -> (thatStart - thisEnd < 0).
You are only stating the assumption that `thatEnd` is non-negative.
But I think you need all 4 values to be non-negative.
As a counter-example, assume:
thatEnd = 1
thisStart = Long.MIN_VALUE
thisStart < thatEnd = true
but
(thisStart - thatEnd < 0) = (Long.MAX_VALUE < 0) = false
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26672#discussion_r2266880849
More information about the core-libs-dev
mailing list