RFR: 8327156: Avoid copying in StringTable::intern(oop, TRAPS) [v3]

David Holmes dholmes at openjdk.org
Thu Oct 24 01:56:18 UTC 2024


On Wed, 23 Oct 2024 13:55:18 GMT, Casper Norrbin <cnorrbin at openjdk.org> wrote:

>> src/hotspot/share/classfile/stringTable.cpp line 473:
>> 
>>> 471: oop StringTable::intern(const char* utf8_string, TRAPS) {
>>> 472:   if (utf8_string == nullptr) return nullptr;
>>> 473:   int length = static_cast<int>(strlen(utf8_string));
>> 
>> Is the source for such a string always a constant pool entry, and so known to < 64K in length?
>
> I am not sure. The previous implementation stored length as `int`, so my assumption is that it would be fine. If it is a problem, I could take some time to change the various lengths to `size_t`s instead.

See the preamble in utf8.hpp. The unicode length of a utf8 string is assumed/required to fit in an int, but the raw utf8 length need not. Changing to use size_t may have a significant fanout however.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21325#discussion_r1814128014


More information about the hotspot-dev mailing list