Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 94 lines (58 sloc) 5.275 kb
a948cae @moritz [docs] add links to architecture.svg, and a HTML document to which it li...
moritz authored
1 <html>
2 <head>
1905259 Updated description of the Core settings
Salve J. Nilsen authored
3 <title>How Rakudo compiles a Perl 6 program</title>
a948cae @moritz [docs] add links to architecture.svg, and a HTML document to which it li...
moritz authored
4 </head>
5 <body style="margin:2ex">
6
1905259 Updated description of the Core settings
Salve J. Nilsen authored
7 <h1>How Rakudo compiles a Perl 6 program</h1>
a948cae @moritz [docs] add links to architecture.svg, and a HTML document to which it li...
moritz authored
8
9 <object
10 style="margin:2ex; float:left"
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
11 data="architecture.svg"
a948cae @moritz [docs] add links to architecture.svg, and a HTML document to which it li...
moritz authored
12 type="image/svg+xml"
13 alt="Rakudo flow chart"
14 >
15 </object>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
16
a948cae @moritz [docs] add links to architecture.svg, and a HTML document to which it li...
moritz authored
17 <a id="action-methods" />
1905259 Updated description of the Core settings
Salve J. Nilsen authored
18 <h2 id="parser" >Parser and Action Methods</h2>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
19
1905259 Updated description of the Core settings
Salve J. Nilsen authored
20 <p>The Perl 6 source code is transformed in various stages, of which the first two are the Parser and Action Method stages. The Parser creates a parse tree out of the Perl 6 source code and then gives control to appropriate action methods that annotate the parse tree, incrementally turning it into an Abstract Syntax Tree (AST). When an action method is done annotating, control is handed back to the parser, which then continues parsing the Perl 6 code and "fire off" new action methods as it goes.</p>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
21
1905259 Updated description of the Core settings
Salve J. Nilsen authored
22 <p>The result of these two stages interacting is an "improved PAST" (Perl 6 Abstract Syntax Tree) called QAST. This tree is then passed on to the QAST compiler.</p>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
23
1905259 Updated description of the Core settings
Salve J. Nilsen authored
24 <p>The parser and action methods are implemented in "Not Quite Perl 6" (NQP) and are part of Rakudo and hosted in the Rakudo repository at <a href="../src/Perl6/Grammar.pm">src/Perl6/Grammar.pm</a> and <a href="../src/Perl6/Actions.pm">src/Perl6/Actions.pm</a>.</p>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
25
1905259 Updated description of the Core settings
Salve J. Nilsen authored
26 <h2 id="the-world">The World</h2>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
27
1905259 Updated description of the Core settings
Salve J. Nilsen authored
28 <p>The World is where the parser and the action methods store any declarations they encouter during their runs, including Classes, Types, Signatures, Constants, Subs and Methods.</p>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
29
30
1905259 Updated description of the Core settings
Salve J. Nilsen authored
31 <h2 id="qast-compiler">QAST compiler</h2>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
32
1905259 Updated description of the Core settings
Salve J. Nilsen authored
33 <p>The QAST compiler transforms the abstract syntax tree into a PIRT (Parrot Intermediate Representation Tree). To do this, the QAST compiler does a series of translations on the AST, creating PIRT nodes that implement the operations specified by the QAST nodes.</p>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
34
1905259 Updated description of the Core settings
Salve J. Nilsen authored
35 <p>In addition, the QAST compiler is responsible for serializing <em>The World</em> in such a way that later stages can get access to the declarations stored there during the parser and action methods stages.</p>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
36
1905259 Updated description of the Core settings
Salve J. Nilsen authored
37 <p>There's also opportunity to apply some VM-specific optimizations at this point. When this is done, the resulting PIRT is passed to the PIRT serializer.</p>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
38
1905259 Updated description of the Core settings
Salve J. Nilsen authored
39 <p>This stage is described in the different files in the <a href="../nqp/src/QAST/">nqp/src/QAST/</a> directory.</p>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
40
1905259 Updated description of the Core settings
Salve J. Nilsen authored
41 <h2 id="pirt-serializer">PIRT serializer</h2>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
42
1905259 Updated description of the Core settings
Salve J. Nilsen authored
43 <p>The PIRT serializer "squashes" the PIR Tree into a format that can be passed to Parrot itself and it's IMCC (InterMediate Code Compiler) stage.</p>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
44
1905259 Updated description of the Core settings
Salve J. Nilsen authored
45 <p>You can read more about this at <a href="../nqp/src/QAST/PIRT.nqp">nqp/src/QAST/PIRT.nqp</a>.</p>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
46
47
48 <a id="parrot-runtime" />
49 <h2 id="imcc">IMCC and Parrot runtime</h2>
50
1905259 Updated description of the Core settings
Salve J. Nilsen authored
51 <p>The IMCC (InterMediate Code Compiler) receives the PIR code from the PIRT serializer and then transforms it into Parrot Byte Code (PBC). IMCC is parrot's PIR compiler, written in C and statically linked into parrot. The byte code can then be stored to disk or executed in memory by one of the <em>run cores</em> availabe as part of the Parrot runtime. This is in some sense the heart of Parrot - or one of the hearts; There are several different cores available, including one for just-in-time compilation (JIT), one for debugging and others.</p>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
52
1905259 Updated description of the Core settings
Salve J. Nilsen authored
53 <p>You can find out more about the IMCC in the <a href="../parrot/docs/imcc/">parrot/docs/imcc/</a> directory, and about the different run cores in the <a href="../parrot/docs/running.pod">parrot/docs/running.pod</a></p>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
54
55 <h2 id="pmc-dynops">PMCs and dynops</h2>
56
57 <p>There are also some supporting custom types and operations in Rakudo called <em>dynamic PMCs</em> and <em>dynamic ops</em> (dynops) which are written in C, and helper functions written in NQP and PIR. These supporting libraries exist for adding features to Parrot that are needed to handle special features in Perl 6.</p>
58
1905259 Updated description of the Core settings
Salve J. Nilsen authored
59 <h2 id="core-setting">Core setting library</h2>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
60
1905259 Updated description of the Core settings
Salve J. Nilsen authored
61 <p>The core settings library is the library containing the methods, classes and almost all other features that make up the Rakudo Perl 6 implementation. This library is tightly coupled with the <code>perl6</code> binary, and loaded by default every time <code>perl6</code> is run.</p>
a948cae @moritz [docs] add links to architecture.svg, and a HTML document to which it li...
moritz authored
62
63 <h2 id="glossary">Glossary</h2>
64
65 <dl>
66 <dt>NQP</dt>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
67 <dd>Not Quite Perl 6, a small subset of Perl 6 that is used for tree transformations in compilers.</dd>
68
69 <dt>PIR</dt>
70 <dd>Parrot Intermediate Representation, the most commonly used for of parrot assembly (which is still high-level enough to be written by humans).</dd>
71
72 <dt>IMCC</dt>
73 <dd>InterMediate Code Compiler, the part of parrot that compiles PIR into byte code.</dd>
74
75 <dt>PBC</dt>
76 <dd>Parrot Byte Code, the binary form to which all parrot programs are compiled in the end.</dd>
77
78 <dt>Core setting</dt>
1905259 Updated description of the Core settings
Salve J. Nilsen authored
79 <dd>The core setting is the Perl 6 standard library. It is part of the perl6 executable, and contains all the standard features available in Perl 6.</dd>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
80
81 <dt>QAST</dt>
1905259 Updated description of the Core settings
Salve J. Nilsen authored
82 <dd>The "improved" Abstract Syntax Tree used in Rakudo Perl 6. It contains information about how the program is structured, and what it is supposed to do.</dd>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
83
84 <dt>PIRT</dt>
1905259 Updated description of the Core settings
Salve J. Nilsen authored
85 <dd>Parrot Intermediate Representation Tree.</dd>
63de79c Updated architecture docs to current state
Salve J. Nilsen authored
86
a948cae @moritz [docs] add links to architecture.svg, and a HTML document to which it li...
moritz authored
87 </dl>
88
89 </body>
90 </html>
91 <!--
92 vim: ft=html spell sw=4 ts=4 expandtab tw=75
93 -->
Something went wrong with that request. Please try again.