On Sat, Jun 5, 2010 at 2:06 PM, Kresten Krab Thorup <[email protected]> wrote:
> Oh, btw, ...
>
> In HotRuby I do the same.  The codegen for X + B is  X.fast_plus(B,
> SEL_PLUS).  (SEL_PLUS is statically allocated "Selector" object which
> is akin to a CallSite object)   And then fast_plus is implemented as a
> normal dispatch in RubyObject:
>
>        public IRubyObject fast_plus(IRubyObject arg, Selector selector) {
>                return this.do_select(selector).call(this, arg);
>        }

Yup, that looks familiar...I've prototyped this a few times but never
felt like I wanted to special-case arithmetic quite yet. Now that
other Ruby implementations are starting to catch up on performance,
it's time to start tweaking again :)

> See: 
> http://github.com/krestenkrab/hotruby/blob/master/modules/vm-loaded/src/com/trifork/hotruby/objects/RubyObject.java#L153
>
> In RubyFixnum, it knows you're in an arithmetic plus:
>
> http://github.com/krestenkrab/hotruby/blob/master/modules/vm-loaded/src/com/trifork/hotruby/objects/RubyFixnum.java#L107
>
> So the technique should be adaptable to JRuby as well.

Actually I had a much more ambitious idea at one point that depended
on interface injection:

* For each method name in the system, generate a one-method (or
N-method, if splitting up arities) interface that takes all
IRubyObject and returns IRubyObject
* As new methods are defined, add additional interfaces
* Compiled invocation of any dynamic method then is done by calling
against the appropriate one-method interface, injecting it if it has
not yet been injected

As the system reaches a steady state, all classes implement N
interfaces for the N method names they define, and dispatch is as fast
as interface injection will allow it to be for all calls.

It's perhaps a gross perversion of interface injection, but I thought
it was a cute idea :)

- Charlie

-- 
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.

Reply via email to