Ticket #436: pdd13fixes-1.patch

File pdd13fixes-1.patch, 7.3 KB (added by NotFound, 6 years ago)

First attempt at pdd13 fix

  • docs/pdds/pdd13_bytecode.pod

     
    184184  |        |        |    n = u % 16 ? 16 - (u % 16) : 0                      | 
    185185  +--------+--------+--------------------------------------------------------+ 
    186186 
    187 Everything beyond the header is an opcode, with word length and byte ordering 
    188 as defined in the header. If the word length and byte ordering of the machine 
    189 that is reading the PBC file do not match these, it needs to transform the 
    190 words making up the rest of the packfile. 
     187Everything beyond the header, except the directory segment, is an opcode, 
     188with word length and byte ordering as defined in the header. 
     189If the word length and byte ordering of the machine that is reading the PBC file 
     190do not match these, it needs to transform the words making up the rest of the 
     191packfile. 
    191192 
    192193=over 4 
    193194 
     
    279280  | 0      | 1      | The total size of the segment in opcodes, including    | 
    280281  |        |        | this header.                                           | 
    281282  +--------+--------+--------------------------------------------------------+ 
     283  | 1      | 1      | Internal type of the segment                           | 
     284  +--------+--------+--------------------------------------------------------+ 
     285  | 2      | 1      | Internal id                                            | 
     286  +--------+--------+--------------------------------------------------------+ 
     287  | 3      | 1      | Size of the following op array, 0 if none              | 
     288  +--------+--------+--------------------------------------------------------+ 
    282289 
    283290 
    284291=head4 Segment Padding 
     
    352359=head4 Bytecode Segment 
    353360 
    354361This segment has no additional headers. It stores a stream of instructions in 
    355 bytecode format. Instructions have variable length. Each instruction starts 
    356 with an operation code (opcode). 
     362bytecode format, with the length given in the last field of the segment header. 
    357363 
     364Instructions have variable length. Each instruction starts with an operation 
     365code (opcode). 
     366 
    358367  +--------+--------+--------------------------------------------------------+ 
    359368  | Offset | Length | Description                                            | 
    360369  +--------+--------+--------------------------------------------------------+ 
     
    393402 
    394403=head4 Constants Segment 
    395404 
    396 This segment stores number, string and PMC constants. It adds one extra field 
    397 to its header. 
     405This segment stores number, string and PMC constants. 
    398406 
     407The first element is the number of constants contained. 
     408 
    399409  +--------+--------+--------------------------------------------------------+ 
    400410  | Offset | Length | Description                                            | 
    401411  +--------+--------+--------------------------------------------------------+ 
     
    496506 
    497507=head4 Fixup Segment 
    498508 
    499 The fixup segment maps names of subs to offsets in the bytecode stream. It 
    500 adds one extra field to its header. 
     509The fixup segment maps names of subs to offsets in the bytecode stream. 
    501510 
     511The number of fixup table entries, n, is given by the last field of the 
     512segment header. 
     513 
    502514{{ TODO: I think label fixups are no longer used. Check if that is so. }} 
    503515 
    504   +--------+--------+--------------------------------------------------------+ 
    505   | Offset | Length | Description                                            | 
    506   +--------+--------+--------------------------------------------------------+ 
    507   | 1      | 1      | Number of fixup table entries that follow.             | 
    508   |        |        |    n                                                   | 
    509   +--------+--------+--------------------------------------------------------+ 
    510  
    511516This is followed by n fixup table entries, of variable length, that take the 
    512517following form. 
    513518 
     
    515520  | Offset | Length | Description                                            | 
    516521  +--------+--------+--------------------------------------------------------+ 
    517522  | 0      | 1      | Type of the fixup. Must be:                            | 
    518   |        |        |    0x01 - Subroutine fixup                             | 
     523  |        |        |    0x01 - Subroutine fixup constant string             | 
     524  |        |        |    0x02 - Subroutine fixup ascii string                | 
    519525  +--------+--------+--------------------------------------------------------+ 
    520   | 1      | 1      | The label that is being fixed up. A string constant,   | 
    521   |        |        | stored as an index into the constants table.           | 
     526  | 1      | -      | The label that is being fixed up. A string constant,   | 
     527  |        |        | stored as an index into the constants table in the 01  | 
     528  |        |        | case, a NULL terminated ASCII string padded to word    | 
     529  |        |        | length with zeroes in the 02.                          | 
    522530  +--------+--------+--------------------------------------------------------+ 
    523   | 2      | 1      | For subroutine fixups, this is an index into the       | 
    524   |        |        | constants table for the sub PMC corresponding to the   | 
    525   |        |        | label.                                                 | 
     531  | -      | 1      | This is an index into the constants table for the sub  | 
     532  |        |        |  PMC corresponding to the label.                       | 
    526533  +--------+--------+--------------------------------------------------------+ 
    527534 
    528535 
     
    533540 
    534541=over 4 
    535542 
     543=item A list of mappings between instructions in the bytecode and line 
     544numbers, with one entry per instruction 
     545 
    536546=item A list of mappings between offsets in the bytecode and filenames, 
    537547indicating that the bytecode from that point on until the next entry was 
    538548generated from the PIR found in the given filename 
    539549 
    540 =item A list of mappings between instructions in the bytecode and line 
    541 numbers, with one entry per instruction 
    542  
    543550=back 
    544551 
    545 The segment starts with: 
     552The length of the table of line numbers mapping is given by the last field 
     553of the segment header. 
    546554 
     555Then come the table: 
     556 
    547557  +--------+--------+--------------------------------------------------------+ 
    548558  | Offset | Length | Description                                            | 
    549559  +--------+--------+--------------------------------------------------------+ 
    550   | 1      | 1      | Number of filename mappings that follow.               | 
    551   |        |        |    n                                                   | 
     560  | 0      | 1      | Line number for the offset in the bytecode.            | 
    552561  +--------+--------+--------------------------------------------------------+ 
    553562 
     563Then come an opcode with n, the number of file mappings. 
     564 
    554565Then come n mappings. 
    555566 
    556567  +--------+--------+--------------------------------------------------------+ 
     
    562573  |        |        | index into the constants table.                        | 
    563574  +--------+--------+--------------------------------------------------------+ 
    564575 
    565 This is followed by the line number for each instruction in the bytecode 
    566 segment. 
    567576 
    568  
    569577=head4 Annotations Segment 
    570578 
    571579Annotations allow any instruction in the bytecode stream to have zero or more 
     
    591599 
    592600=back 
    593601 
     602The last field of the segment header is not used. 
     603 
    594604The first word in the segment supplies the number of keys. 
    595605 
    596606  +--------+--------+--------------------------------------------------------+