On Wed, May 18, 2011 at 5:34 AM, Szymon Jachim <sjac...@gmail.com> wrote:
> I have to questions to you guys about possible (and planned) JIT
> optimizations for MethodHandles.
> 1. Assuming that there will be a chain of MH's:
>       mh1(invoker) -> mh2 -> aMethod()
>    and there will be no other references to mh2. Will JIT/GC be able to
> optimize unneeded mh2 and put into callsites a direct call to aMethod?

Yes. The current JDK builds should already do this for most MH types,
and others are landing every day.

> 2. Assuming second situation:
>   mh1(dynamicInvoker() product) -> MutableCallSite -> mh2(constant()
> product) -> integer constant
> After calculating the constant value and doing setTarget() there will be no
> longer any other references to MCS and mh2, so MCS is effectively
> immutable. Will they get optimized away and/or garbage collected?
> This could be useful to implement efficient lazy initialized data
> structures. The call site cannot be ConstantCallSite, becouse the value is
> calculated in runtime by a non static methods...
> I think this is similar problem to what Headius described here recently.
> Thanks,

As Rémi replied, ideally there should be no cost from having a
MutableCallSite rather than a ConstantCallSite. However I believe with
Christian was inspecting JRuby+indy assembly output, there's still a
guard emitted for each MutableCallSite. He said he thought this would
go away eventually and be replaced with an external deoptimization
trigger.

As for dynamicInvoker to MutableCallSite...I'm not sure if that will
inline or not. In theory it seems like it should (and it would sure be
nice) but I'm not sure if it does right now.

- Charlie

> Szymon
>
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev@openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
>
>
_______________________________________________
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Reply via email to