RFR: 8367981: Update CompactHashtable comments [v2]
Hamlin Li
mli at openjdk.org
Tue Sep 23 19:01:52 UTC 2025
On Tue, 23 Sep 2025 18:32:15 GMT, Hamlin Li <mli at openjdk.org> wrote:
>> src/hotspot/share/classfile/compactHashtable.hpp line 174:
>>
>>> 172: // For regular buckets, each entry is 8 bytes in the entries[]:
>>> 173: // u4 hash; // entry hash
>>> 174: // u4 value; // it could be offset or index or any payload.
>>
>> I think `value` is confusing, as it's not the same as the template type `V`. I would suggest changing the declaration to
>>
>>
>> class CompactHashtableWriter: public StackObj {
>> public:
>> class Entry {
>> unsigned int _hash;
>> - u4 _value;
>> + u4 _encoded_value;
>>
>>
>> All parameters of `offset` should be changed to `encoded_value`.
>>
>> This comment should be updated:
>>
>>
>> u4 encoded_value; // A 32-bit encoding of the template type V. The template parameter DECODE
>> // converts this to type V. Many CompactHashtables encode a pointer as a 32-bit offset, where
>> // V entry = (V)(base_address + offset)
>> // see StringTable, SymbolTable and AdapterHandlerLibrary for examples
>>
>>
>> I think we should consider a future clean up of adding an `ENCODE` template parameter so that the various table dumping functions can be consolidated.
>
>> All parameters of offset should be changed to encoded_value.
>
> I guess you mean change from `value` to encoded_value in `CompactHashtable`?
> I did not touch the parameter name `offset` in read_value_from_compact_hashtable (which is used in OffsetCompactHashtable), as I think it means `offset` intentionally.
> But please correct me if I'm understanding wrongly.
Modify from `offset`/`value` to `encoded_value` in CompactHashtable template parameters.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27360#discussion_r2373201842
More information about the hotspot-runtime-dev
mailing list