RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]
Chen Liang
liach at openjdk.org
Tue Jun 6 22:37:59 UTC 2023
On Tue, 6 Jun 2023 21:29:49 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
> I believe instead of changing the guards we can change the implementation of the static methods on the concrete static VHs to call `asDirect()` (lets also add `@ForceInline` on `asDirect`), since `linkToStatic` will pass the args to the static method described by the member name (since the lazy and direct VH handles share the same var form).
>
> That has the nice effect of pushing the complexity closer to where it is needed. Its subtle but i think can be explained. Thereby we can reduce the memory footprint for subsequent access modes. Perhaps we can even "zero" out the MH cache on initialization?
Is this aimed at decreasing long-term invocation cost or the initial invocation cost? FYI long-term invocation is already efficient enough; if this is for initial invocation, which can potentially bypass costly MH construction, I recommend creating an alternative method to `asDirect` for the purpose to be called and casted by X-VarHandle implementations.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13821#issuecomment-1579550628
More information about the core-libs-dev
mailing list