On Tue, 20 Aug 2024 10:07:26 GMT, Roman Kennke <[email protected]> wrote:
> This is the main body of the JEP 450: Compact Object Headers (Experimental).
>
> Main changes:
> - Introduction of the (experimental) flag UseCompactObjectHeaders. All
> changes in this PR are protected by this flag. The purpose of the flag is to
> provide a fallback, in case that users unexpectedly observe problems with the
> new implementation. The intention is that this flag will remain experimental
> and opt-in for at least one release, then make it on-by-default and
> diagnostic (?), and eventually deprecate and obsolete it. However, there are
> a few unknowns in that plan, specifically, we may want to further improve
> compact headers to 4 bytes, we are planning to enhance the Klass* encoding to
> support virtually unlimited number of Klasses, at which point we could also
> obsolete UseCompressedClassPointers.
> - The compressed Klass* can now be stored in the mark-word of objects. In
> order to be able to do this, we are building on #20603 and #20605 to protect
> the relevant (upper 32) bits of the mark-word. Significant parts of this PR
> deal with loading the compressed Klass* from the mark-word. This PR also
> changes some code paths (mostly in GCs) to be more careful when accessing
> Klass* (or mark-word or size) to be able to fetch it from the forwardee in
> case the object is forwarded.
> - The identity hash-code is temporarily narrowed to 25 bits. As soon as we
> get Tiny Class-Pointers (planned before the JEP can be integrated, and to be
> opened for review soon), we will widen the hash-bits back to 31 bits.
> - Instances can now have their base-offset (the offset where the field
> layouter starts to place fields) at offset 8 (instead of 12 or 16).
> - Arrays will can now store their length at offset 8.
> - CDS can now write and read archives with the compressed header. However,
> it is not possible to read an archive that has been written with an opposite
> setting of UseCompactObjectHeaders. Some build machinery is added so that
> _coh variants of CDS archives are generated, next to the _nocoops variant.
> - Note that oopDesc::klass_offset_in_bytes() is not used by +UCOH paths
> anymore. The only exception is C2, which uses it as a placeholder/identifier
> of the special memory slice that only LoadNKlass uses. The backend then
> extracts the original oop and loads its mark-word and extracts the
> narrow-Klass* from that. I played with other approaches to implement
> LoadNKlass. Expanding it as a macro did not easily work, because C2 is
> missing a way to cast a word-sized integral to a narrow-Klass* (o...
src/hotspot/share/opto/library_call.cpp line 4631:
> 4629: // vm: see markWord.hpp.
> 4630: Node *hash_mask = _gvn.intcon(UseCompactObjectHeaders ?
> markWord::hash_mask_compact : markWord::hash_mask);
> 4631: Node *hash_shift = _gvn.intcon(UseCompactObjectHeaders ?
> markWord::hash_shift_compact : markWord::hash_shift);
Could you please export these two symbols to JVMCI? Thanks!
diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp
b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp
index 688691fb976..d97fdcb3f44 100644
--- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp
+++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp
@@ -792,11 +792,13 @@
declare_constant(InvocationCounter::count_shift) \
\
declare_constant(markWord::hash_shift) \
+ declare_constant(markWord::hash_shift_compact) \
declare_constant(markWord::monitor_value) \
\
declare_constant(markWord::lock_mask_in_place) \
declare_constant(markWord::age_mask_in_place) \
declare_constant(markWord::hash_mask) \
+ declare_constant(markWord::hash_mask_compact) \
declare_constant(markWord::hash_mask_in_place) \
\
declare_constant(markWord::unlocked_value) \
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20640#discussion_r1725162361