<%method title>Perl 6 Internals Dan Sugalski
TPC 5.0

"Here there be dragons"

The big goals of perl 6's internals

Some global decisions

The quick overview

The parser

The Bytecode Compiler

The optimizer

The Interpreter

The Parser

Parser goals

Parsing perl isn't easy

The Compiler

From syntax tree to bytecode

The Optimizer

Things that make optimizing perl tough

The Interpreter

Interpreter goals

The perl 6 interpreter is software CPU

CPU specs

The regex engine

A few words on the stack system

Bytecode

What is bytecode?

Data Structures

Variables

Scalars

Arrays

Hashes

Strings

String handling

Numbers

Vtables

Vtables (cont'd)

Vtables hide data manipulation

For example:

Fetching the string value of a scalar

For scalars with strings:


String *get_str(PMC *my_PMC) {
  return my_PMC->data_pointer;
}

For int-only scalar:

String *get_str(PMC *my_PMC) {


  my_PMC->data_pointer = 
    make_string(my_PMC->integer);
  my_PMC->vtable = int_and_string_vtable;
  return my_PMC->data_pointer;
}

Memory Management

Getting headers

Buffer Management

Garbage Collection

The perl 6 GC is a copying collector

GC considerations for Objects

Extensions beware!

Extending Perl 6

Extensions Made Easier

Embedding

Extensions

Extensions (cont)

Homegrown Opcodes and Vtables

Utility library

Variations on a Theme

The source doesn't have to be perl

The interpreter doesn't have to interpret


HTMLified from Dan's powerpoint talk by Daniel Allen (da@coder.com) on 15 Aug. 2001.