Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Going faster with InvokeDynamic

Going faster with InvokeDynamic

InvokeDynamic is a new instruction for the Java 7 VM which allows language implementers to handle method dispatch for any language quickly. This talk covers the basics of how it works and what it enables in JRuby 1.7

tarcieri

May 18, 2012
Tweet

More Decks by tarcieri

Other Decks in Programming

Transcript

  1. Compile to bytecode RUBY Ruby code becomes JVM instructions B

    Y T E C O D E B Y T E C O D E B Y T E C O D E B Y T E C O D E B Y T E C O D E
  2. HotSpot JITs too RUBY Ruby code becomes machine code B

    Y T E C O D E B Y T E C O D E 1 0 1 0 1 0 1 0 1 0 1 0
  3. Y U NO InvokeRuby? Y U NO InvokeGroovy? Y U

    NO InvokeJavaScript? Y U NO InvokeClojure?
  4. InDy •Shipped in Java 7 •Supported in JRuby 1.7 •JRuby

    1.7 release preview available next week!
  5. Bootstrap Method •Called on all classes that use InDy •Find

    MethodHandle to dispatch •Return CallSite object
  6. Bootstrap Method •Invoked the first time a call site is

    used •Resulting call site object is “bound” to where InDy was invoked and is used for subsequent calls •CallSites can designate their own caching behavior
  7. YES

  8. YES

  9. YES

  10. YES

  11. YES

  12. YES

  13. YES

  14. YES