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

Just-In-Time Compiler for MRI

Just-In-Time Compiler for MRI

RubyConf 2017 New Orleans

Takashi Kokubun

November 17, 2017
Tweet

More Decks by Takashi Kokubun

Other Decks in Programming

Transcript

  1. DPNQJMFEDPEF`TSFOEFSJOHUJNFTQFSTFDPOE OP)5.-FTDBQF 3FOEFSJOHUJNFTQFSTFDPOE JT      ERB

    Ruby 2.5.0 Erubis 2.7.0 Ruby 2.5.0 Erubi 1.7.0 Ruby 2.5.0 ERB Ruby 2.4.2            IUUQTHJTUHJUIVCDPNLLVCVOFEEDDCEFGDGBDEGGE *NBEF&3#YGBTUFS
  2. 5PEBZ*`MMUFMMZPVIPX*BDIJFWFEUIJTXJUIJU 0QUDBSSPUXJUI[email protected] GQT      Ruby 2.0

    Ruby 2.5 YARV-MJIT    IUUQTHJUIVCDPNLLVCVOZBSWNKJUPQUDBSSPUCFODINBSL
  3. )PXDVSSFOU.3*XPSLT EFGSVCZ   FOE 3VCZDPEF "CTUSBDU 4ZOUBY5SFF /0%&@$"-- NFUIPE

    SFDFJWFS BSHT 1BSTF QVUPCKFDU QVUPCKFDU PQU@NVMU MFBWF #ZUFDPEF GPS3VCZ7. $PNQJMF
  4. #ZUFDPEF GPS3VCZ7. QVUPCKFDU QVUPCKFDU PQU@NVMU MFBWF 5ISFBE 3VCZ7. 5ISFBE +*5DPNQJMFS

    $BMMDPVOU /BUJWFDPEF $BMM 0QUJNJ[F )PXEPFT+*5XPSL *OUFSQSFU
  5. 'JSTUPGBMM EPFT3VCZOFFEUPCFGBTUFS 3VCZJTGBTUFOPVHIGPSNBOZVTFDBTFT CVUJUTIPVMECFGBTUFS w 'PSNPOFZ w 5IFGBTUFS3VCZJT UIFGFXFSDPNQVUFSFTPVSDFTBSFSFRVJSFE w

    'PSFOEVTFSFYQFSJFODF w FH'BTUXFCBQQMJDBUJPOJTDPNGPSUBCMFUPVTF w 5PBMXBZTVTF3VCZ❤ w /PMPOHFSOFFEUPDIPPTFBOPUIFSMBOHVBHFEVFUPQFSGPSNBODF
  6. 0LBZ UIFOXIZ+*5GPS3VCZQFSGPSNBODF w +*5+VTU*O5JNF"05"IFBE0G5JNF w "05DPNQJMFTQSPHSBNUPOBUJWFDPEFCFGPSFJUTFYFDVUJPO w 8IZOPU"05CVU+*5  w

    5PLFFQCPPUUJNFTIPSU DPNQJMBUJPOTIPVMECFGVMMZBTZODISPOPVT w 4PNFPQUJNJ[BUJPOTOFFESVOUJNFJOGPSNBUJPO FYQMBJOFEMBUFS
  7. 1FSGPSNBODFPGTPNF+*5DPNQJMFSJNQMFNFOUBUJPOT 0QUDBSSPUXJUI[email protected] GQT      Ruby 2.0

    Ruby 2.5 YARV-MJIT MJIT     IUUQTHJUIVCDPNLLVCVOZBSWNKJUPQUDBSSPUCFODINBSL
  8. #ZUFDPEF QVUPCKFDU QVUPCKFDU PQU@NVMU MFBWF 5ISFBE 3VCZ7. )PX--3#XPSLT *OUFSQSFU .FUIPE`T

    --7.*3 $PNQJMF $PNCJOFE --7.*3 -JOL*3 .3*`T QSFDPNQJMFE --7.CJUDPEF
  9. #ZUFDPEF QVUPCKFDU QVUPCKFDU PQU@NVMU MFBWF 5ISFBE 3VCZ7. )PX--3#XPSLT *OUFSQSFU .FUIPE`T

    --7.*3 $PNQJMF /BUJWF$PEF $PNCJOFE --7.*3 -JOL*3 0QUJNJ[BUJPO CZ--7.1BTT $PEFHFO .3*`T QSFDPNQJMFE --7.CJUDPEF
  10. #ZUFDPEF QVUPCKFDU QVUPCKFDU PQU@NVMU MFBWF 5ISFBE 3VCZ7. )PX--3#XPSLT *OUFSQSFU .FUIPE`T

    --7.*3 $PNQJMF .3*`T QSFDPNQJMFE --7.CJUDPEF /BUJWF$PEF $PNCJOFE --7.*3 -JOL*3 $PEFHFO $BMM 0QUJNJ[BUJPO CZ--7.1BTT
  11. --3#`T1BTTQJQFMJOF w .BKPS1BTTFTUIBUB⒎FDU--3#`TPQUJNJ[BUJPOTUBUT 1B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DU *OUFHFS JNVMUJ *OUFHFS *OUFHFS
  15. -PDBMpMFT $BMMDPVOU 35-#ZUFDPEF WBMUFNQ  JNVMUJ   UFNQ@SFU 5ISFBE3VCZ7.

    5ISFBE+*5DPNQJMFS )PX.+*5XPSLT *OUFSQSFU $DPEFPGNFUIPE $PNQJMF 4IBSFE0CKFDUpMF HDD DMBOH
  16. -PDBMpMFT $BMMDPVOU 35-#ZUFDPEF WBMUFNQ  JNVMUJ   UFNQ@SFU 5ISFBE3VCZ7.

    5ISFBE+*5DPNQJMFS )PX.+*5XPSLT *OUFSQSFU $DPEFPGNFUIPE $PNQJMF 4IBSFE0CKFDUpMF HDD DMBOH .FNPSZ /BUJWFDPEF EMTZN
  17. -PDBMpMFT $BMMDPVOU 35-#ZUFDPEF WBMUFNQ  JNVMUJ   UFNQ@SFU 5ISFBE3VCZ7.

    5ISFBE+*5DPNQJMFS )PX.+*5XPSLT *OUFSQSFU $DPEFPGNFUIPE $PNQJMF 4IBSFE0CKFDUpMF HDD DMBOH .FNPSZ EMTZN $BMM /BUJWFDPEF
  18. 8FOFFEUPDIFDLNFUIPESFEFpOJUJPO QVUPCKFDU MFBWF DMBTT*OUFHFS EFG PCK  PCK FOE FOE

      $VSSFOU3VCZDPNQJMFSEPFTO`UQSPWJEFTVDIPQUJNJ[BUJPO :"37CZUFDPEF
  19. QVUPCKFDU QVUPCKFDU PQU@NVMU MFBWF $BMMDPVOU (FOFSBUF$DPEF 7"-6&PQU@NVMU B C \

    *G OPU@SFEFpOFE JOU@NVMU \ SFUVSOB C ^FMTF\ SFUVSOWN@FYFD  ^ ^ 7"-6&OBUJWF@DPEF \ SFUVSOPQU@NVMU    ^ :"37CZUFDPEF )PXEPFT:"37.+*5PQUJNJ[FUIJT 5ISFBE3VCZ7. 5ISFBE+*5DPNQJMFS 5ISFBE3VCZ7. *OUFSQSFU
  20. QVUPCKFDU QVUPCKFDU PQU@NVMU MFBWF $BMMDPVOU 7"-6&PQU@NVMU B C \ *G

    O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