Why is LambdaMetafactory 10% slower than a static MethodHandle but 80% faster than a non-static MethodHandle?
Jochen Theodorou
blackdrag at gmx.org
Mon Feb 19 12:28:06 UTC 2018
Am 19.02.2018 um 13:00 schrieb Vladimir Ivanov:
> Geoffrey,
>
> In both staticMethodHandle & lambdaMetafactory Dog::getName is inlined,
> but using different mechanisms.
>
> In staticMethodHandle target method is statically known [1], but in case
> of lambdaMetafactory [2] 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?
bye Jochen
More information about the mlvm-dev
mailing list