How does TruffleRuby work

How does TruffleRuby work

2019/4/19に行われたRubyKaigi2019でのLT登壇資料です。
Truffleがどのような方針で最適化を行うかという話をしました。

9e840766611f942c7c0a9ad6987a5d78?s=128

Naoki Kishida

April 19, 2019
Tweet

Transcript

  1. , / 1 4 2 0 4 4

  2. • ) • ( • • )

  3.      •

  4. • •

  5. • ( A 0 D • C A • H

    0 C G • A C 0 • 1 G D ) ( 1- ) 2 D
  6. ! ! • • • .. • .. •

  7. • CA ( 22 2A , 2 , 2 2

    2 2 • .C A 2 + A C + 2 • + 2 2 • ( - 2A 2 2 • ( 22 + 2A 2 A C 2 2 • -C 2 2 A 2AA ) . 2 ( 22 • -C 2A 2 2 2 ( 22 .C A 2 +
  8. • - A • + / • A + •

    - - + - - • + @CoreMethod(names = "^", required = 1) public abstract static class BitXOrNode extends BignumCoreMethodNode { @Specialization public int bitXOr(int a, int b) { return a ^ b; } @Specialization public long bitXOr(long a, long b) { return a ^ b; } - - . / / - -
  9. • ( ( ( ( • ( + * (

    ( • ( + ( * ( * * ( ( + ( * + * () • ( ( def bar(num) a = 3 return num + a end def foo print bar(2) end def bar(num) return num + 3 end def foo print bar(2) end def foo print 2 + 3 end def foo print 5 end
  10. . 2 . 2

  11. ) ( ( • 1 1 1 1! 1>1 -

    1 1 3- 3 1 • ( - - 1 3 • 1 3- 3 1 3 1 1 1 ! 3 1 • ( - - 1 3 • 1 3- 3 1 1 3- 3 1 ! 3 1 )1 1 - • ( - - 1 3 • 3 22 1
  12. • - : 2 A 2 • 1 E 2

    I/ A2 I • I 2 24: • A : : 2 : A • : : : A • 0 : / E A : : ./ A 2 2 2 : 4 A: : A : 2 2 : A 2 E def jump(self, space, bytecode, frame, cur_pc, target_pc): if target_pc < cur_pc: self.jitdriver.can_enter_jit( self=self, bytecode=bytecode, frame=frame, pc=target_pc, block_bytecode=self.get_block_bytecode(frame.block), w_trace_proc=space.getexecutioncontext().gettraceproc() ) return target_pc A2 : A A
  13. • • @CoreMethod(names = "^", required = 1) public abstract

    static class BitXOrNode extends BignumCoreMethodNode { @Specialization public int bitXOr(int a, int b) { return a ^ b; } @Specialization public long bitXOr(long a, long b) { return a ^ b; }
  14. • • • • - • • - • -

  15. • ( • > • )>- • )>- • )>-

    > • - > • > - • > • -> • ->
  16. • • • • • •

  17.  • • ! •