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 Parrot VM
Dynamic Features ● Runtime vs. compile-time ● Extend code (eval, load) ● Define classes ● Alter type system ● Higher-order functions ● Closures, Continuations, Coroutines
Goals ● Revolution... ● ...becoming Establishment ● Powerful tools ● Portability ● Interoperability ● Language evolution
Register-based ● Stack operations
Register-based ● Stack operations 14
Register-based ● Stack operations 9 14
Register-based ● Stack operations 9 add 14
Register-based ● Stack operations 23
Register-based ● Stack operations ● Register operations 9 14
Register-based ● Stack operations ● Register operations 9 14 add
Register-based ● Stack operations ● Register operations 23 9 14
Register-based ● Stack operations ● Register operations ● Fewer instructions ● Hardware registers ● Register spilling ● Flexible register sets
Continuation Passing Style ● Stack-based control flow
Continuation Passing Style ● Stack-based control flow foo
Continuation Passing Style ● Stack-based control flow foo return addr
Continuation Passing Style ● Stack-based control flow 12 9 foo return addr
Continuation Passing Style ● Stack-based control flow return addr
Continuation Passing Style ● Stack-based control flow
Continuation Passing Style ● Stack-based control flow ● Continuation-based Context: control flow main
Continuation Passing Style ● Stack-based control flow ● Continuation-based Context: control flow main Context: foo
Continuation Passing Style ● Stack-based control flow Continuation ● Continuation-based Context: control flow main Context: foo
Continuation Passing Style ● Stack-based control flow Continuation ● Continuation-based Context: control flow main Context: foo Context: bar
Continuation Passing Style ● Stack-based control flow Continuation Continuation ● Continuation-based Context: control flow main Context: foo Context: bar
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
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
Languages ● Core VM = C ● PASM/PIR parser = lex/yacc (flex/bison) ● Build tools = Perl/Parrot ● Compiler tools = PIR
Squaak ● Download ● http://www.parrot.org ● Build ● $ perl Configure.pl ● $ make test ● Language ● $ cd examples/languages/squaak ● $ make squaak ● $ make test
Squaak ● hello.sq ● print("Hello, World!") ● ● Run ● $ ./squaak hello.sq
MyLang ● Create ● $ perl mk_language_shell.pl MyLang ● Run ● $ cd mylang ● $ make test ● Extend ● $ vim src/parser/grammar.pg
Compiler Tools Tutorial ● In the Parrot distribution: ● examples/languages/squaak/doc
Questions? ● Get involved at parrot-dev@lists.parrot.org or #parrot on irc.parrot.org
Recommend
More recommend