On Wed, 12 Aug 2026 21:57:07 GMT, Chris Plummer <[email protected]> wrote:

>> Yasumasa Suenaga has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Improve OopField::getOffset
>
> src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/OopField.java line 
> 64:
> 
>> 62:   public long getOffset() {
>> 63:     long ofs = super.getOffset();
>> 64:     if ((inlineKlass != null) || (inlineKlass == null && isFlat())) {
> 
> Can you explain a bit how this works. I thought an InstanceKlass that is 
> inlineable is marked as such, but that doesn't imply it will actually be 
> inlined (flattened) for every field reference. The field referencing the 
> inlineable class is marked as "flat" if it is actually flattened. How do we 
> end up with (inlineKlass == null && isFlat()) being true? I would think that 
> isFlat() being true would imply (inlineKlass != null) being true.

I've added this condition for followup bugs (FlatArray).

In FlatArray, I think we can traverse flattened array oop as following. We need 
to pass holder (element) Klass to `OopField`. In `Instance` (`oop`), `OopField` 
associates with the field owner, so `isFlat()` can work. OTOH `Inline` in 
`FlatArray` is just the value, and we need to instantiate `OopField` directly. 
It means we cannot access metadata - it is JDK-8247507. 


    FlatArrayKlass klass = (FlatArrayKlass)getKlass();
    InlineKlass elementKlass = (InlineKlass)klass.getElementKlass();

    for (int index = 0; index < length; index++) {
      long offset = baseOffset + (index * elementSize);
      OopField field = new OopField(new IndexableFieldIdentifier(index), 
offset, false, elementKlass);
      visitor.doOop(field, false);
    }


Hence we need to consider two conditions to detect vaule object:

1. `inlineKlass != null`: for FlatArray: `Klass` is injected in force.
2. `inlineKlass == null && isFlat()`: Flattened field in (normal) oop: we can 
access metadata via `isFlat()`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3771614870

Reply via email to