blog post on invokedynamic
John.Rose at Sun.COM
Tue Feb 17 19:48:02 PST 2009
On Feb 17, 2009, at 2:41 AM, Tobias Ivarsson wrote:
> When the JRuby runtime recevies an object from PHP it casts it to
> IRubyObject (the main JRuby type) which is an injectable interface.
> If the class of the object does not already implement IRubyObject
> the injector for the interface is invoked. The injector is a regular
> java object that has a method for providing MethodHandles that make
> up the implementation methods for the interface. As in the case with
> the bootstrap method in invokedynamic this method can do whatever
> the language implementor chooses to get or define these
> MethodHandles. My recommendation in this case is for the injector to
> get the meta object from the PHP object and use that to lookup the
> MethodHandles for each capability that JRuby uses, and use default
> implementations where the meta object does not support the capability.
Yes, that sounds right. That way, each language decides what its
"native" object protocol looks like (IRubyObject, GroovyObject etc.).
The generic MOP provides a more language-neutral view of capability
lookup, but still supports useful correspondences across languages
about method/function call, property/variable access, basic scalar and
aggregate types, names (simple and structured), operators, and type
descriptors. If the MOP provides the right common ground, most
languages will be able to use it to inject their native object
protocols into "foreign" classes, providing useful bridges between
libraries coded in different languages. If the MOP provides the right
sorts of partial evaluation, and the native object protocol does also,
then performance techniques like inline caches will make the bridges
operate without speed penalties.
More information about the mlvm-dev