parrot vm
play

Parrot VM Allison Randal Parrot Foundation & O'Reilly Media, - PowerPoint PPT Presentation

Parrot VM Allison Randal Parrot Foundation & O'Reilly Media, Inc. Python Ruby Perl 5 Perl 6 PHP Parrot VM Objective-C Lua Javascript Python Ruby Scheme Tcl Dylan Perl 5 Perl 6 PHP TeX macro Invent your language here. Forth


  1. Parrot VM Allison Randal Parrot Foundation & O'Reilly Media, Inc.

  2. Python Ruby Perl 5 Perl 6 PHP Parrot VM

  3. Objective-C Lua Javascript Python Ruby Scheme Tcl Dylan Perl 5 Perl 6 PHP TeX macro Invent your language here. Forth Parrot VM

  4. Dynamic Features ● Runtime vs. compile-time ● Extend code (eval, load) ● Define classes ● Alter type system ● Higher-order functions ● Closures, Continuations, Coroutines

  5. Goals ● Revolution... ● ...becoming Establishment ● Powerful tools ● Portability ● Interoperability ● Language evolution

  6. Register-based ● Stack operations

  7. Register-based ● Stack operations 14

  8. Register-based ● Stack operations 9 14

  9. Register-based ● Stack operations 9 add 14

  10. Register-based ● Stack operations 23

  11. Register-based ● Stack operations ● Register operations 9 14

  12. Register-based ● Stack operations ● Register operations 9 14 add

  13. Register-based ● Stack operations ● Register operations 23 9 14

  14. Register-based ● Stack operations ● Register operations ● Fewer instructions ● Hardware registers ● Register spilling ● Flexible register sets

  15. Continuation Passing Style ● Stack-based control flow

  16. Continuation Passing Style ● Stack-based control flow foo

  17. Continuation Passing Style ● Stack-based control flow foo return addr

  18. Continuation Passing Style ● Stack-based control flow 12 9 foo return addr

  19. Continuation Passing Style ● Stack-based control flow return addr

  20. Continuation Passing Style ● Stack-based control flow

  21. Continuation Passing Style ● Stack-based control flow ● Continuation-based Context: control flow main

  22. Continuation Passing Style ● Stack-based control flow ● Continuation-based Context: control flow main Context: foo

  23. Continuation Passing Style ● Stack-based control flow Continuation ● Continuation-based Context: control flow main Context: foo

  24. Continuation Passing Style ● Stack-based control flow Continuation ● Continuation-based Context: control flow main Context: foo Context: bar

  25. Continuation Passing Style ● Stack-based control flow Continuation Continuation ● Continuation-based Context: control flow main Context: foo Context: bar

  26. Continuation Passing Style ● Stack-based control flow Continuation Continuation ● Continuation-based Context: control flow main ● Linked list Context: ● Cheap continuations foo ● Deeply nested contexts Context: ● Tail recursion bar

  27. Parser Grammar Engine (PGE) Parrot Compiler Toolkit (PCT) NQP PAST HLLCompiler PASM (assembly language) PIR (intermediate representation) Parrot VM I/O GC Events Exceptions OO IMCC Unicode Threads STM JIT

  28. Languages ● Core VM = C ● PASM/PIR parser = lex/yacc (flex/bison) ● Build tools = Perl/Parrot ● Compiler tools = PIR

  29. Squaak ● Download ● http://www.parrot.org ● Build ● $ perl Configure.pl ● $ make test ● Language ● $ cd examples/languages/squaak ● $ make squaak ● $ make test

  30. Squaak ● hello.sq ● print("Hello, World!") ● ● Run ● $ ./squaak hello.sq

  31. MyLang ● Create ● $ perl mk_language_shell.pl MyLang ● Run ● $ cd mylang ● $ make test ● Extend ● $ vim src/parser/grammar.pg

  32. Compiler Tools Tutorial ● In the Parrot distribution: ● examples/languages/squaak/doc

  33. Questions? ● Get involved at parrot-dev@lists.parrot.org or #parrot on irc.parrot.org

Recommend


More recommend