[aarch64-port-dev ] RFR(M): 8243392: Remodel CDS/Metaspace storage reservation

Nick Gasson nick.gasson at arm.com
Wed Apr 29 08:51:23 UTC 2020


On 04/29/20 16:36 pm, Andrew Haley wrote:
> On 4/29/20 8:47 AM, Nick Gasson wrote:
>> This makes the
>> relationship with the compressed class decode logic a bit clearer as the
>> restriction comes from the MOV and MOVK instructions we use to
>> decompress the pointer: we have to ensure the bits of the base and bits
>> of the offset after shifting do not overlap.
>
> This seems a bit crazy. Whyever would anyone want shifted
> CompressedKlassPointers with an offset? I guess I'm going to have to
> look very closely at this patch.

The compressed class shift is always set to LogKlassAlignmentInBytes
when CDS is enabled. It's for compatibility with AOT. See this comment
in Metaspace::set_narrow_klass_base_and_shift():

  // CDS uses LogKlassAlignmentInBytes for narrow_klass_shift. See
  // MetaspaceShared::initialize_dumptime_shared_and_meta_spaces() for
  // how dump time narrow_klass_shift is set. Although, CDS can work
  // with zero-shift mode also, to be consistent with AOT it uses
  // LogKlassAlignmentInBytes for klass shift so archived java heap objects
  // can be used at same time as AOT code.

For AOT this is set up in AOTGraalHotSpotVMConfig.java:

  // AOT captures VM settings during compilation. For compressed oops this
  // presents a problem for the case when the VM selects a zero-shift mode
  // (i.e., when the heap is less than 4G). Compiling an AOT binary with
  // zero-shift limits its usability. As such we force the shift to be
  // always equal to alignment to avoid emitting zero-shift AOT code.
  CompressEncoding vmOopEncoding = super.getOopEncoding();
  aotOopEncoding = new CompressEncoding(vmOopEncoding.getBase(), logMinObjAlignment());
  CompressEncoding vmKlassEncoding = super.getKlassEncoding();
  aotKlassEncoding = new CompressEncoding(vmKlassEncoding.getBase(), logKlassAlignment);

For compressed OOPs it makes sense because it allows a larger heap
without changing the encoding mode. But for compressed class pointers we
never need to address more than 4G so maybe it's better to use 0 shift
instead of logKlassAlignment above? With CDS the default shared base
address is 0x80000000 which doesn't allow a zero base anyway.


Thanks,
Nick


More information about the hotspot-dev mailing list