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

TruffleでPHPぽい言語を実装したら爆速だった話 / truffle php at jj...

Naoki Kishida
February 27, 2019

TruffleでPHPぽい言語を実装したら爆速だった話 / truffle php at jjug night seminar

TruffleでPHPを実装したら爆速だった話です

Naoki Kishida

February 27, 2019
Tweet

More Decks by Naoki Kishida

Other Decks in Technology

Transcript

  1. PHP   • jparsec ( ) • https://github.com/jparsec/jparsec/ •

      • +-<>.(  ) •  •  • if • echo https://github.com/kishida/phpparser
  2.     <?php function fib($n) { if ($n

    < 2) { return $n; } return fib($n - 1) + fib($n - 2); } echo "fib:".fib(31); echo "¥n";
  3. (6/6) • 5; • 0:, 4 %)5210:,  69; •

    return=-2/   goto(JVM%)) jmp(*!' +) ReturnException #+&"$(87  resultObject <3.
  4.  <?php function fib($n) { if ($n < 2) {

    return $n; } return fib($n - 1) + fib($n - 2); } $start = microtime(1); echo "fib:".fib(31); echo "¥n"; echo "time:".(microtime(1) - $start); echo "¥n"; fib(31);fib(31);fib(31);fib(31);fib(31); $start = microtime(1); echo "fib:".fib(31); echo "¥n"; echo "time:".(microtime(1) - $start); echo "¥n";
  5.  •  (interpreter) on JDK 11 • Truffle 

    JDK 11 • Truffle  GraalVM CE • Truffle  GraalVM CE   • Truffle  GraalVM EE • Truffle  GraalVM EE   • PHP 5.6 • PHP 7.3
  6. (JIT) • PHP 7.3PHP5.63 •   PHP7.37 • Truffle+GraalVM

    CEPHP7.3 • Truffle+GraalVM EEPHP7.32 • GraalVM CE    PHP7.32 • GraalVM EE    PHP7.34
  7.  • JIT    •   •

     • EE PHP7.3   • CE PHP7.3  
  8.   • PHP  # &!"' •  %

    •  • EE$CE% <?php function fib($n) { if ($n < 2) { return $n; } return fib($n - 1) + fib($n - 2); } echo "fib:".fib(31); echo "¥n";
  9.  • Real$) "UserCPU! " • JVMUser" ' • 

    ( CPU" ' • GraalVMRealUser & • Graal#% ( CPU" 
  10.  • PHPPHP3PHP4PHP5PHP7 '5# !"(PHP6&8) • (0, +*:% PHP7941 

     •  "$!(03  • . '5# (0,6 -2 • 5/$7)#(Specialization) 
  11.  • GraalVM  • Truffle   • "

    # SimpleLanguage  • Writing a Language in Truffle •  gitter ! % • Graal&$