SlideShare a Scribd company logo
InvokeDynamic
 Your API for HotSpot


       Tony Arcieri
        Boundary
    October 11th, 2012
Who am I?
Who am I?
Our story begins...
Once upon a time...

Java was slow
Anamorphic
Anamorphic
StrongTalk
Anamorphic
   StrongTalk

• Optional static typing
• Modern garbage collector
• JIT compiler
Anamorphic   Sun Microsystems
StrongTalk         Java
Anamorphic      Sun Microsystems
StrongTalk            Java


       Stolen legacy!
Anamorphic      Sun Microsystems
StrongTalk            Java


       Stolen legacy!
Anamorphic      Sun Microsystems
StrongTalk            Java


       Stolen legacy!
Invoke dynamic your api to hotspot
HotSpot
JIT
Just-In-Time
     Compiler

Compile When Code Runs
JIT Spectrum
JIT Spectrum
Eager                  Lazy
JIT Spectrum
Eager                     Lazy



                    V8
CLR
                         HotSpot
  HiPE
JIT Spectrum
Eager                                  Lazy



                                V8
CLR
                                     HotSpot
   HiPE

 Static Optimizations   Runtime Optimizations
HotSpot


• C1: Client Compiler
• C2: Server Compiler
HotSpot

• C1: Client Compiler
• C2: Server Compiler
• -XX:+TieredCompilation
Mixed Mode
  Profiling JIT
Start by interpreting
JVM “emulates” bytecodes in userspace




              BYTECODE
Locate “hot spots”
Using runtime profiling information




            BYTECODE
Generate machine code
 Compile JVM bytecode to native ISA
          after 10,000 calls


  1       1              1   1    1
  0       0              0   0    0
  1       1   BYTECODE   1   1    1
  0       0              0   0    0
Optimizations
• Inlining methods
• Unrolling loops
• Eliding locks
• Eliminating dead code
• Escape analysis
Optimizations
• Inlining methods
• Unrolling loops
• Eliding locks
• Eliminating dead code
• Escape analysis
Inlining
Combine and optimize across calls


       Method 1

         CALL      Method 2
Inlining
Combine and optimize across calls


             Method 1


             Method 2
Call Sites
Where the magic happens...




        CALL
Call Sites


• Profile data
• Monomorphic inline cache
• Polymorphic inline cache
“Shapes”
Monomorphic
Only one type seen at call site




      A
          CALL
Bimorphic
Two types seen at call site




    A
        CALL         B
Polymorphic
Many types seen at call site




     A
         CALLB       C
Megamorphic
Too many types seen at call site



            F       D
       A
           CALL
           E G
                B       C
Inlining

• Measure invocations and branches
• Make an educated guess
• Inline the code in question
• Back out if we guessed wrong
Deopt

• Check invariants at a “safe point”
• Did we guess wrong?
• Revert optimization and try again
JVM Limitations
Made for Java

  • InvokeVirtual
  • InvokeInterface
  • InvokeStatic
  • InvokeSpecial
Non-Java call sites are
 opaque to HotSpot
       Can’t be inlined

     Method 1

       CALL       Method 2
Teach HotSpot?
See through non-Java call sites


     Method 1

       CALL       Method 2
Inline just like Java

        Method 1


        Method 2
What if it worked for
 any language?
Even Ruby?
InvokeDynamic
InDy
InDy

• JSR-292: “Supporting Dynamically
  Typed Languages on the Java Platform”

• Initial version shipped in Java 7
• Feeds directly into HotSpot in Java 8
New JVM
instruction
java.lang.invoke
InvokeDynamic
InvokeDynamic
InvokeDynamic
“User defined
data endpoint”
JVM Data Endpoints

  • Invoke operations
  • Array element access
  • Property lookup
  • And more!
InDy Use Cases

• Custom invocation
• “Constant” values (e.g.
  globals, language intrinsics)

• Scoped values (e.g.
  instance variables)
InDy




How does it work?
Pieces of InDy

• Bootstrap methods
• Call sites
• Method handles
• Switch points
Bootstrap method
Bootstrap method
   Wire up the call site
Bootstrap method
    Your own code!
Bootstrap Method

• Called the first time each InDy call
  site is used

• Find MethodHandle to dispatch
• Return CallSite object
Call Site
Replaces InDy instruction in bytecode
Call Site
Holds onto a chain of MethodHandles
java.lang.invoke.CallSite

 • ConstantCallSite: unchangeable
 • VolatileCallSite: seen coherently
   across cores

 • MutableCallSite: may appear
   different across cores
Any of those can be
    subclassed
java.lang.invoke.MethodHandle


   • Directly executable reference to a
     Java method (i.e. fast-as-Java)

   • Inlineable by HotSpot
   • MethodHandles all the way down
Methods are first-
 class objects
Project Lambda
     Lambdas for the JVM
Coming in Java 8! (Summer 2013)
Guarded Invocation
Guarded Invocation


MethodHandle.guardWithTest(
! MethodHandle test,
! MethodHandle target,
! MethodHandle fallback
)
fallback can rebind
     the call site
 Handle new types as they’re seen
SwitchPoints
SwitchPoints

SwitchPoint.guardWithTest(
! MethodHandle target,
! MethodHandle fallback
)

SwitchPoint.invalidateAll(
! SwitchPoint[]
)
java.lang.invoke.SwitchPoint


 • Publish events across threads (e.g.
   blow caches when classes change)

 • Only event is valid -> invalid
 • Hooks directly into the HotSpot
   deoptimizer (no additional branches)
Putting it together
Invocation example

CallSite: where the call is taking place
Invocation example

CallSite: where the call is taking place
  SwitchPoint: did the class change?
Invocation example

CallSite: where the call is taking place
  SwitchPoint: did the class change?
   GuardWithTest: is this the type we bound?
Invocation example

CallSite: where the call is taking place
  SwitchPoint: did the class change?
   GuardWithTest: is this the type we bound?
     Target: invoke the target method
Invocation example

CallSite: where the call is taking place
  SwitchPoint: did the class change?
   GuardWithTest: is this the type we bound?
     Target: invoke the target method
     - or -
     Rebind: lookup new method and rebuild call site
Invocation example

CallSite: where the call is taking place
  SwitchPoint: did the class change?
   GuardWithTest: is this the type we bound?
     Target: invoke the target method
      - or -
      Rebind: lookup new method and rebuild call site
    - or -
    Rebind: lookup potentially changed methods
InDy in the real world
Is it good?
 To the assembly!
Enabling ASM output


java -XX:+UnlockDiagnosticVMOptions
    -XX:+PrintAssembly
Contrived Ruby code

   def foo; 1; end
   def invoker; foo; end
   i = 0
   while i < 10000
     invoker
     i+=1
   end
0x00000001060a1be0: mov    %eax,-0x14000(%rsp)
  0x00000001060a1be7: push   %rbp
  0x00000001060a1be8: sub    $0x30,%rsp          ;*synchronization entry
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)
  0x00000001060a1bec: mov    0x8(%rcx),%r10d     ; implicit exception: dispatches to 0x00000001060a1c55
  0x00000001060a1bf0: cmp    $0xfb7aedc9,%r10d ;     {oop('org/jruby/RubyObject')}
  0x00000001060a1bf7: jne    0x00000001060a1c39
  0x00000001060a1bf9: mov    %rcx,%r10           ;*checkcast
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1bfc: mov    0x10(%r10),%ebp     ;*getfield metaClass
                                                ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c00: cmp    $0xfed77602,%ebp    ;   {oop(a 'org/jruby/MetaClass')}
  0x00000001060a1c06: jne    0x00000001060a1c1e ;*if_acmpne
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn
                                                ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@6
                                                ; - java.lang.invoke.MethodHandle::invokeExact@31
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
                                                ;    {oop(a 'org/jruby/RubyFixnum')}
  0x00000001060a1c12: add    $0x30,%rsp
  0x00000001060a1c16: pop    %rbp
  0x00000001060a1c17: test   %eax,-0xec3c1d(%rip)         # 0x00000001051de000
                                                ;    {poll_return}
  0x00000001060a1c1d: retq
0x00000001060a1be0: mov
  0x00000001060a1be7: push
                             %eax,-0x14000(%rsp)
                             %rbp
                                                   Stack juggling
  0x00000001060a1be8: sub    $0x30,%rsp          ;*synchronization entry
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)
  0x00000001060a1bec: mov    0x8(%rcx),%r10d     ; implicit exception: dispatches to 0x00000001060a1c55
  0x00000001060a1bf0: cmp    $0xfb7aedc9,%r10d ;     {oop('org/jruby/RubyObject')}
  0x00000001060a1bf7: jne    0x00000001060a1c39
  0x00000001060a1bf9: mov    %rcx,%r10           ;*checkcast
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1bfc: mov    0x10(%r10),%ebp     ;*getfield metaClass
                                                ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c00: cmp    $0xfed77602,%ebp    ;   {oop(a 'org/jruby/MetaClass')}
  0x00000001060a1c06: jne    0x00000001060a1c1e ;*if_acmpne
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn
                                                ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@6
                                                ; - java.lang.invoke.MethodHandle::invokeExact@31
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
                                                ;    {oop(a 'org/jruby/RubyFixnum')}
  0x00000001060a1c12: add    $0x30,%rsp
  0x00000001060a1c16: pop    %rbp
  0x00000001060a1c17: test   %eax,-0xec3c1d(%rip)         # 0x00000001051de000
                                                ;    {poll_return}
  0x00000001060a1c1d: retq
0x00000001060a1be0: mov
  0x00000001060a1be7: push
                             %eax,-0x14000(%rsp)
                             %rbp
                                                 Is “self” a Ruby object?
  0x00000001060a1be8: sub    $0x30,%rsp          ;*synchronization entry
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)
  0x00000001060a1bec: mov    0x8(%rcx),%r10d     ; implicit exception: dispatches to 0x00000001060a1c55
  0x00000001060a1bf0: cmp    $0xfb7aedc9,%r10d ;     {oop('org/jruby/RubyObject')}
  0x00000001060a1bf7: jne    0x00000001060a1c39
  0x00000001060a1bf9: mov    %rcx,%r10           ;*checkcast
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1bfc: mov    0x10(%r10),%ebp     ;*getfield metaClass
                                                ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c00: cmp    $0xfed77602,%ebp    ;   {oop(a 'org/jruby/MetaClass')}
  0x00000001060a1c06: jne    0x00000001060a1c1e ;*if_acmpne
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn
                                                ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@6
                                                ; - java.lang.invoke.MethodHandle::invokeExact@31
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
                                                ;    {oop(a 'org/jruby/RubyFixnum')}
  0x00000001060a1c12: add    $0x30,%rsp
  0x00000001060a1c16: pop    %rbp
  0x00000001060a1c17: test   %eax,-0xec3c1d(%rip)         # 0x00000001051de000
                                                ;    {poll_return}
  0x00000001060a1c1d: retq
0x00000001060a1be0: mov
  0x00000001060a1be7: push
                             %eax,-0x14000(%rsp)
                             %rbp
                                                 Same metaclass as before?
  0x00000001060a1be8: sub    $0x30,%rsp          ;*synchronization entry
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)
  0x00000001060a1bec: mov    0x8(%rcx),%r10d     ; implicit exception: dispatches to 0x00000001060a1c55
  0x00000001060a1bf0: cmp    $0xfb7aedc9,%r10d ;     {oop('org/jruby/RubyObject')}
  0x00000001060a1bf7: jne    0x00000001060a1c39
  0x00000001060a1bf9: mov    %rcx,%r10           ;*checkcast
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1bfc: mov    0x10(%r10),%ebp     ;*getfield metaClass
                                                ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c00: cmp    $0xfed77602,%ebp    ;   {oop(a 'org/jruby/MetaClass')}
  0x00000001060a1c06: jne    0x00000001060a1c1e ;*if_acmpne
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn
                                                ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@6
                                                ; - java.lang.invoke.MethodHandle::invokeExact@31
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
                                                ;    {oop(a 'org/jruby/RubyFixnum')}
  0x00000001060a1c12: add    $0x30,%rsp
  0x00000001060a1c16: pop    %rbp
  0x00000001060a1c17: test   %eax,-0xec3c1d(%rip)         # 0x00000001051de000
                                                ;    {poll_return}
  0x00000001060a1c1d: retq
0x00000001060a1be0: mov
  0x00000001060a1be7: push
                             %eax,-0x14000(%rsp)
                             %rbp
                                                 Store Fixnum “1” for return
  0x00000001060a1be8: sub    $0x30,%rsp          ;*synchronization entry
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)
  0x00000001060a1bec: mov    0x8(%rcx),%r10d     ; implicit exception: dispatches to 0x00000001060a1c55
  0x00000001060a1bf0: cmp    $0xfb7aedc9,%r10d ;     {oop('org/jruby/RubyObject')}
  0x00000001060a1bf7: jne    0x00000001060a1c39
  0x00000001060a1bf9: mov    %rcx,%r10           ;*checkcast
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1bfc: mov    0x10(%r10),%ebp     ;*getfield metaClass
                                                ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c00: cmp    $0xfed77602,%ebp    ;   {oop(a 'org/jruby/MetaClass')}
  0x00000001060a1c06: jne    0x00000001060a1c1e ;*if_acmpne
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn
                                                ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@6
                                                ; - java.lang.invoke.MethodHandle::invokeExact@31
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
                                                ;    {oop(a 'org/jruby/RubyFixnum')}
  0x00000001060a1c12: add    $0x30,%rsp
  0x00000001060a1c16: pop    %rbp
  0x00000001060a1c17: test   %eax,-0xec3c1d(%rip)         # 0x00000001051de000
                                                ;    {poll_return}
  0x00000001060a1c1d: retq
0x00000001060a1be0: mov
  0x00000001060a1be7: push
                             %eax,-0x14000(%rsp)
                             %rbp
                                                 Note: inside the “foo” method
  0x00000001060a1be8: sub    $0x30,%rsp          ;*synchronization entry
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)
  0x00000001060a1bec: mov    0x8(%rcx),%r10d     ; implicit exception: dispatches to 0x00000001060a1c55
  0x00000001060a1bf0: cmp    $0xfb7aedc9,%r10d ;     {oop('org/jruby/RubyObject')}
  0x00000001060a1bf7: jne    0x00000001060a1c39
  0x00000001060a1bf9: mov    %rcx,%r10           ;*checkcast
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1bfc: mov    0x10(%r10),%ebp     ;*getfield metaClass
                                                ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c00: cmp    $0xfed77602,%ebp    ;   {oop(a 'org/jruby/MetaClass')}
  0x00000001060a1c06: jne    0x00000001060a1c1e ;*if_acmpne
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn
                                                ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@6
                                                ; - java.lang.invoke.MethodHandle::invokeExact@31
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
                                                ;    {oop(a 'org/jruby/RubyFixnum')}
  0x00000001060a1c12: add    $0x30,%rsp
  0x00000001060a1c16: pop    %rbp
  0x00000001060a1c17: test   %eax,-0xec3c1d(%rip)         # 0x00000001051de000
                                                ;    {poll_return}
  0x00000001060a1c1d: retq
0x00000001060a1be0: mov
  0x00000001060a1be7: push
                             %eax,-0x14000(%rsp)
                             %rbp
                                                 Stack juggling
  0x00000001060a1be8: sub    $0x30,%rsp          ;*synchronization entry
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)
  0x00000001060a1bec: mov    0x8(%rcx),%r10d     ; implicit exception: dispatches to 0x00000001060a1c55
  0x00000001060a1bf0: cmp    $0xfb7aedc9,%r10d ;     {oop('org/jruby/RubyObject')}
  0x00000001060a1bf7: jne    0x00000001060a1c39
  0x00000001060a1bf9: mov    %rcx,%r10           ;*checkcast
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1bfc: mov    0x10(%r10),%ebp     ;*getfield metaClass
                                                ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c00: cmp    $0xfed77602,%ebp    ;   {oop(a 'org/jruby/MetaClass')}
  0x00000001060a1c06: jne    0x00000001060a1c1e ;*if_acmpne
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn
                                                ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@6
                                                ; - java.lang.invoke.MethodHandle::invokeExact@31
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
                                                ;    {oop(a 'org/jruby/RubyFixnum')}
  0x00000001060a1c12: add    $0x30,%rsp
  0x00000001060a1c16: pop    %rbp
  0x00000001060a1c17: test   %eax,-0xec3c1d(%rip)         # 0x00000001051de000
                                                ;    {poll_return}
  0x00000001060a1c1d: retq
0x00000001060a1be0: mov
  0x00000001060a1be7: push
                             %eax,-0x14000(%rsp)
                             %rbp
                                                 Safe point check
  0x00000001060a1be8: sub    $0x30,%rsp          ;*synchronization entry
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)
  0x00000001060a1bec: mov    0x8(%rcx),%r10d     ; implicit exception: dispatches to 0x00000001060a1c55
  0x00000001060a1bf0: cmp    $0xfb7aedc9,%r10d ;     {oop('org/jruby/RubyObject')}
  0x00000001060a1bf7: jne    0x00000001060a1c39
  0x00000001060a1bf9: mov    %rcx,%r10           ;*checkcast
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1bfc: mov    0x10(%r10),%ebp     ;*getfield metaClass
                                                ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c00: cmp    $0xfed77602,%ebp    ;   {oop(a 'org/jruby/MetaClass')}
  0x00000001060a1c06: jne    0x00000001060a1c1e ;*if_acmpne
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn
                                                ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@6
                                                ; - java.lang.invoke.MethodHandle::invokeExact@31
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
                                                ;    {oop(a 'org/jruby/RubyFixnum')}
  0x00000001060a1c12: add    $0x30,%rsp
  0x00000001060a1c16: pop    %rbp
  0x00000001060a1c17: test   %eax,-0xec3c1d(%rip)         # 0x00000001051de000
                                                ;    {poll_return}
  0x00000001060a1c1d: retq
0x00000001060a1be0: mov
  0x00000001060a1be7: push
                             %eax,-0x14000(%rsp)
                             %rbp
                                                 Done!
  0x00000001060a1be8: sub    $0x30,%rsp          ;*synchronization entry
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)
  0x00000001060a1bec: mov    0x8(%rcx),%r10d     ; implicit exception: dispatches to 0x00000001060a1c55
  0x00000001060a1bf0: cmp    $0xfb7aedc9,%r10d ;     {oop('org/jruby/RubyObject')}
  0x00000001060a1bf7: jne    0x00000001060a1c39
  0x00000001060a1bf9: mov    %rcx,%r10           ;*checkcast
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1bfc: mov    0x10(%r10),%ebp     ;*getfield metaClass
                                                ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c00: cmp    $0xfed77602,%ebp    ;   {oop(a 'org/jruby/MetaClass')}
  0x00000001060a1c06: jne    0x00000001060a1c1e ;*if_acmpne
                                                ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@3
                                                ; - java.lang.invoke.MethodHandle::invokeExact@5
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
  0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn
                                                ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)
                                                ; - java.lang.invoke.MethodHandle::invokeExact@6
                                                ; - java.lang.invoke.MethodHandle::invokeExact@31
                                                ; - java.lang.invoke.MethodHandle::invokeExact@29
                                                ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)
                                                ;    {oop(a 'org/jruby/RubyFixnum')}
  0x00000001060a1c12: add    $0x30,%rsp
  0x00000001060a1c16: pop    %rbp
  0x00000001060a1c17: test   %eax,-0xec3c1d(%rip)         # 0x00000001051de000
                                                ;    {poll_return}
  0x00000001060a1c1d: retq
Benchmarks
Invoke dynamic your api to hotspot
Invoke dynamic your api to hotspot
That’s it!
Twitter:
      @bascule

    Celluloid:
   celluloid.io

       Blog:
unlimitednovelty.com

More Related Content

What's hot (20)

PDF
Rocket Fuelled Cucumbers
Joseph Wilk
 
PPTX
FOSDEM2016 - Ruby and OMR
Charlie Gracie
 
PDF
Lambda: A Peek Under The Hood - Brian Goetz
JAX London
 
PDF
Smashing the stack with Hydra
pratap21
 
PPTX
Dependency injection
housecor
 
PDF
JRuby and Invokedynamic - Japan JUG 2015
Charles Nutter
 
KEY
Rails console
Reuven Lerner
 
PDF
Code lifecycle in the jvm - TopConf Linz
Ivan Krylov
 
PDF
Type Profiler: An Analysis to guess type signatures
mametter
 
PDF
What to expect from Java 9
Ivan Krylov
 
KEY
InvokeDynamic - You Ain't Seen Nothin Yet
Charles Nutter
 
KEY
Frederick web meetup slides
Pat Zearfoss
 
PDF
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
Nikita Lipsky
 
PDF
Swift - Under the Hood
C4Media
 
PDF
The State of Managed Runtimes 2013, by Attila Szegedi
ZeroTurnaround
 
KEY
Utah PHP Users Group - 2012
Randy Secrist
 
PDF
Swift 2 Under the Hood - Gotober 2015
Alex Blewitt
 
PDF
Down the Rabbit Hole: An Adventure in JVM Wonderland
Charles Nutter
 
PDF
How the HotSpot and Graal JVMs execute Java Code
Jim Gough
 
PDF
Open Source Swift Under the Hood
C4Media
 
Rocket Fuelled Cucumbers
Joseph Wilk
 
FOSDEM2016 - Ruby and OMR
Charlie Gracie
 
Lambda: A Peek Under The Hood - Brian Goetz
JAX London
 
Smashing the stack with Hydra
pratap21
 
Dependency injection
housecor
 
JRuby and Invokedynamic - Japan JUG 2015
Charles Nutter
 
Rails console
Reuven Lerner
 
Code lifecycle in the jvm - TopConf Linz
Ivan Krylov
 
Type Profiler: An Analysis to guess type signatures
mametter
 
What to expect from Java 9
Ivan Krylov
 
InvokeDynamic - You Ain't Seen Nothin Yet
Charles Nutter
 
Frederick web meetup slides
Pat Zearfoss
 
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
Nikita Lipsky
 
Swift - Under the Hood
C4Media
 
The State of Managed Runtimes 2013, by Attila Szegedi
ZeroTurnaround
 
Utah PHP Users Group - 2012
Randy Secrist
 
Swift 2 Under the Hood - Gotober 2015
Alex Blewitt
 
Down the Rabbit Hole: An Adventure in JVM Wonderland
Charles Nutter
 
How the HotSpot and Graal JVMs execute Java Code
Jim Gough
 
Open Source Swift Under the Hood
C4Media
 

Similar to Invoke dynamic your api to hotspot (20)

PDF
Spring framework
Aircon Chen
 
KEY
High Performance Ruby - Golden Gate RubyConf 2012
Charles Nutter
 
ZIP
Ruby on the JVM
Kresten Krab Thorup
 
PPTX
owasp lithuania chapter - exploit vs anti-exploit
Kęstutis Meškonis
 
PDF
Lifecycle of a JIT compiled code
J On The Beach
 
PDF
Sista: Improving Cog’s JIT performance
ESUG
 
PPTX
Optimizing Java Notes
Adam Feldscher
 
PDF
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
chen yuki
 
PDF
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
Boxed Ice
 
PDF
JRuby 9000 - Taipei Ruby User's Group 2015
Charles Nutter
 
PDF
Swift Micro-services and AWS Technologies
SimonPilkington8
 
PPTX
Ruby Under The Hood
craig lehmann
 
KEY
MacRuby: What is it? and why should you care?
Joshua Ballanco
 
PPTX
Implementing a JavaScript Engine
Kris Mok
 
PPTX
Jvm2
Mykola Bova
 
PDF
JRuby 9000 - Optimizing Above the JVM
Charles Nutter
 
PDF
Dmitry Schelkunov, Vasily Bukasov - About practical deobfuscation
DefconRussia
 
PDF
From V8 to Modern Compilers
Min-Yih Hsu
 
KEY
The Ruby Racer: under the hood
cowboyd
 
PDF
Java Runtime: повседневные обязанности JVM
odnoklassniki.ru
 
Spring framework
Aircon Chen
 
High Performance Ruby - Golden Gate RubyConf 2012
Charles Nutter
 
Ruby on the JVM
Kresten Krab Thorup
 
owasp lithuania chapter - exploit vs anti-exploit
Kęstutis Meškonis
 
Lifecycle of a JIT compiled code
J On The Beach
 
Sista: Improving Cog’s JIT performance
ESUG
 
Optimizing Java Notes
Adam Feldscher
 
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
chen yuki
 
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
Boxed Ice
 
JRuby 9000 - Taipei Ruby User's Group 2015
Charles Nutter
 
Swift Micro-services and AWS Technologies
SimonPilkington8
 
Ruby Under The Hood
craig lehmann
 
MacRuby: What is it? and why should you care?
Joshua Ballanco
 
Implementing a JavaScript Engine
Kris Mok
 
JRuby 9000 - Optimizing Above the JVM
Charles Nutter
 
Dmitry Schelkunov, Vasily Bukasov - About practical deobfuscation
DefconRussia
 
From V8 to Modern Compilers
Min-Yih Hsu
 
The Ruby Racer: under the hood
cowboyd
 
Java Runtime: повседневные обязанности JVM
odnoklassniki.ru
 
Ad

Recently uploaded (20)

PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Ad

Invoke dynamic your api to hotspot

  • 1. InvokeDynamic Your API for HotSpot Tony Arcieri Boundary October 11th, 2012
  • 5. Once upon a time... Java was slow
  • 8. Anamorphic StrongTalk • Optional static typing • Modern garbage collector • JIT compiler
  • 9. Anamorphic Sun Microsystems StrongTalk Java
  • 10. Anamorphic Sun Microsystems StrongTalk Java Stolen legacy!
  • 11. Anamorphic Sun Microsystems StrongTalk Java Stolen legacy!
  • 12. Anamorphic Sun Microsystems StrongTalk Java Stolen legacy!
  • 15. JIT
  • 16. Just-In-Time Compiler Compile When Code Runs
  • 19. JIT Spectrum Eager Lazy V8 CLR HotSpot HiPE
  • 20. JIT Spectrum Eager Lazy V8 CLR HotSpot HiPE Static Optimizations Runtime Optimizations
  • 21. HotSpot • C1: Client Compiler • C2: Server Compiler
  • 22. HotSpot • C1: Client Compiler • C2: Server Compiler • -XX:+TieredCompilation
  • 23. Mixed Mode Profiling JIT
  • 24. Start by interpreting JVM “emulates” bytecodes in userspace BYTECODE
  • 25. Locate “hot spots” Using runtime profiling information BYTECODE
  • 26. Generate machine code Compile JVM bytecode to native ISA after 10,000 calls 1 1 1 1 1 0 0 0 0 0 1 1 BYTECODE 1 1 1 0 0 0 0 0
  • 27. Optimizations • Inlining methods • Unrolling loops • Eliding locks • Eliminating dead code • Escape analysis
  • 28. Optimizations • Inlining methods • Unrolling loops • Eliding locks • Eliminating dead code • Escape analysis
  • 29. Inlining Combine and optimize across calls Method 1 CALL Method 2
  • 30. Inlining Combine and optimize across calls Method 1 Method 2
  • 31. Call Sites Where the magic happens... CALL
  • 32. Call Sites • Profile data • Monomorphic inline cache • Polymorphic inline cache
  • 34. Monomorphic Only one type seen at call site A CALL
  • 35. Bimorphic Two types seen at call site A CALL B
  • 36. Polymorphic Many types seen at call site A CALLB C
  • 37. Megamorphic Too many types seen at call site F D A CALL E G B C
  • 38. Inlining • Measure invocations and branches • Make an educated guess • Inline the code in question • Back out if we guessed wrong
  • 39. Deopt • Check invariants at a “safe point” • Did we guess wrong? • Revert optimization and try again
  • 41. Made for Java • InvokeVirtual • InvokeInterface • InvokeStatic • InvokeSpecial
  • 42. Non-Java call sites are opaque to HotSpot Can’t be inlined Method 1 CALL Method 2
  • 43. Teach HotSpot? See through non-Java call sites Method 1 CALL Method 2
  • 44. Inline just like Java Method 1 Method 2
  • 45. What if it worked for any language?
  • 48. InDy
  • 49. InDy • JSR-292: “Supporting Dynamically Typed Languages on the Java Platform” • Initial version shipped in Java 7 • Feeds directly into HotSpot in Java 8
  • 56. JVM Data Endpoints • Invoke operations • Array element access • Property lookup • And more!
  • 57. InDy Use Cases • Custom invocation • “Constant” values (e.g. globals, language intrinsics) • Scoped values (e.g. instance variables)
  • 59. Pieces of InDy • Bootstrap methods • Call sites • Method handles • Switch points
  • 61. Bootstrap method Wire up the call site
  • 62. Bootstrap method Your own code!
  • 63. Bootstrap Method • Called the first time each InDy call site is used • Find MethodHandle to dispatch • Return CallSite object
  • 64. Call Site Replaces InDy instruction in bytecode
  • 65. Call Site Holds onto a chain of MethodHandles
  • 66. java.lang.invoke.CallSite • ConstantCallSite: unchangeable • VolatileCallSite: seen coherently across cores • MutableCallSite: may appear different across cores
  • 67. Any of those can be subclassed
  • 68. java.lang.invoke.MethodHandle • Directly executable reference to a Java method (i.e. fast-as-Java) • Inlineable by HotSpot • MethodHandles all the way down
  • 69. Methods are first- class objects
  • 70. Project Lambda Lambdas for the JVM Coming in Java 8! (Summer 2013)
  • 72. Guarded Invocation MethodHandle.guardWithTest( ! MethodHandle test, ! MethodHandle target, ! MethodHandle fallback )
  • 73. fallback can rebind the call site Handle new types as they’re seen
  • 76. java.lang.invoke.SwitchPoint • Publish events across threads (e.g. blow caches when classes change) • Only event is valid -> invalid • Hooks directly into the HotSpot deoptimizer (no additional branches)
  • 78. Invocation example CallSite: where the call is taking place
  • 79. Invocation example CallSite: where the call is taking place SwitchPoint: did the class change?
  • 80. Invocation example CallSite: where the call is taking place SwitchPoint: did the class change? GuardWithTest: is this the type we bound?
  • 81. Invocation example CallSite: where the call is taking place SwitchPoint: did the class change? GuardWithTest: is this the type we bound? Target: invoke the target method
  • 82. Invocation example CallSite: where the call is taking place SwitchPoint: did the class change? GuardWithTest: is this the type we bound? Target: invoke the target method - or - Rebind: lookup new method and rebuild call site
  • 83. Invocation example CallSite: where the call is taking place SwitchPoint: did the class change? GuardWithTest: is this the type we bound? Target: invoke the target method - or - Rebind: lookup new method and rebuild call site - or - Rebind: lookup potentially changed methods
  • 84. InDy in the real world
  • 85. Is it good? To the assembly!
  • 86. Enabling ASM output java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly
  • 87. Contrived Ruby code def foo; 1; end def invoker; foo; end i = 0 while i < 10000   invoker   i+=1 end
  • 88. 0x00000001060a1be0: mov %eax,-0x14000(%rsp)   0x00000001060a1be7: push %rbp   0x00000001060a1be8: sub $0x30,%rsp ;*synchronization entry                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)   0x00000001060a1bec: mov 0x8(%rcx),%r10d ; implicit exception: dispatches to 0x00000001060a1c55   0x00000001060a1bf0: cmp $0xfb7aedc9,%r10d ; {oop('org/jruby/RubyObject')}   0x00000001060a1bf7: jne 0x00000001060a1c39   0x00000001060a1bf9: mov %rcx,%r10 ;*checkcast                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1bfc: mov 0x10(%r10),%ebp ;*getfield metaClass                                                 ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c00: cmp $0xfed77602,%ebp ; {oop(a 'org/jruby/MetaClass')}   0x00000001060a1c06: jne 0x00000001060a1c1e ;*if_acmpne                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn                                                 ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@6                                                 ; - java.lang.invoke.MethodHandle::invokeExact@31                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)                                                 ; {oop(a 'org/jruby/RubyFixnum')}   0x00000001060a1c12: add $0x30,%rsp   0x00000001060a1c16: pop %rbp   0x00000001060a1c17: test %eax,-0xec3c1d(%rip) # 0x00000001051de000                                                 ; {poll_return}   0x00000001060a1c1d: retq
  • 89. 0x00000001060a1be0: mov   0x00000001060a1be7: push %eax,-0x14000(%rsp) %rbp Stack juggling   0x00000001060a1be8: sub $0x30,%rsp ;*synchronization entry                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)   0x00000001060a1bec: mov 0x8(%rcx),%r10d ; implicit exception: dispatches to 0x00000001060a1c55   0x00000001060a1bf0: cmp $0xfb7aedc9,%r10d ; {oop('org/jruby/RubyObject')}   0x00000001060a1bf7: jne 0x00000001060a1c39   0x00000001060a1bf9: mov %rcx,%r10 ;*checkcast                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1bfc: mov 0x10(%r10),%ebp ;*getfield metaClass                                                 ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c00: cmp $0xfed77602,%ebp ; {oop(a 'org/jruby/MetaClass')}   0x00000001060a1c06: jne 0x00000001060a1c1e ;*if_acmpne                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn                                                 ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@6                                                 ; - java.lang.invoke.MethodHandle::invokeExact@31                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)                                                 ; {oop(a 'org/jruby/RubyFixnum')}   0x00000001060a1c12: add $0x30,%rsp   0x00000001060a1c16: pop %rbp   0x00000001060a1c17: test %eax,-0xec3c1d(%rip) # 0x00000001051de000                                                 ; {poll_return}   0x00000001060a1c1d: retq
  • 90. 0x00000001060a1be0: mov   0x00000001060a1be7: push %eax,-0x14000(%rsp) %rbp Is “self” a Ruby object?   0x00000001060a1be8: sub $0x30,%rsp ;*synchronization entry                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)   0x00000001060a1bec: mov 0x8(%rcx),%r10d ; implicit exception: dispatches to 0x00000001060a1c55   0x00000001060a1bf0: cmp $0xfb7aedc9,%r10d ; {oop('org/jruby/RubyObject')}   0x00000001060a1bf7: jne 0x00000001060a1c39   0x00000001060a1bf9: mov %rcx,%r10 ;*checkcast                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1bfc: mov 0x10(%r10),%ebp ;*getfield metaClass                                                 ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c00: cmp $0xfed77602,%ebp ; {oop(a 'org/jruby/MetaClass')}   0x00000001060a1c06: jne 0x00000001060a1c1e ;*if_acmpne                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn                                                 ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@6                                                 ; - java.lang.invoke.MethodHandle::invokeExact@31                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)                                                 ; {oop(a 'org/jruby/RubyFixnum')}   0x00000001060a1c12: add $0x30,%rsp   0x00000001060a1c16: pop %rbp   0x00000001060a1c17: test %eax,-0xec3c1d(%rip) # 0x00000001051de000                                                 ; {poll_return}   0x00000001060a1c1d: retq
  • 91. 0x00000001060a1be0: mov   0x00000001060a1be7: push %eax,-0x14000(%rsp) %rbp Same metaclass as before?   0x00000001060a1be8: sub $0x30,%rsp ;*synchronization entry                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)   0x00000001060a1bec: mov 0x8(%rcx),%r10d ; implicit exception: dispatches to 0x00000001060a1c55   0x00000001060a1bf0: cmp $0xfb7aedc9,%r10d ; {oop('org/jruby/RubyObject')}   0x00000001060a1bf7: jne 0x00000001060a1c39   0x00000001060a1bf9: mov %rcx,%r10 ;*checkcast                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1bfc: mov 0x10(%r10),%ebp ;*getfield metaClass                                                 ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c00: cmp $0xfed77602,%ebp ; {oop(a 'org/jruby/MetaClass')}   0x00000001060a1c06: jne 0x00000001060a1c1e ;*if_acmpne                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn                                                 ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@6                                                 ; - java.lang.invoke.MethodHandle::invokeExact@31                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)                                                 ; {oop(a 'org/jruby/RubyFixnum')}   0x00000001060a1c12: add $0x30,%rsp   0x00000001060a1c16: pop %rbp   0x00000001060a1c17: test %eax,-0xec3c1d(%rip) # 0x00000001051de000                                                 ; {poll_return}   0x00000001060a1c1d: retq
  • 92. 0x00000001060a1be0: mov   0x00000001060a1be7: push %eax,-0x14000(%rsp) %rbp Store Fixnum “1” for return   0x00000001060a1be8: sub $0x30,%rsp ;*synchronization entry                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)   0x00000001060a1bec: mov 0x8(%rcx),%r10d ; implicit exception: dispatches to 0x00000001060a1c55   0x00000001060a1bf0: cmp $0xfb7aedc9,%r10d ; {oop('org/jruby/RubyObject')}   0x00000001060a1bf7: jne 0x00000001060a1c39   0x00000001060a1bf9: mov %rcx,%r10 ;*checkcast                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1bfc: mov 0x10(%r10),%ebp ;*getfield metaClass                                                 ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c00: cmp $0xfed77602,%ebp ; {oop(a 'org/jruby/MetaClass')}   0x00000001060a1c06: jne 0x00000001060a1c1e ;*if_acmpne                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn                                                 ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@6                                                 ; - java.lang.invoke.MethodHandle::invokeExact@31                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)                                                 ; {oop(a 'org/jruby/RubyFixnum')}   0x00000001060a1c12: add $0x30,%rsp   0x00000001060a1c16: pop %rbp   0x00000001060a1c17: test %eax,-0xec3c1d(%rip) # 0x00000001051de000                                                 ; {poll_return}   0x00000001060a1c1d: retq
  • 93. 0x00000001060a1be0: mov   0x00000001060a1be7: push %eax,-0x14000(%rsp) %rbp Note: inside the “foo” method   0x00000001060a1be8: sub $0x30,%rsp ;*synchronization entry                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)   0x00000001060a1bec: mov 0x8(%rcx),%r10d ; implicit exception: dispatches to 0x00000001060a1c55   0x00000001060a1bf0: cmp $0xfb7aedc9,%r10d ; {oop('org/jruby/RubyObject')}   0x00000001060a1bf7: jne 0x00000001060a1c39   0x00000001060a1bf9: mov %rcx,%r10 ;*checkcast                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1bfc: mov 0x10(%r10),%ebp ;*getfield metaClass                                                 ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c00: cmp $0xfed77602,%ebp ; {oop(a 'org/jruby/MetaClass')}   0x00000001060a1c06: jne 0x00000001060a1c1e ;*if_acmpne                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn                                                 ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@6                                                 ; - java.lang.invoke.MethodHandle::invokeExact@31                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)                                                 ; {oop(a 'org/jruby/RubyFixnum')}   0x00000001060a1c12: add $0x30,%rsp   0x00000001060a1c16: pop %rbp   0x00000001060a1c17: test %eax,-0xec3c1d(%rip) # 0x00000001051de000                                                 ; {poll_return}   0x00000001060a1c1d: retq
  • 94. 0x00000001060a1be0: mov   0x00000001060a1be7: push %eax,-0x14000(%rsp) %rbp Stack juggling   0x00000001060a1be8: sub $0x30,%rsp ;*synchronization entry                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)   0x00000001060a1bec: mov 0x8(%rcx),%r10d ; implicit exception: dispatches to 0x00000001060a1c55   0x00000001060a1bf0: cmp $0xfb7aedc9,%r10d ; {oop('org/jruby/RubyObject')}   0x00000001060a1bf7: jne 0x00000001060a1c39   0x00000001060a1bf9: mov %rcx,%r10 ;*checkcast                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1bfc: mov 0x10(%r10),%ebp ;*getfield metaClass                                                 ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c00: cmp $0xfed77602,%ebp ; {oop(a 'org/jruby/MetaClass')}   0x00000001060a1c06: jne 0x00000001060a1c1e ;*if_acmpne                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn                                                 ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@6                                                 ; - java.lang.invoke.MethodHandle::invokeExact@31                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)                                                 ; {oop(a 'org/jruby/RubyFixnum')}   0x00000001060a1c12: add $0x30,%rsp   0x00000001060a1c16: pop %rbp   0x00000001060a1c17: test %eax,-0xec3c1d(%rip) # 0x00000001051de000                                                 ; {poll_return}   0x00000001060a1c1d: retq
  • 95. 0x00000001060a1be0: mov   0x00000001060a1be7: push %eax,-0x14000(%rsp) %rbp Safe point check   0x00000001060a1be8: sub $0x30,%rsp ;*synchronization entry                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)   0x00000001060a1bec: mov 0x8(%rcx),%r10d ; implicit exception: dispatches to 0x00000001060a1c55   0x00000001060a1bf0: cmp $0xfb7aedc9,%r10d ; {oop('org/jruby/RubyObject')}   0x00000001060a1bf7: jne 0x00000001060a1c39   0x00000001060a1bf9: mov %rcx,%r10 ;*checkcast                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1bfc: mov 0x10(%r10),%ebp ;*getfield metaClass                                                 ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c00: cmp $0xfed77602,%ebp ; {oop(a 'org/jruby/MetaClass')}   0x00000001060a1c06: jne 0x00000001060a1c1e ;*if_acmpne                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn                                                 ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@6                                                 ; - java.lang.invoke.MethodHandle::invokeExact@31                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)                                                 ; {oop(a 'org/jruby/RubyFixnum')}   0x00000001060a1c12: add $0x30,%rsp   0x00000001060a1c16: pop %rbp   0x00000001060a1c17: test %eax,-0xec3c1d(%rip) # 0x00000001051de000                                                 ; {poll_return}   0x00000001060a1c1d: retq
  • 96. 0x00000001060a1be0: mov   0x00000001060a1be7: push %eax,-0x14000(%rsp) %rbp Done!   0x00000001060a1be8: sub $0x30,%rsp ;*synchronization entry                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@-1 (line 1)   0x00000001060a1bec: mov 0x8(%rcx),%r10d ; implicit exception: dispatches to 0x00000001060a1c55   0x00000001060a1bf0: cmp $0xfb7aedc9,%r10d ; {oop('org/jruby/RubyObject')}   0x00000001060a1bf7: jne 0x00000001060a1c39   0x00000001060a1bf9: mov %rcx,%r10 ;*checkcast                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@2 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1bfc: mov 0x10(%r10),%ebp ;*getfield metaClass                                                 ; - org.jruby.RubyBasicObject::getMetaClass@1 (line 520)                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@5 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c00: cmp $0xfed77602,%ebp ; {oop(a 'org/jruby/MetaClass')}   0x00000001060a1c06: jne 0x00000001060a1c1e ;*if_acmpne                                                 ; - org.jruby.runtime.invokedynamic.InvocationLinker::testMetaclass@8 (line 633)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@3                                                 ; - java.lang.invoke.MethodHandle::invokeExact@5                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)   0x00000001060a1c08: movabs $0x7f6bf4bb0,%rax ;*areturn                                                 ; - ruby.__dash_e__::method__0$RUBY$foo@6 (line 1)                                                 ; - java.lang.invoke.MethodHandle::invokeExact@6                                                 ; - java.lang.invoke.MethodHandle::invokeExact@31                                                 ; - java.lang.invoke.MethodHandle::invokeExact@29                                                 ; - ruby.__dash_e__::method__1$RUBY$invoker@3 (line 1)                                                 ; {oop(a 'org/jruby/RubyFixnum')}   0x00000001060a1c12: add $0x30,%rsp   0x00000001060a1c16: pop %rbp   0x00000001060a1c17: test %eax,-0xec3c1d(%rip) # 0x00000001051de000                                                 ; {poll_return}   0x00000001060a1c1d: retq
  • 101. Twitter: @bascule Celluloid: celluloid.io Blog: unlimitednovelty.com