On Thu, 29 Aug 2024 12:08:37 GMT, Coleen Phillimore <cole...@openjdk.org> wrote:
>> This change stores InstanceKlass for interface and abstract classes in the >> non-class metaspace, since class metaspace will have limits on number of >> classes that can be represented when Lilliput changes go in. Classes that >> have no instances created for them don't require compressed class pointers. >> The generated LambdaForm classes are also AllStatic, and changing them to >> abstract moves them to non-class metaspace too. It's not technically great >> to make them abstract and not final but you can't have both. Java classfile >> access flags have no way of specifying something like AllStatic. >> >> Tested with tier1-8. > > Coleen Phillimore has updated the pull request incrementally with one > additional commit since the last revision: > > Add function in Metaspace to tell you if Klass pointer is in compressible > space. I still worry about unforeseen implications of not every Klass having an nKlass. It will have some implications on some of my Lilliput work. I wish we could have done this earlier. But in any case, this seems to be a reasonable way forward. One remark inline, otherwise this looks mostly good to me. src/hotspot/share/memory/metaspace.hpp line 165: > 163: return using_class_space() && (is_in_class_space(k) || > is_in_shared_metaspace(k)); > 164: } > 165: I propose to drop this, and instead add a utility function to `CompressedKlassPointers` like this: // Returns true if p falls into the narrow Klass encoding range inline bool CompressedKlassPointers::is_in_encoding_range(const void* p) { return _base != nullptr && p >= _base && p < (_base + _range); } (Probably the `_base != nullptr` could even be left out, since `_range==0` and `_base==nullptr` for -UseCompressedClassPointers) And then use that function in `jfrTraceIdKlass.cpp`. That file needs to use `CompressedKlassPointers` anyway because it needs to encode the Klass*. This avoids having to rely on the exact composition of the memory regions inside the encoding range. What counts is whether the Klass pointer points into the narrow Klass encoding range. Essentially, with CDS, memory looks like this: encoding encoding base end |-----------------------------------------------------------------------| |----CDS---| |--------------------class space---------------------------| ------------- PR Review: https://git.openjdk.org/jdk/pull/19157#pullrequestreview-2285987065 PR Review Comment: https://git.openjdk.org/jdk/pull/19157#discussion_r1746943501