RFR: 8330532: Improve line-oriented text parsing in HotSpot [v3]

Ioi Lam iklam at openjdk.org
Wed May 1 20:07:07 UTC 2024


On Tue, 23 Apr 2024 18:29:36 GMT, John R Rose <jrose at openjdk.org> wrote:

>> src/hotspot/share/utilities/istream.hpp line 106:
>> 
>>> 104:   size_t _end;          // offset to end of known current line (else content_end)
>>> 105:   size_t _next;         // offset to known start of next line (else =end)
>>> 106:   void*  _must_free;    // unless null, a malloc pointer which we must free
>> 
>> Reading this code, why do we set `_must_free` instead of simply having a method:
>> 
>> ```c++
>> bool must_free() {
>>   return _buffer != &_small_buffer;
>> }
>> 
>> 
>> and just delete the `_must_free` field.
>
> Good question.  There was a version of the code that accepted a user-supplied buffer, optionally.  In that case, `_must_free` was set false (or to a user-requested value), since it was up to the user whether the user-supplied buffer should be freed.  It could be a static buffer.  If there is no longer such an option in the existing constructors, then this field can be GC-ed.

I removed `_must_free` and added a new `has_c_heap_buffer()` method.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18833#discussion_r1586766416


More information about the hotspot-dev mailing list