RFR: 8329433: Reduce nmethod header size [v4]

Vladimir Kozlov kvn at openjdk.org
Tue Apr 16 22:15:02 UTC 2024


On Tue, 16 Apr 2024 19:47:06 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> Okay.
>
> It is tempting to do for `nmethod` to replace `init_defaults()`. I will look what can be done.

It does not work. It does not allow fields initialization after delegation:

src/hotspot/share/code/nmethod.cpp: In constructor 'nmethod::nmethod(Method*, CompilerType, int, int, CodeOffsets*, CodeBuffer*, int, ByteSize, ByteSize, OopMapSet*)':
src/hotspot/share/code/nmethod.cpp:1232:56: error: mem-initializer for 'nmethod::<unnamed union>::<unnamed struct>::_native_receiver_sp_offset' follows constructor delegation


Yes, I can move some fields initialization into body - but then it will be duplicated initialization.
>From reading net, the delegated constructor should take the largest number of arguments which default values are set by delegating constructors. It is not easy applicable to `nmethod` constructors - it will add more lines of code than remove. `nmethod` constructors we have are too big and different enough that delegation will not improve code.

I will keep `init_defaults()` and extend it to reduce common code in constructors.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18768#discussion_r1567992881


More information about the serviceability-dev mailing list