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

Stefan Karlsson stefank at openjdk.org
Fri Sep 19 13:28:35 UTC 2025


On Fri, 19 Sep 2025 11:33:00 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> It wasn't really symmetric except number of lines.  One branch calls ArrayKlass::allocate_arrayArray, the other calls allocate_instance for ObjArray.  Unless I refactor allocate_arrayArray into this, it still won't be symmetrical, and it's quite a bit different in the valhalla repo.
>
> It might make sense to refactor allocate_arrayArray into this though and remove that too.
> Yes, I like suggestion #1.  There are too many array allocation functions.

> It wasn't really symmetric except number of lines.

Given that you refuted my statement about symmetry I want to try to explain what symmetry I saw but you didn't:

The old code called allocate_xArray function in both branches. That was the symmetry. It was quite clear that the two functions accomplished similar goals, in similar ways. Yes, the functions called are named differently, but I didn't talk about absolute symmetry in characters of number of lines.

In the first proposed patch both branches call its corresponding array_klass function, but only one of the legs make it explicit, and the other has that deferred to the call to allocate_xArray function. I find that this kind of asymmetry often hurts readability and makes code harder to maintain. Hence my proposal. My 2c.

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

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


More information about the hotspot-dev mailing list