[master] RFR: 8368755: [Lilliput] Fix CompressedClassSpaceSize handling [v2]
Roman Kennke
rkennke at openjdk.org
Fri Sep 26 12:28:13 UTC 2025
On Fri, 26 Sep 2025 10:51:58 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> Roman Kennke has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Avoid hard-coding encoding range
>
> src/hotspot/share/runtime/arguments.cpp line 3772:
>
>> 3770: }
>> 3771: if (UseCompactObjectHeaders && FLAG_IS_DEFAULT(CompressedClassSpaceSize)) {
>> 3772: FLAG_SET_DEFAULT(CompressedClassSpaceSize, 512 * M);
>
> This may be a bit less ugly and hard-coded:
>
> Suggestion:
>
> FLAG_SET_DEFAULT(CompressedClassSpaceSize, CompressedKlassPointers::max_klass_range_size_coh);
>
>
> with this patch in addition:
>
>
> diff --git a/src/hotspot/share/oops/compressedKlass.cpp b/src/hotspot/share/oops/compressedKlass.cpp
> index d7c97d3c8d5..bf45f4ecd78 100644
> --- a/src/hotspot/share/oops/compressedKlass.cpp
> +++ b/src/hotspot/share/oops/compressedKlass.cpp
> @@ -47,6 +47,7 @@ size_t CompressedKlassPointers::_protection_zone_size = 0;
> size_t CompressedKlassPointers::max_klass_range_size() {
> #ifdef _LP64
> const size_t encoding_allows = nth_bit(narrow_klass_pointer_bits() + max_shift());
> + assert(!UseCompactObjectHeaders || max_klass_range_size_coh == encoding_allows, "Sanity");
> constexpr size_t cap = 4 * G;
> return MIN2(encoding_allows, cap);
> #else
> diff --git a/src/hotspot/share/oops/compressedKlass.hpp b/src/hotspot/share/oops/compressedKlass.hpp
> index 64b9fcf9c82..4f94675d8ed 100644
> --- a/src/hotspot/share/oops/compressedKlass.hpp
> +++ b/src/hotspot/share/oops/compressedKlass.hpp
> @@ -192,6 +192,10 @@ class CompressedKlassPointers : public AllStatic {
> // resulting from the current encoding settings (base, shift), capped to a certain max. value.
> static size_t max_klass_range_size();
>
> + // For use before pre-initialization
> + static constexpr size_t max_klass_range_size_coh =
> + nth_bit(narrow_klass_pointer_bits_coh + max_shift_coh);
> +
> // On 64-bit, we need the class space to confine Klass structures to the encoding range, which is determined
> // by bit size of narrowKlass IDs and the shift. On 32-bit, we support compressed class pointer only
> // "pro-forma": narrowKlass have the same size as addresses (32 bits), and therefore the encoding range is
Ok, good idea. It brings in a bunch of stuff from upstream JDK that is not yet present in Lilliput (yes, we're quite a bit behind atm...) but that is ok.
-------------
PR Review Comment: https://git.openjdk.org/lilliput/pull/203#discussion_r2382254800
More information about the lilliput-dev
mailing list