RFR: 8367989: Remove InstanceKlass::allocate_objArray [v3]

Coleen Phillimore coleenp at openjdk.org
Fri Sep 19 14:30:02 UTC 2025


On Fri, 19 Sep 2025 13:18:09 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> This change removes InstanceKlass::allocate_objArray and has its caller call ObjArrayKlass::allocate_instance directly from oopFactory, like the other array allocations do.  See CR for more information why we should have this change.  I also removed element_klass_addr() and moved element_klass_offset() to be in a more logical place near element_klass() functions.  This upstreams a tiny valhalla diff.
>> Tested with tier1-4.
>
> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Use virtual function rather than if statement, still need one cast though.

src/hotspot/share/memory/oopFactory.cpp line 113:

> 111:   } else {
> 112:     return InstanceKlass::cast(klass)->allocate_objArray(1, length, THREAD);
> 113:   }

I suppose this has symmetry in the mainline, except both of these functions do the same thing as ObjArrayKlass.allocate_instance do.  The goal is to hide allocate_instance and only make this class a friend, and not InstanceKlass.  This isn't the case in the current repository but it is in the valhalla repo and I want them to be the same at this level.

So this isolates the CollectedHeap::array_allocate call to less places now.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27372#discussion_r2363081628


More information about the hotspot-dev mailing list