Am 19.02.2018 um 13:00 schrieb Vladimir Ivanov:
In both staticMethodHandle & lambdaMetafactory Dog::getName is inlined,
but using different mechanisms.
In staticMethodHandle target method is statically known , but in case
of lambdaMetafactory  compiler has to rely on profiling info to
devirtualize Function::apply(). The latter requires exact type check on
the receiver at runtime and that explains the difference you are seeing.
But comparing that with nonStaticMethodHandle is not fair: there's no
inlining happening there.
I actually never dared to ask, what kind of information is really
provided by the java compiler here to make the static version so fast?
Is it because the static final version becomes a member of the class
pool? Is the lambdafactory so fast, because here the handle will become
the member of the pool of the generated class? And is there a way for me
to bring nonStaticMethodHandle more near to staticMethodHandle, short of
making it static?
mlvm-dev mailing list