RFR: 8139457: Array bases are aligned at HeapWord granularity [v50]

Albert Mingkun Yang ayang at openjdk.org
Mon Aug 21 10:28:44 UTC 2023


On Thu, 17 Aug 2023 18:55:13 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

> Maybe it makes sense to move out header_size() to avoid the confusion?

I believe so. Having header-bytes aligned up to word sounds like sth the caller interests, not callee.

> It could, but it doesn't seem to be a good fit because a narrowKlass is not a ptr. narrowKlass are explicitly only
a 32bit int value and should be treated as such.

That would get rid of the trailing zero-gap later, right?


  else if (UseCompressedClassPointers) {
    xorptr(t1, t1);
    store_klass_gap(obj, t1);
  }


> If the gap is not used by instance fields or array elements, they don't actually belong to neither the header nor to the payload.

It boils down to the def. of "header".

Option 1: `header == markword + klass + (length)         ==> array/obj == header + (gap) + payload/body`
Option 2: `header == markword + klass + (length) + (gap) ==> array/obj == header + payload/body`

It's kind of a preexisting issue though.

> and I believe C2 would not clear it in any case

I used a simple class to test.


class A {
  long x;
}


In the C2 assembly, I believe the following three instructions correspond to markword, klass and the gap.


  0x00007f7eccad9c60:   mov    QWORD PTR [rax],0x1
  0x00007f7eccad9c67:   mov    DWORD PTR [rax+0x8],0x80208210;   {metadata('hello$A')}
  0x00007f7eccad9c6e:   mov    DWORD PTR [rax+0xc],0x0


(Ofc, I may have missed some jvm flags; the corresponding source `PhaseMacroExpand::initialize_object` is not obvious to me.)

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/11044#discussion_r1299922319


More information about the hotspot-dev mailing list