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

LLVM-Based JIT Compiler for CRuby

LLVM-Based JIT Compiler for CRuby

RubyKaigi 2017 Lightning Talk
http://rubykaigi.org/2017

Takashi Kokubun

September 19, 2017
Tweet

More Decks by Takashi Kokubun

Other Decks in Programming

Transcript

  1. 8IBUEPFT--3#EP HFNJOTUBMMMMSC FYUDPOGSCEPFT $3VCZ`T$GVODUJPOGPS 7.JOTO JOTOTEFG MMSC@JOTO@PQU@QMVTD --7.*3 MMSC@JOTO@PQU@QMVTMM

    --7.CJUDPEF MMSC@JOTO@PQU@QMVTCD DMBOH0 FNJUMMWN MMWNBT *OJU@MMSCJOWPLFT TUBDLQSPGMJLFQSPpMFS TFUJUJNFS *5*.&3@130' SC@QPTUQPOFE@KPC@SFHJTUFS@POF SVCZSMMSCTUBSUʜ
  2. 8IBUEPFT--3#EP HFNJOTUBMMMMSC FYUDPOGSCEPFT $3VCZ`T$GVODUJPOGPS 7.JOTO JOTOTEFG MMSC@JOTO@PQU@QMVTD --7.*3 MMSC@JOTO@PQU@QMVTMM

    --7.CJUDPEF MMSC@JOTO@PQU@QMVTCD DMBOH0 FNJUMMWN MMWNBT *OJU@MMSCJOWPLFT TUBDLQSPGMJLFQSPpMFS TFUJUJNFS *5*.&3@130' SC@QPTUQPOFE@KPC@SFHJTUFS@POF 3VCZ`T CZUFDPEF PGIPUTQPU %FUFDU GSFRVFOUMZ DBMMFE*4FR SVCZSMMSCTUBSUʜ
  3. 8IBUEPFT--3#EP HFNJOTUBMMMMSC FYUDPOGSCEPFT $3VCZ`T$GVODUJPOGPS 7.JOTO JOTOTEFG MMSC@JOTO@PQU@QMVTD --7.*3 MMSC@JOTO@PQU@QMVTMM

    --7.CJUDPEF MMSC@JOTO@PQU@QMVTCD DMBOH0 FNJUMMWN MMWNBT *OJU@MMSCJOWPLFT TUBDLQSPGMJLFQSPpMFS TFUJUJNFS *5*.&3@130' SC@QPTUQPOFE@KPC@SFHJTUFS@POF 3VCZ`T CZUFDPEF PGIPUTQPU %FUFDU GSFRVFOUMZ DBMMFE*4FR --7.*3 PGIPUTQPU --3#`T $PNQJMFS SVCZSMMSCTUBSUʜ
  4. 8IBUEPFT--3#EP HFNJOTUBMMMMSC FYUDPOGSCEPFT $3VCZ`T$GVODUJPOGPS 7.JOTO JOTOTEFG MMSC@JOTO@PQU@QMVTD --7.*3 MMSC@JOTO@PQU@QMVTMM

    --7.CJUDPEF MMSC@JOTO@PQU@QMVTCD DMBOH0 FNJUMMWN MMWNBT *OJU@MMSCJOWPLFT TUBDLQSPGMJLFQSPpMFS TFUJUJNFS *5*.&3@130' SC@QPTUQPOFE@KPC@SFHJTUFS@POF 3VCZ`T CZUFDPEF PGIPUTQPU %FUFDU GSFRVFOUMZ DBMMFE*4FR --7.*3 PGIPUTQPU --3#`T $PNQJMFS $GVODUJPO JOQPJOUFS --7.1BTT JOMJOFT$ GVODUJPO --7. SVCZSMMSCTUBSUʜ
  5. 8IBUEPFT--3#EP HFNJOTUBMMMMSC FYUDPOGSCEPFT SVCZSMMSCTUBSUʜ $3VCZ`T$GVODUJPOGPS 7.JOTO JOTOTEFG MMSC@JOTO@PQU@QMVTD --7.*3

    MMSC@JOTO@PQU@QMVTMM --7.CJUDPEF MMSC@JOTO@PQU@QMVTCD DMBOH0 FNJUMMWN MMWNBT *OJU@MMSCJOWPLFT TUBDLQSPGMJLFQSPpMFS TFUJUJNFS *5*.&3@130' SC@QPTUQPOFE@KPC@SFHJTUFS@POF 3VCZ`T CZUFDPEF PGIPUTQPU %FUFDU GSFRVFOUMZ DBMMFE*4FR --7.*3 PGIPUTQPU --3#`T $PNQJMFS $GVODUJPO JOQPJOUFS --7.1BTT JOMJOFT$ GVODUJPO 3FQMBDFCZUFDPEF UPUIFPOFUIBUVTFT UIJT$GVODUJPO
  6. --3#`T1BTTQJQFMJOF w --3#JTVTJOH--7.`TEFGBVMU1BTTQJQFMJOFGPS0 1BTTFT w 'PSDF'VODUJPO"UUST-FHBDZ1BTT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