RFR: 8377179: Improve and document racy use of start/end in ThreadLocalAllocBuffer [v2]

Thomas Schatzl tschatzl at openjdk.org
Thu Feb 5 15:21:06 UTC 2026


On Thu, 5 Feb 2026 13:28:55 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:

>> Thomas Schatzl has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   * ayang review
>
> src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp line 472:
> 
>> 470:   // the used bytes from a semi-initialized TLAB ending up with implausible values.
>> 471:   // In this case also just return 0.
>> 472:   if ((diff <= 0) || (diff > checked_cast<ptrdiff_t>(ThreadLocalAllocBuffer::max_size_in_bytes()))) {
> 
> I think the logic would be much cleaner if the negative case and exceeding-max case are separated, sth like:
> 
> 
> if (top < start) {
>   return 0;
> }
> size = pointer_delta(top, start, 1);
> if (size > max) {
>   return 0;
> }
> return size;

Either is fine with me.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29573#discussion_r2769712384


More information about the hotspot-dev mailing list