On Tue, 6 Jun 2023 22:34:57 GMT, Chen Liang <li...@openjdk.org> wrote:
> 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. It aims to reduce the cost of getting to peak performance (the work that C2 has to perform) and reduce the overall memory footprint of such VHs (as long as the user does not explicitly request MHs from them). Assuming of course that the peak performance is good! For this pattern i not sure we need to create another method returning the target that effectively does the same as `asDirect`, and instead it may come down to better naming and documentation of the concepts. There is already a tight coupling between the `LazyInitializingVarHandle` and its target via the sharing of the var forms. Renaming `asDirect` to `target` might do it, and we refine a what a direct handle is to mean the guards just pass along the handle that is given to it, otherwise we use a (lazily created) method handle to its target. Thereby a VH implementation free to switch between indirect and direct and is further free to deal with any implementation specific indirection in its own implementation. ------------- PR Comment: https://git.openjdk.org/jdk/pull/13821#issuecomment-1579631030