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

parrot vm
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Parrot VM

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

slide-2
SLIDE 2

Parrot VM

Ruby Python Perl 5 Perl 6 PHP

slide-3
SLIDE 3

Parrot VM

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

slide-4
SLIDE 4

Dynamic Features

  • Runtime vs. compile-time
  • Extend code (eval, load)
  • Define classes
  • Alter type system
  • Higher-order functions
  • Closures, Continuations, Coroutines
slide-5
SLIDE 5

Goals

  • Revolution...
  • ...becoming Establishment
  • Powerful tools
  • Portability
  • Interoperability
  • Language evolution
slide-6
SLIDE 6

Register-based

  • Stack operations
slide-7
SLIDE 7

Register-based

  • Stack operations

14

slide-8
SLIDE 8

Register-based

  • Stack operations

9 14

slide-9
SLIDE 9

Register-based

  • Stack operations

9 14 add

slide-10
SLIDE 10

Register-based

  • Stack operations

23

slide-11
SLIDE 11

Register-based

  • Stack operations
  • Register operations

9 14

slide-12
SLIDE 12

Register-based

  • Stack operations
  • Register operations

9 14 add

slide-13
SLIDE 13

Register-based

  • Stack operations
  • Register operations

9 14 23

slide-14
SLIDE 14

Register-based

  • Stack operations
  • Register operations
  • Fewer instructions
  • Hardware registers
  • Register spilling
  • Flexible register sets
slide-15
SLIDE 15

Continuation Passing Style

  • Stack-based control flow
slide-16
SLIDE 16

Continuation Passing Style

  • Stack-based control flow

foo

slide-17
SLIDE 17

Continuation Passing Style

  • Stack-based control flow

return addr foo

slide-18
SLIDE 18

Continuation Passing Style

  • Stack-based control flow

9 return addr foo 12

slide-19
SLIDE 19

Continuation Passing Style

  • Stack-based control flow

return addr

slide-20
SLIDE 20

Continuation Passing Style

  • Stack-based control flow
slide-21
SLIDE 21

Continuation Passing Style

  • Stack-based control flow
  • Continuation-based

control flow

Context: main

slide-22
SLIDE 22

Continuation Passing Style

  • Stack-based control flow
  • Continuation-based

control flow

Context: main Context: foo

slide-23
SLIDE 23

Continuation Passing Style

  • Stack-based control flow
  • Continuation-based

control flow

Continuation Context: main Context: foo

slide-24
SLIDE 24

Continuation Passing Style

  • Stack-based control flow
  • Continuation-based

control flow

Continuation Context: main Context: foo Context: bar

slide-25
SLIDE 25

Continuation Passing Style

  • Stack-based control flow
  • Continuation-based

control flow

Continuation Continuation Context: main Context: foo Context: bar

slide-26
SLIDE 26

Continuation Passing Style

  • Stack-based control flow
  • Continuation-based

control flow

  • Linked list
  • Cheap continuations
  • Deeply nested contexts
  • Tail recursion

Continuation Continuation Context: main Context: foo Context: bar

slide-27
SLIDE 27

Parrot VM

PASM (assembly language) Parser Grammar Engine (PGE) Parrot Compiler Toolkit (PCT)

I/O GC Events Threads OO Unicode Exceptions IMCC STM JIT

PIR (intermediate representation)

NQP PAST HLLCompiler

slide-28
SLIDE 28

Languages

  • Core VM = C
  • PASM/PIR parser = lex/yacc (flex/bison)
  • Build tools = Perl/Parrot
  • Compiler tools = PIR
slide-29
SLIDE 29

Squaak

  • Download
  • http://www.parrot.org
  • Build
  • $ perl Configure.pl
  • $ make test
  • Language
  • $ cd examples/languages/squaak
  • $ make squaak
  • $ make test
slide-30
SLIDE 30

Squaak

  • hello.sq
  • print("Hello, World!")
  • Run
  • $ ./squaak hello.sq
slide-31
SLIDE 31

MyLang

  • Create
  • $ perl mk_language_shell.pl MyLang
  • Run
  • $ cd mylang
  • $ make test
  • Extend
  • $ vim src/parser/grammar.pg
slide-32
SLIDE 32

Compiler Tools Tutorial

  • In the Parrot distribution:
  • examples/languages/squaak/doc
slide-33
SLIDE 33

Questions?

  • Get involved at parrot-dev@lists.parrot.org or

#parrot on irc.parrot.org