Author: infinoid Date: Tue Jan 6 21:35:06 2009 New Revision: 35089 Modified: trunk/docs/pdds/pdd13_bytecode.pod trunk/docs/pdds/pdd19_pir.pod
Changes in other areas also in this revision: Added: trunk/t/op/annotate.t Modified: trunk/compilers/imcc/imcc.l trunk/compilers/imcc/imcc.y trunk/compilers/imcc/imclexer.c trunk/compilers/imcc/imcparser.c trunk/compilers/imcc/imcparser.h trunk/compilers/imcc/parser_util.c trunk/compilers/imcc/pbc.c trunk/include/parrot/packfile.h trunk/src/atomic/gcc_x86.c trunk/src/embed.c trunk/src/packfile.c trunk/src/pbc_merge.c trunk/src/pmc/exception.pmc Log: Merge changes from bcanno branch back into trunk. Modified: trunk/docs/pdds/pdd13_bytecode.pod ============================================================================== --- trunk/docs/pdds/pdd13_bytecode.pod (original) +++ trunk/docs/pdds/pdd13_bytecode.pod Tue Jan 6 21:35:06 2009 @@ -307,9 +307,10 @@ | | | 0x02 - Fixup Segment | | | | 0x03 - Constant Table Segment | | | | 0x04 - Bytecode Segment | - | | | 0x05 - Annotations Segment | - | | | 0x06 - PIC Data Segment | - | | | 0x07 - Dependencies Segment | + | | | 0x05 - PIR Debug Segment | + | | | 0x06 - Annotations Segment | + | | | 0x07 - PIC Data Segment | + | | | 0x08 - Dependencies Segment | +--------+--------+--------------------------------------------------------+ | 1 | n | The name of the segment, as a (NULL terminated) ASCII | | | | C string. This must be padded with trailing NULL | @@ -511,6 +512,46 @@ +--------+--------+--------------------------------------------------------+ +=head3 PIR Debug Segment + +This segment stores the filenames and line numbers of PIR code that was +compiled to bytecode. The segment comes in two parts. + +=over 4 + +=item A list of mappings between offsets in the bytecode and filenames, +indicating that the bytecode from that point on until the next entry was +generated from the PIR found in the given filename + +=item A list of mappings between instructions in the bytecode and line +numbers, with one entry per instruction + +=back + +The segment starts with: + + +--------+--------+--------------------------------------------------------+ + | Offset | Length | Description | + +--------+--------+--------------------------------------------------------+ + | 1 | 1 | Number of filename mappings that follow. | + | | | n | + +--------+--------+--------------------------------------------------------+ + +Then come n mappings. + + +--------+--------+--------------------------------------------------------+ + | Offset | Length | Description | + +--------+--------+--------------------------------------------------------+ + | 0 | 1 | Offset in the bytecode. | + +--------+--------+--------------------------------------------------------+ + | 1 | 1 | A string constant holding the filename, stored as an | + | | | index into the constants table. | + +--------+--------+--------------------------------------------------------+ + +This is followed by the line number for each instruction in the bytecode +segment. + + =head3 Annotations Segment Annotations allow any instruction in the bytecode stream to have zero or more @@ -589,8 +630,17 @@ | | | annotations for the given instruction start. | +--------+--------+--------------------------------------------------------+ -The rest of the segment is made up of a sequence of instructions to key and -value mappings, taking the following format: +The rest of the segment is made up of a sequence of bytecode offset to key and +value mappings. First comes the number of them that follow: + + +--------+--------+--------------------------------------------------------+ + | Offset | Length | Description | + +--------+--------+--------------------------------------------------------+ + | 1 | 1 | Number of bytecode to keypair mappings that follow. | + | | | n | + +--------+--------+--------------------------------------------------------+ + +Then there are n entries of the following format: +--------+--------+--------------------------------------------------------+ | Offset | Length | Description | Modified: trunk/docs/pdds/pdd19_pir.pod ============================================================================== --- trunk/docs/pdds/pdd19_pir.pod (original) +++ trunk/docs/pdds/pdd19_pir.pod Tue Jan 6 21:35:06 2009 @@ -359,14 +359,14 @@ the PIR code is generated from some source PIR files, and error messages should print the source file's name, not the name of the generated file. -=item .annotate <key> <value> +=item .annotate <key>, <value> Makes an entry in the bytecode annotations table. This is used to store high level language debug information. Examples: - .annotate "file" "aardvark.p6" - .annotate "line" 5 - .annotate "column" 24 + .annotate "file", "aardvark.p6" + .annotate "line", 5 + .annotate "column", 24 An annotation stays in effect until the next annotation with the same key or the end of the current compilation unit (that is, if you use a tool such as @@ -377,13 +377,13 @@ line of HLL code is 15 lines of PIR, you only need to emit one annotation before the first of those 15 lines to set the line number. - .annotate "line" 42 + .annotate "line", 42 The key must always be a quoted string. The value may be an integer, a number or a quoted string. Note that integer values are stored most compactly; should you instead of the above annotate directive emit: - .annotate "line" "42" + .annotate "line", "42" Then you're asking for a bigger bytecode file as a result.