SlideShare ist ein Scribd-Unternehmen logo
1 von 101
Downloaden Sie, um offline zu lesen
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!
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
That’s it!
Twitter:
      @bascule

    Celluloid:
   celluloid.io

       Blog:
unlimitednovelty.com

Weitere ähnliche Inhalte

Was ist angesagt?

Rocket Fuelled Cucumbers
Rocket Fuelled CucumbersRocket Fuelled Cucumbers
Rocket Fuelled CucumbersJoseph Wilk
 
FOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMRFOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMRCharlie Gracie
 
Lambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzLambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzJAX London
 
Smashing the stack with Hydra
Smashing the stack with HydraSmashing the stack with Hydra
Smashing the stack with Hydrapratap21
 
Dependency injection
Dependency injectionDependency injection
Dependency injectionhousecor
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015Charles Nutter
 
Code lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzCode lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzIvan Krylov
 
Type Profiler: An Analysis to guess type signatures
Type Profiler: An Analysis to guess type signaturesType Profiler: An Analysis to guess type signatures
Type Profiler: An Analysis to guess type signaturesmametter
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9Ivan Krylov
 
InvokeDynamic - You Ain't Seen Nothin Yet
InvokeDynamic - You Ain't Seen Nothin YetInvokeDynamic - You Ain't Seen Nothin Yet
InvokeDynamic - You Ain't Seen Nothin YetCharles Nutter
 
Frederick web meetup slides
Frederick web meetup slidesFrederick web meetup slides
Frederick web meetup slidesPat Zearfoss
 
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...Nikita Lipsky
 
Swift - Under the Hood
Swift - Under the HoodSwift - Under the Hood
Swift - Under the HoodC4Media
 
The State of Managed Runtimes 2013, by Attila Szegedi
The State of Managed Runtimes 2013, by Attila SzegediThe State of Managed Runtimes 2013, by Attila Szegedi
The State of Managed Runtimes 2013, by Attila SzegediZeroTurnaround
 
Utah PHP Users Group - 2012
Utah PHP Users Group - 2012Utah PHP Users Group - 2012
Utah PHP Users Group - 2012Randy Secrist
 
Swift 2 Under the Hood - Gotober 2015
Swift 2 Under the Hood - Gotober 2015Swift 2 Under the Hood - Gotober 2015
Swift 2 Under the Hood - Gotober 2015Alex Blewitt
 
Down the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM WonderlandDown the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM WonderlandCharles Nutter
 
How the HotSpot and Graal JVMs execute Java Code
How the HotSpot and Graal JVMs execute Java CodeHow the HotSpot and Graal JVMs execute Java Code
How the HotSpot and Graal JVMs execute Java CodeJim Gough
 
Open Source Swift Under the Hood
Open Source Swift Under the HoodOpen Source Swift Under the Hood
Open Source Swift Under the HoodC4Media
 

Was ist angesagt? (20)

Rocket Fuelled Cucumbers
Rocket Fuelled CucumbersRocket Fuelled Cucumbers
Rocket Fuelled Cucumbers
 
FOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMRFOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMR
 
Lambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzLambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian Goetz
 
Smashing the stack with Hydra
Smashing the stack with HydraSmashing the stack with Hydra
Smashing the stack with Hydra
 
Dependency injection
Dependency injectionDependency injection
Dependency injection
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015
 
Rails console
Rails consoleRails console
Rails console
 
Code lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzCode lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf Linz
 
Type Profiler: An Analysis to guess type signatures
Type Profiler: An Analysis to guess type signaturesType Profiler: An Analysis to guess type signatures
Type Profiler: An Analysis to guess type signatures
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 
InvokeDynamic - You Ain't Seen Nothin Yet
InvokeDynamic - You Ain't Seen Nothin YetInvokeDynamic - You Ain't Seen Nothin Yet
InvokeDynamic - You Ain't Seen Nothin Yet
 
Frederick web meetup slides
Frederick web meetup slidesFrederick web meetup slides
Frederick web meetup slides
 
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
 
Swift - Under the Hood
Swift - Under the HoodSwift - Under the Hood
Swift - Under the Hood
 
The State of Managed Runtimes 2013, by Attila Szegedi
The State of Managed Runtimes 2013, by Attila SzegediThe State of Managed Runtimes 2013, by Attila Szegedi
The State of Managed Runtimes 2013, by Attila Szegedi
 
Utah PHP Users Group - 2012
Utah PHP Users Group - 2012Utah PHP Users Group - 2012
Utah PHP Users Group - 2012
 
Swift 2 Under the Hood - Gotober 2015
Swift 2 Under the Hood - Gotober 2015Swift 2 Under the Hood - Gotober 2015
Swift 2 Under the Hood - Gotober 2015
 
Down the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM WonderlandDown the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM Wonderland
 
How the HotSpot and Graal JVMs execute Java Code
How the HotSpot and Graal JVMs execute Java CodeHow the HotSpot and Graal JVMs execute Java Code
How the HotSpot and Graal JVMs execute Java Code
 
Open Source Swift Under the Hood
Open Source Swift Under the HoodOpen Source Swift Under the Hood
Open Source Swift Under the Hood
 

Ähnlich wie Invoke dynamic your api to hotspot

Spring framework
Spring frameworkSpring framework
Spring frameworkAircon Chen
 
High Performance Ruby - Golden Gate RubyConf 2012
High Performance Ruby - Golden Gate RubyConf 2012High Performance Ruby - Golden Gate RubyConf 2012
High Performance Ruby - Golden Gate RubyConf 2012Charles Nutter
 
owasp lithuania chapter - exploit vs anti-exploit
owasp lithuania chapter - exploit vs anti-exploitowasp lithuania chapter - exploit vs anti-exploit
owasp lithuania chapter - exploit vs anti-exploitKęstutis Meškonis
 
Lifecycle of a JIT compiled code
Lifecycle of a JIT compiled codeLifecycle of a JIT compiled code
Lifecycle of a JIT compiled codeJ On The Beach
 
Sista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceSista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceESUG
 
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...chen yuki
 
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBMongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBBoxed Ice
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015Charles Nutter
 
Swift Micro-services and AWS Technologies
Swift Micro-services and AWS TechnologiesSwift Micro-services and AWS Technologies
Swift Micro-services and AWS TechnologiesSimonPilkington8
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?Joshua Ballanco
 
Implementing a JavaScript Engine
Implementing a JavaScript EngineImplementing a JavaScript Engine
Implementing a JavaScript EngineKris Mok
 
JRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMJRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMCharles Nutter
 
Dmitry Schelkunov, Vasily Bukasov - About practical deobfuscation
Dmitry Schelkunov, Vasily Bukasov - About practical deobfuscationDmitry Schelkunov, Vasily Bukasov - About practical deobfuscation
Dmitry Schelkunov, Vasily Bukasov - About practical deobfuscationDefconRussia
 
From V8 to Modern Compilers
From V8 to Modern CompilersFrom V8 to Modern Compilers
From V8 to Modern CompilersMin-Yih Hsu
 
The Ruby Racer: under the hood
The Ruby Racer: under the hoodThe Ruby Racer: under the hood
The Ruby Racer: under the hoodcowboyd
 
Java Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVMJava Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVModnoklassniki.ru
 

Ähnlich wie Invoke dynamic your api to hotspot (20)

Spring framework
Spring frameworkSpring framework
Spring framework
 
High Performance Ruby - Golden Gate RubyConf 2012
High Performance Ruby - Golden Gate RubyConf 2012High Performance Ruby - Golden Gate RubyConf 2012
High Performance Ruby - Golden Gate RubyConf 2012
 
Ruby on the JVM
Ruby on the JVMRuby on the JVM
Ruby on the JVM
 
owasp lithuania chapter - exploit vs anti-exploit
owasp lithuania chapter - exploit vs anti-exploitowasp lithuania chapter - exploit vs anti-exploit
owasp lithuania chapter - exploit vs anti-exploit
 
Lifecycle of a JIT compiled code
Lifecycle of a JIT compiled codeLifecycle of a JIT compiled code
Lifecycle of a JIT compiled code
 
Sista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceSista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performance
 
Optimizing Java Notes
Optimizing Java NotesOptimizing Java Notes
Optimizing Java Notes
 
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
 
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBMongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
 
Swift Micro-services and AWS Technologies
Swift Micro-services and AWS TechnologiesSwift Micro-services and AWS Technologies
Swift Micro-services and AWS Technologies
 
Ruby Under The Hood
Ruby Under The HoodRuby Under The Hood
Ruby Under The Hood
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?
 
Implementing a JavaScript Engine
Implementing a JavaScript EngineImplementing a JavaScript Engine
Implementing a JavaScript Engine
 
Jvm2
Jvm2Jvm2
Jvm2
 
JRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMJRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVM
 
Dmitry Schelkunov, Vasily Bukasov - About practical deobfuscation
Dmitry Schelkunov, Vasily Bukasov - About practical deobfuscationDmitry Schelkunov, Vasily Bukasov - About practical deobfuscation
Dmitry Schelkunov, Vasily Bukasov - About practical deobfuscation
 
From V8 to Modern Compilers
From V8 to Modern CompilersFrom V8 to Modern Compilers
From V8 to Modern Compilers
 
The Ruby Racer: under the hood
The Ruby Racer: under the hoodThe Ruby Racer: under the hood
The Ruby Racer: under the hood
 
Java Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVMJava Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVM
 

Kürzlich hochgeladen

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Kürzlich hochgeladen (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

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!
  • 13.
  • 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
  • 98.
  • 99.
  • 101. Twitter: @bascule Celluloid: celluloid.io Blog: unlimitednovelty.com