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

Casper Norrbin cnorrbin at openjdk.org
Wed Oct 23 14:02:18 UTC 2024


On Tue, 22 Oct 2024 04:39:30 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Casper Norrbin has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   missed cleanup
>
> 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.

> test/hotspot/gtest/classfile/test_stringConversion.cpp line 35:
> 
>> 33: static const jchar static_ascii_unicode_str[] = {0x004A, 0x0061, 0x0076, 0x0061, 0x0028, 0x0052, 0x0029, 0x0021, 0x0021};
>> 34: 
>> 35: // Complex string " Jāvá®!☺☻ ", UTF8 has character lengths 13122133 = 16
> 
> Not sure it is okay to have those special characters in the source code. ??

Since the file is encoded in UTF8, my assumption is that it would be fine to have these. Someone with a primitive editor might see "���" or something similar instead though.

> test/hotspot/gtest/classfile/test_stringConversion.cpp line 36:
> 
>> 34: 
>> 35: // Complex string " Jāvá®!☺☻ ", UTF8 has character lengths 13122133 = 16
>> 36: static const unsigned char static_utf8_str[] = {0x4A, 0x61, 0xCC, 0x84, 0x76, 0xC3, 0xA1, 0xC2, 0xAE, 0x21, 0xE2, 0x98, 0xBA, 0xE2, 0x98, 0xBB};
> 
> 0x61 is `a` not a-with-tilde ??

'ā' in this case is an 'a' (0x61) followed by a [Combining Macron](https://www.compart.com/en/unicode/U+0304) '◌̄' (0xCC 0x84)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21325#discussion_r1812829225
PR Review Comment: https://git.openjdk.org/jdk/pull/21325#discussion_r1812835664
PR Review Comment: https://git.openjdk.org/jdk/pull/21325#discussion_r1812838984


More information about the hotspot-dev mailing list