Raku++ Internals
How a hand-written C++ implementation of Raku works — from source text to native code.
Download the PDF 200 pages · 0.8 MB
- Prefacewho this is for, and the conventions it uses
Ground
- Chapter 1What Raku++ Isthe goals, the four run modes, the shape of the system
- Chapter 2The Shape of the Sourcethe file map, and how to navigate it
The Front End
- Chapter 3The Lexertokens, significant whitespace, quotes, heredocs
- Chapter 4The Parserrecursive descent, a Pratt core, and no compile-time execution
- Chapter 5User-Defined Operators in a Single Passlive tables, precedence traits, and lexical rollback
- Chapter 6The ASTthe node hierarchy, and fields that answer questions about syntax
The Value Model
- Chapter 7
Value: the Fat Tagged Structone fat tagged struct for every runtime value - Chapter 8Strings:
CowStrthe copy-on-write string, and the quadratic it removed - Chapter 9Interning and Comparison:
IStrandMNameinterned tags and packed-prefix name comparison - Chapter 10Numbersnative ints, bignums, rationals, and the spill between them
- Chapter 11Containers, Binding, and Copy Semanticsscopes, binding, and where sharing is broken on purpose
The Interpreter
- Chapter 12The Tree Walkeval, exec, and the per-thread execution registers
- Chapter 13Calls and Parameter Bindingbuilding arguments, activating a routine, binding parameters
- Chapter 14Cooperative Control Flowreturn and friends without a C++ throw
- Chapter 15Dispatchsubs, multis, the method ladder, and re-dispatch
- Chapter 16The Object Systemclasses, roles, mixins, and the meta-object surface
- Chapter 17Laziness, Junctions, and the Wilder Valuesinfinite sequences, gather without coroutines, junctions
- Chapter 18Node Specializationone optimisation, measured end to end
The Regex and Grammar Engine
- Chapter 19Compiling a Regexa second recursive-descent compiler inside the runtime
- Chapter 20The Backtracking Matchercontinuation passing, backtracking, and a step budget
- Chapter 21Grammarsrules, packrat memoisation, actions, protos
- Chapter 22Longest-Token Matchingranking alternations by declarative prefix
Unicode
- Chapter 23Graphemes, Normalization, Collationgraphemes, normalization, collation — from pinned tables
The Back Ends
- Chapter 24Four Ways to Run a Programone program through interpret, bundle, AOT and native
- Chapter 25The Code GeneratorAST to C++, calling the same runtime the interpreter calls
- Chapter 26The
-OOptimizerthree passes, and three defaults that are not passes - Chapter 27Dispatch Cost in Compiled Codewhat each call shape costs, and an analysis that was wrong
- Chapter 28AST Serialization and the Precompiled Parsethe binary AST format, and what invalidates a cache entry
Boundaries
- Chapter 29Moduleswhat use Foo actually does, and where it diverges
- Chapter 30
use nqp: a Compatibility Subseta compatibility subset that costs nothing when unused - Chapter 31NativeCall and the libffi Backendlibffi loaded at run time, and its ABI probed not tabulated
- Chapter 32The Extension ABIthe C ABI an extension compiles against, and why it never sees Value
- Chapter 33Concurrencythe GIL, per-thread registers, and switching the lock off
Around the Compiler
- Chapter 34Tooling Built on the ASTlint, highlight, profile, the REPL, and tools written in Raku
- Chapter 35Measuring, and Provingthe benchmark policy, the gates, and what did not pay
Appendices
- Appendix AThe Tag Setsthe VT, NK and regex-node tag sets
- Appendix BFlags and Environment Variablesevery flag and environment variable
- Appendix CSource Map and Glossarya source map, the rules that are easy to break, a glossary