Le 24/11/2011 11:15, Jochen Theodorou a écrit :
Hi all,
I started implementing an invokedynamic port of Groovy, but I have two
"complex" questions early on:
(1) Groovy method selection depends on runtime types. This seems to
mean that I need a two step approach for my methods. On the first step
I let the bootstrap return a method handle, that will do the method
selection. In the second step I will replace the target in the call
site, with the now selected method. The result is that only on the
second invocation the real target method will be called directly and
on the first invocation this will happen through the selector. Is that
right?
Yes, only the second call will use the guard.
Does this also mean that if my target is for example Class.forName,
that it may use a different class loader on the next invocation?
(first time the one of the class containing my method selector method,
second time the class doing the method call originally)
the guard test if the class doesn't change, so if there is more than one
classloader,
it can be a different class so it will use the slow path.
(2) for convenience I currently use MethodHandle#asType a lot... is
that good practice or better to be avoided?
By design you have to use asType a lot because the callsite type and the
method handle type must match.
bye blackdrag
cheers,
Rémi
--
You received this message because you are subscribed to the Google Groups "JVM
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jvm-languages?hl=en.