RFR: 8254598: StringDedupTable should use OopStorage
Kim Barrett
kbarrett at openjdk.java.net
Sat May 1 09:48:54 UTC 2021
On Wed, 28 Apr 2021 06:44:58 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>> src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp line 557:
>>
>>> 555: // non-latin1, and deduplicating if we find a match. For deduplication we
>>> 556: // only care if the arrays consist of the same sequence of bytes.
>>> 557: const jchar* chars = static_cast<jchar*>(value->base(T_CHAR));
>>
>> The encoding of the shared strings always match CompactStrings. Otherwise the CDS archive will fail to map. E.g.,
>>
>>
>> $ java -XX:-CompactStrings -Xshare:dump
>> $ java -XX:+CompactStrings -Xlog:cds -version
>> ...
>> [0.032s][info][cds] UseSharedSpaces: The shared archive file's CompactStrings
>> setting (disabled) does not equal the current CompactStrings setting (enabled).
>> [0.032s][info][cds] UseSharedSpaces: Unable to map shared spaces
>> ...
>>
>>
>> So you can avoid this `if` block when `CompactStrings == true`. The `!java_lang_String::is_latin1(found)` check below can be changed to an assert.
>>
>> Also, I think we need an explicit test case where you'd return `true` at line 564. I can write a new test case and email to you. I think it will involve dumping an archive with `-XX:-CompactStrings`.
>
> Oh, I realized that my suggestion above is wrong. When `CompactStrings==true`, you can still have a string whose coder is UTF16:
>
> https://github.com/openjdk/jdk/blob/75a2354dc276e107d64516d20fc72bc7ef3d5f86/src/java.base/share/classes/java/lang/String.java#L343-L351
Correct.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3662
More information about the core-libs-dev
mailing list