RFR: 8363996: Obsolete UseCompressedClassPointers [v4]
Ivan Walulya
iwalulya at openjdk.org
Mon Dec 8 13:31:12 UTC 2025
On Thu, 4 Dec 2025 13:36:43 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> _This patch is not intended for JDK 26_.
>>
>> I'm posting it now to collect feedback and, barring any objections, plan to push it once JDK 27 opens.
>>
>> This change removes the uncompressed Klass pointer mode and, with compressed Klass pointers remaining as the only option, the `UseCompressedClassPointers` switch.
>>
>> For motivation, please take a look at CSR associated with the deprecation (which we did for JDK 25) and the preparatory discussion we had at the start of the year around this topic [2].
>>
>> This patch is quite invasive and touches many parts of the JVM, since its goal is to remove most traces of the uncompressed Klass path and to take advantage of opportunities for simplification. In some cases, I did not take opportunities for further simplification to keep the patch somewhat legible; it will be onerous enough to review.
>>
>> ### Implementation Notes
>>
>> With uncompressed Klass pointers removed, we have three modes of operation left (including 32-bit):
>> a) 64-bit, COH off - this is the old `+UseCompressedClassPointers` mode. This is now the standard mode until we run with COH by default.
>> b) 64-bit, COH on
>> c) 32-bit - Here, we run with a "fake" narrow Klass pointer mode. We run with hardcoded narrowKlass base == NULL and shift = 0, so nKlass == Klass*. The difference to (a, b) is that we don't use a class space. This was implemented with JDK-8363998 [3] - for more details, please see that issue and its PR.
>>
>> I ensured *arm32* builds and I performed some rudimentary checks (selected metaspace/gc tests, and a simple Spring PetClinic run). Vendors with an interest in arm32 will have to step up and do their own, more thorough unit testing. Also, I did not see anyone doing follow-up work after JDK-8363998 [3] - so some issues may still lurk from that patch as well (but maybe JDK-8363998 was just not breaking anything).
>>
>> I did not check *zero 32-bit*, the only other platform supporting 32-bit. Anyone with an interest in 32-bit zero should chip in.
>>
>> Pre-existing errors: While working on this patch, I stumbled over a few occurrences of old but benign bugs. Mostly old code assuming CompressedClassPointers and CompressedOops were still tied together (example: Arguments::set_heap_size()). These bugs are implicitly fixed with this patch.
>>
>> ### Testing
>>
>> - tier 1 2 3 locally on Linux x64
>> - SAP ran their whole set of tests for all the platforms they support.
>>
>>
>> [1] https://bugs.openjdk.org/browse/JDK-8350754
>> [2...
>
> Thomas Stuefe has updated the pull request incrementally with one additional commit since the last revision:
>
> Update src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
>
> Co-authored-by: Andrew Haley <aph-open at littlepinkcloud.com>
src/hotspot/share/oops/instanceKlass.cpp line 492:
> 490: assert(CompressedKlassPointers::is_encodable(ik),
> 491: "Klass " PTR_FORMAT "needs a narrow Klass ID, but is not encodable", p2i(ik));
> 492: }
Suggestion:
assert(ik == nullptr || CompressedKlassPointers::is_encodable(ik),
"Klass " PTR_FORMAT "needs a narrow Klass ID, but is not encodable", p2i(ik));
src/hotspot/share/oops/oop.inline.hpp line 104:
> 102: return CompressedKlassPointers::decode_not_null(_metadata._compressed_klass);
> 103: default:
> 104: return _metadata._klass;
Suggestion:
ShouldNotReachHere();
src/hotspot/share/oops/oop.inline.hpp line 115:
> 113: return CompressedKlassPointers::decode(_metadata._compressed_klass);
> 114: default:
> 115: return _metadata._klass;
Suggestion:
ShouldNotReachHere();
src/hotspot/share/oops/oop.inline.hpp line 128:
> 126: }
> 127: default:
> 128: return AtomicAccess::load_acquire(&_metadata._klass);
Suggestion:
ShouldNotReachHere();
src/hotspot/share/oops/oop.inline.hpp line 139:
> 137: return CompressedKlassPointers::decode_without_asserts(_metadata._compressed_klass);
> 138: default:
> 139: return _metadata._klass;
klass_mode() is either `Compact` or `Compressed`
Should be changed to:
Suggestion:
ShouldNotReachHere();
src/hotspot/share/oops/oop.inline.hpp line 157:
> 155: assert(Universe::is_bootstrapping() || (k != nullptr && k->is_klass()), "incorrect Klass");
> 156: assert(!UseCompactObjectHeaders, "don't set Klass* with compact headers");
> 157: _metadata._compressed_klass = CompressedKlassPointers::encode_not_null(k);
We might have to reconsider if we need to maintain the`union _metadata`
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28366#discussion_r2598158553
PR Review Comment: https://git.openjdk.org/jdk/pull/28366#discussion_r2598641735
PR Review Comment: https://git.openjdk.org/jdk/pull/28366#discussion_r2598409080
PR Review Comment: https://git.openjdk.org/jdk/pull/28366#discussion_r2598413848
PR Review Comment: https://git.openjdk.org/jdk/pull/28366#discussion_r2598407527
PR Review Comment: https://git.openjdk.org/jdk/pull/28366#discussion_r2598474672
More information about the core-libs-dev
mailing list