Ticket #215: book_cage_clean.patch

File book_cage_clean.patch, 15.9 KB (added by mikehh, 13 years ago)

Patch at revison 35914

  • docs/book/ch02_getting_started.pod

     
    142142 
    143143=head1 Building Parrot 
    144144 
    145 Z<CHP-9-SECT-1> 
     145Z<CHP-2-SECT-2.2.2> 
    146146 
    147147X<Parrot;source code> 
    148148The first step before you start playing with Parrot's PASM and PIR 
     
    192192 
    193193=head3 Patch submission 
    194194 
    195 Z<CHP-2-SECT-2.2.2> 
     195Z<CHP-2-SECT-2.2.3> 
    196196 
    197197X<Parrot;patch submission> 
    198198Parrot development proceeds through a continuous stream of patches. 
     
    324324 
    325325=head3 Bug tracking 
    326326 
    327 Z<CHP-2-SECT-2.2.3> 
     327Z<CHP-2-SECT-2.2.4> 
    328328 
    329329X<Parrot;bug tracking> 
    330330Bug reports go to the same address as patch submissions 
  • docs/book/ch08_architecture.pod

     
    22 
    33=head0 Parrot Internals 
    44 
    5 Z<CHP-7> 
     5Z<CHP-8> 
    66 
    77This chapter details the architecture and internal workings of Parrot, 
    88and attempts to explain how Parrot has been designed and how it operates. 
     
    1313 
    1414=head1 Core Design Principles 
    1515 
    16 Z<CHP-7-SECT-1> 
     16Z<CHP-8-SECT-1> 
    1717 
    1818X<Parrot;internals> 
    1919Three main principles drive the design of 
     
    7272 
    7373=head1 Parrot's Architecture 
    7474 
    75 Z<CHP-7-SECT-2> 
     75Z<CHP-8-SECT-2> 
    7676 
    7777The X<architecture;Parrot> 
    7878X<Parrot;architecture> 
     
    8585 
    8686=begin figure Parrot's flow 
    8787 
    88 Z<CHP-7-FIG-1> 
     88Z<CHP-8-FIG-1> 
    8989F<figs/p6e_0801.png> 
    9090 
    9191=end figure 
     
    113113 
    114114=head2 Parser 
    115115 
    116 Z<CHP-7-SECT-2.1> 
     116Z<CHP-8-SECT-2.1> 
    117117 
    118118X<parser, Parrot> 
    119119X<Parrot;parser module> 
     
    171171 
    172172=head2 Compiler 
    173173 
    174 Z<CHP-7-SECT-2.2> 
     174Z<CHP-8-SECT-2.2> 
    175175 
    176176 
    177177X<Parrot;compiler module> 
     
    194194 
    195195=head2 Optimizer 
    196196 
    197 Z<CHP-7-SECT-2.3> 
     197Z<CHP-8-SECT-2.3> 
    198198 
    199199X<Parrot;optimizer module> 
    200200X<optimizer> 
     
    316316 
    317317=head1 The Interpreter 
    318318 
    319 Z<CHP-7-SECT-3> 
     319Z<CHP-8-SECT-3> 
    320320 
    321321The X<interpreter, Parrot> 
    322322interpreter is the engine that actually runs the code emitted by the 
     
    360360 
    361361=head2 Registers 
    362362 
    363 Z<CHP-7-SECT-3.1> 
     363Z<CHP-8-SECT-3.1> 
    364364 
    365365X<interpreter, Parrot;registers> 
    366366As we've seen in previous chapers, Parrot has four basic types of 
     
    375375 
    376376=head2 Strings 
    377377 
    378 Z<CHP-7-SECT-3.3> 
     378Z<CHP-8-SECT-3.3> 
    379379 
    380380X<strings;Parrot> 
    381381X<interpreter, Parrot;strings> 
     
    455455 
    456456=head2 Variables 
    457457 
    458 Z<CHP-7-SECT-3.4> 
     458Z<CHP-8-SECT-3.4> 
    459459 
    460460X<variables;Parrot interpreter and> 
    461461X<interpreter, Parrot;variables> 
     
    506506 
    507507=head2 Bytecode 
    508508 
    509 Z<CHP-7-SECT-3.5> 
     509Z<CHP-8-SECT-3.5> 
    510510 
    511511Like any CPU, software, or hardware, Parrot needs a set of 
    512512instructions to tell it what to do. For hardware, this is a stream of 
     
    560560 
    561561=head1 I/O, Events, and Threads 
    562562 
    563 Z<CHP-7-SECT-4> 
     563Z<CHP-8-SECT-4> 
    564564 
    565565Parrot has comprehensive support for I/O, threads, and events. These 
    566566three systems are interrelated, so we'll treat them together. The 
     
    570570 
    571571=head2 I/O 
    572572 
    573 Z<CHP-7-SECT-4.1> 
     573Z<CHP-8-SECT-4.1> 
    574574 
    575575Parrot's base X<I/O;Parrot> I/O system is fully X<asynchronous I/O> 
    576576asynchronous with callbacks and per-request private data. Since this 
     
    637637 
    638638=head2 Events 
    639639 
    640 Z<CHP-7-SECT-4.2> 
     640Z<CHP-8-SECT-4.2> 
    641641 
    642642An X<events, Parrot> event is a notification that something has 
    643643happened: the user has manipulated a GUI element, an I/O request has 
     
    710710 
    711711=head2 Signals 
    712712 
    713 Z<CHP-7-SECT-4.3> 
     713Z<CHP-8-SECT-4.3> 
    714714 
    715715X<signals, Parrot> 
    716716Signals are a special form of event, based on the standard Unix signal 
     
    771771 
    772772=head2 Threads 
    773773 
    774 Z<CHP-7-SECT-4.4> 
     774Z<CHP-8-SECT-4.4> 
    775775 
    776776X<threads, Parrot> 
    777777Threads are a means of splitting a process into multiple pieces that 
     
    884884 
    885885=head1 Objects 
    886886 
    887 Z<CHP-7-SECT-5> 
     887Z<CHP-8-SECT-5> 
    888888 
    889889X<objects;Parrot> 
    890890Perl 5, Perl 6, Python, and Ruby are all object-oriented languages in 
     
    899899 
    900900=head2 Generic Object Interfacing 
    901901 
    902 Z<CHP-7-SECT-5.1> 
     902Z<CHP-8-SECT-5.1> 
    903903 
    904904X<PMCs (Parrot Magic Cookies);handling method calls> 
    905905Parrot's object system is very simple--in fact, a PMC only has to handle 
     
    924924 
    925925=head2 Parrot Objects 
    926926 
    927 Z<CHP-7-SECT-5.2> 
     927Z<CHP-8-SECT-5.2> 
    928928 
    929929X<objects;Parrot> 
    930930X<Parrot;objects> 
     
    986986 
    987987=head2 Mixed Class-Type Support 
    988988 
    989 Z<CHP-7-SECT-5.3> 
     989Z<CHP-8-SECT-5.3> 
    990990 
    991991X<mixed class-type support in Parrot> 
    992992X<classes;Parrot;mixed class support> 
     
    10151015 
    10161016=head1 Advanced Features 
    10171017 
    1018 Z<CHP-7-SECT-6> 
     1018Z<CHP-8-SECT-6> 
    10191019 
    10201020Since the languages Parrot targets (like Perl and Ruby) have 
    10211021sophisticated concepts as core features, it's in Parrot's best 
     
    10241024 
    10251025=head2 Garbage Collection 
    10261026 
    1027 Z<CHP-7-SECT-6.1> 
     1027Z<CHP-8-SECT-6.1> 
    10281028 
    10291029X<garbage collection;Parrot> 
    10301030It's expected that modern languages have garbage collection built in. 
     
    10991099 
    11001100=head2 Multimethod Dispatching 
    11011101 
    1102 Z<CHP-7-SECT-6.2> 
     1102Z<CHP-8-SECT-6.2> 
    11031103 
    11041104X<multimethod;dispatching> 
    11051105Multimethod dispatching (also known as signature-based dispatching) is 
     
    11621162 
    11631163=head2 Continuations 
    11641164 
    1165 Z<CHP-7-SECT-6.3> 
     1165Z<CHP-8-SECT-6.3> 
    11661166 
    11671167X<continuations> 
    11681168Continuations are possibly the most powerful high-level flow control 
     
    12341234 
    12351235=head2 Coroutines 
    12361236 
    1237 Z<CHP-7-SECT-6.4> 
     1237Z<CHP-8-SECT-6.4> 
    12381238 
    12391239X<coroutines> 
    12401240A coroutine is a subroutine or method that can suspend itself partway 
     
    12561256 
    12571257=head1 Conclusion 
    12581258 
    1259 Z<CHP-7-SECT-7> 
     1259Z<CHP-8-SECT-7> 
    12601260 
    12611261We've touched on much of Parrot's core functionality, but certainly 
    12621262not all. Hopefully we've given you enough of a feel for how Parrot 
  • docs/book/ch12_opcodes.pod

     
    22 
    33=head1 Opcodes and Runcores 
    44 
    5 Z<CHP-11> 
     5Z<CHP-12> 
    66 
    77The smallest executable component is not the compilation unit or even 
    88the subroutine, but is actually the opcode. Opcodes in PASM, like opcodes 
     
    5050 
    5151=over 4 
    5252 
    53 =item* Slow Core 
     53=item * Slow Core 
    5454 
    5555The slow core is a basic runcore design that treats each opcode as a 
    5656separate function at the C level. Each function is called, and returns 
     
    7171          UPDATE_INTERPRETER(); 
    7272  } 
    7373 
    74 =item* Fast Core 
     74=item * Fast Core 
    7575 
    7676The fast core is a bare-bones core that doesn't do any of the 
    7777bounds-checking or context updating that the slow core does. The fast 
     
    8686          DISPATCH_OPCODE(pc); 
    8787  } 
    8888 
    89 =item* Switch Core 
     89=item * Switch Core 
    9090 
    9191As its name implies, the switch core uses a gigantic C C<switch / case> 
    9292structure to execute opcodes. Here's a brief example of how this 
     
    109109pointer, dereferencing the opcode pointer, and then a jump to the C<case> 
    110110statement for the next opcode. 
    111111 
    112 =item* Computed Goto Core 
     112=item * Computed Goto Core 
    113113 
    114114I<Computed Goto> is a feature of some C compilers where a label is 
    115115treated as a piece of data that can be stored as a C<void *> pointer. Each 
     
    167167presented here. However, as we shall see with the precomputed goto core, 
    168168it isn't optimized as aggressively as is possible. 
    169169 
    170 =item* Precomputed Goto Core 
     170=item * Precomputed Goto Core 
    171171 
    172172The precomputed goto core is an amazingly fast optimized core that uses 
    173173the same computed goto feature, but performs the array dereferencing 
     
    208208available with compilers that support computed goto, such as GCC. Parrot 
    209209will not have access to this core if it is built with a different compiler. 
    210210 
    211 =item* Tracing Core 
     211=item * Tracing Core 
    212212 
    213 =item* Profiling Core 
     213=item * Profiling Core 
    214214 
    215215The profiling core analyzes the performance of Parrot, and helps to 
    216216determine where bottlenecks and trouble spots are in the programs that 
     
    227227number of calls to each subroutine made. All this information is helpfully 
    228228printed to the STDERR output for later analysis. 
    229229 
    230 =item* GC Debug Core 
     230=item * GC Debug Core 
    231231 
    232232Parrot's garbage collector has been known as a weakness in the system 
    233233for several years. In fact, the garbage collector and memory management 
     
    243243performance is terrible, but that's not the point: it's almost guaranteed 
    244244to find problems in the memory system if they exist. 
    245245 
    246 =item* Debug Core 
     246=item * Debug Core 
    247247 
    248248The debug core works like a normal software debugger, such as GDB. The 
    249249debug core executes each opcode, and then prompts the user to enter a 
     
    361361 
    362362=head2 Dynops 
    363363 
     364=cut 
    364365 
    365366########################################################################## 
    366367#                              PSEUDOPOD LEGEND 
  • docs/book/ch09_pct.pod

     
    5555 
    5656=over 4 
    5757 
    58 =item* A main file 
     58=item * A main file 
    5959 
    6060The main file should contain the C<:main> function that is the driver 
    6161program for the compiler. Here, a new C<PCT::HLLCompiler> object is 
     
    6464although thankfully they tend to be very short. Most of the action 
    6565happens elsewhere. 
    6666 
    67 =item* A parser file 
     67=item * A parser file 
    6868 
    6969The grammar for the high level language is specified using the Perl 6 
    7070grammar engine (PGE) and is stored in a C<.pg> file. This file should 
    7171subclass the C<PCT::Grammar> class and implement all the necessary 
    7272rules to successfully parse the language. 
    7373 
    74 =item* An actions file 
     74=item * An actions file 
    7575 
    7676Actions files are written in NQP. They take match objects generated by 
    7777the grammar file and convert them into an Abstract Syntax Tree (AST) 
     
    196196 
    197197=over 4 
    198198 
    199 =item* Rules 
     199=item * Rules 
    200200 
    201201Rules are the most basic grammar element. Rules may call subrules and 
    202202may also contain arbitrary whitespace, which is ignored. 
    203203 
    204 =item* Tokens 
     204=item * Tokens 
    205205 
    206206Tokens represent basic regular expressions. They may not call subrules 
    207207and whitespace is treated literally. {{I don't think this is right, but 
    208208I'm adding it here anyway as a placeholder -- Whiteknight}} 
    209209 
    210 =item* Protoregex 
     210=item * Protoregex 
    211211 
    212212A protoregex is like a rule or a token, except it can be overloaded 
    213213dynamically. 
  • docs/book/ch04_pir_subroutines.pod

     
    11=pod 
    22 
    3 Z<CHP-4> 
    4  
    53=head1 Subroutines 
    64 
    75Z<CHP-4> 
     
    454452 
    455453=head2 Compilation Units Revisited 
    456454 
    457 Z<CHP-4-SECT-1.2> 
     455Z<CHP-4-SECT-1.1> 
    458456 
    459457The term "compilation unit" is one that's been bandied about throughout the 
    460458chapter and it's worth some amount of explanation here. A compilation unit 
     
    499497 
    500498=head3 PASM Subroutines 
    501499 
    502 Z<CHP-4-SECT-1.1> 
     500Z<CHP-4-SECT-1.2> 
    503501 
    504502X<subroutines;PASM> 
    505503X<PASM (Parrot assembly language);subroutines> 
     
    537535 
    538536=head3 Namespaces 
    539537 
    540 Z<CHP-4-SECT-2> 
     538Z<CHP-4-SECT-2.1> 
    541539 
    542540X<Namespaces> 
    543541X<.namespace> 
     
    586584 
    587585=head3 Calling Methods 
    588586 
    589 Z<CHP-4-SECT-2> 
     587Z<CHP-4-SECT-2.2> 
    590588 
    591589Now that we've discussed namespaces, we can start to discuss all the 
    592590interesting things that namespaces enable, like object-oriented 
     
    793791 
    794792=over 4 
    795793 
    796 =item* Identifies coroutines 
     794=item * Identifies coroutines 
    797795 
    798796When Parrot sees a yield, it knows to create a coroutine PMC object 
    799797instead of a Subroutine one. 
    800798 
    801 =item* Creates a continuation 
     799=item * Creates a continuation 
    802800 
    803801Continuations, as we have already seen, allow us to continue 
    804802execution at the point of the continuation later. It's like a snapshot of 
     
    806804the coroutine and stores the continuation object in the coroutine object 
    807805or later resuming from the point of the C<.yield>. 
    808806 
    809 =item* Returns a value 
     807=item * Returns a value 
    810808 
    811809C<.yield> can return a value N<or many values, or no values> to the caller. 
    812810It is basically the same as a C<.return> in this regard. 
  • docs/book/ch13_reference.pod

     
    22 
    33=head1 Parrot Reference 
    44 
    5 Z<CHP-10> 
     5Z<CHP-13> 
    66 
    77This chapter contains a condensed list of PASM opcodes, PIR directives 
    88and instructions, and Parrot command-line options, sorted alphabetically 
     
    1313 
    1414=head2 PASM Opcodes 
    1515 
    16 Z<CHP-10-SECT-1> 
     16Z<CHP-13-SECT-1> 
    1717 
    1818X<PASM (Parrot assembly language);opcodes, quick reference> 
    1919For complete details on each opcode and the latest changes, read the 
     
    12451245 
    12461246=begin table picture Interpinfo flags 
    12471247 
    1248 Z<CHP-10-TABLE-1> 
     1248Z<CHP-13-TABLE-1> 
    12491249 
    12501250=headrow 
    12511251 
     
    24152415 
    24162416=begin table picture Stringinfo arguments 
    24172417 
    2418 Z<CHP-10-TABLE-2> 
     2418Z<CHP-13-TABLE-2> 
    24192419 
    24202420=headrow 
    24212421 
     
    28122812 
    28132813=head2 PIR Directives 
    28142814 
    2815 Z<CHP-10-SECT-2> 
     2815Z<CHP-13-SECT-2> 
    28162816 
    28172817X<PIR (Parrot intermediate representation);quick reference;directives> 
    28182818This is a summary of PIR directives. Directives are preprocessed by the 
     
    30313031 
    30323032=head2 PIR Instructions 
    30333033 
    3034 Z<CHP-10-SECT-3> 
     3034Z<CHP-13-SECT-3> 
    30353035 
    30363036X<PIR (Parrot intermediate representation);quick reference;instructions> 
    30373037This section is a quick reference to PIR instructions. For more details 
     
    33233323 
    33243324=head2 Parrot Command-Line Options 
    33253325 
    3326 Z<CHP-10-SECT-4> 
     3326Z<CHP-13-SECT-4> 
    33273327 
    33283328X<command-line options (Parrot)> 
    33293329X<Parrot;command-line options> 
     
    33363336 
    33373337=head3 General Usage 
    33383338 
    3339 Z<CHP-10-SECT-4.1> 
     3339Z<CHP-13-SECT-4.1> 
    33403340 
    33413341  parrot [options] file [arguments] 
    33423342 
     
    33463346 
    33473347=head3 Assembler Options 
    33483348 
    3349 Z<CHP-10-SECT-4.2> 
     3349Z<CHP-13-SECT-4.2> 
    33503350 
    33513351=over 4 
    33523352 
     
    33743374 
    33753375=begin table picture Debug bits 
    33763376 
    3377 Z<CHP-10-TABLE-3> 
     3377Z<CHP-13-TABLE-3> 
    33783378 
    33793379=headrow 
    33803380 
     
    35133513 
    35143514=begin table picture Optimizations 
    35153515 
    3516 Z<CHP-10-TABLE-4> 
     3516Z<CHP-13-TABLE-4> 
    35173517 
    35183518=headrow 
    35193519 
     
    35613561 
    35623562=head3 Bytecode Interpreter Options 
    35633563 
    3564 Z<CHP-10-SECT-4.3> 
     3564Z<CHP-13-SECT-4.3> 
    35653565 
    35663566X<Parrot;bytecode interpreter options> 
    35673567X<bytecode interpreter options (Parrot)> 
  • docs/book/ch10_hlls.pod

     
    165165 
    166166=over 4 
    167167 
    168 =item* VTable methods 
     168=item * VTable methods 
    169169 
    170170VTable methods are the standard interface for PMC data types, and all PMCs 
    171171have them. If the PMCs were written properly to satisfy this interface 
    172172all the necessary information from those PMCs. Operate on the PMCs at the 
    173173VTable level, and we can safely ignore the implementation details of them. 
    174174 
    175 =item* Class Methods 
     175=item * Class Methods 
    176176 
    177177If a library returns data in a particular format, the library reuser should 
    178178know, understand, and make use of that format. Classes written in other 
  • docs/book/ch11_pmcs.pod

     
    22 
    33=head1 PMCs 
    44 
    5 Z<CHP-10> 
     5Z<CHP-11> 
    66 
    77PMCs are one of the four fundamental data types in Parrot, and definitely one 
    88of the most useful. A PMC can contain a single scalar value (integer, floating 
     
    229229=head3 Loading dynpmcs 
    230230 
    231231 
     232=cut 
    232233 
    233  
    234234########################################################################## 
    235235#                              PSEUDOPOD LEGEND 
    236236# 
  • docs/book/ch07_testing_and_debugging.pod

     
    22 
    33=head0 Testing and Debugging 
    44 
    5 Z<CHP-6> 
     5Z<CHP-7> 
    66 
    77Programming languages and the virtual machines on which they run are just 
    88one small part of the total programming ecosystem. Programmers require not 
     
    1515 
    1616=head1 Writing Tests 
    1717 
    18 Z<CHP-6-SECT-1> 
     18Z<CHP-7-SECT-1> 
    1919 
    2020X<testing Parrot> 
    2121Parrot is volunteer-driven, and contributions from new users are always 
     
    118118 
    119119=head1 The Parrot Debugger 
    120120 
    121 Z<CHP-6-SECT-2> 
     121Z<CHP-7-SECT-2> 
    122122 
    123123=cut 
    124124