[svn:parrot] r37524 - trunk/docs/pdds

NotFound at svn.parrot.org NotFound at svn.parrot.org
Tue Mar 17 17:09:55 UTC 2009


Author: NotFound
Date: Tue Mar 17 17:09:52 2009
New Revision: 37524
URL: https://trac.parrot.org/parrot/changeset/37524

Log:
[docs] Document current practice in pdd13, TT #436

Modified:
   trunk/docs/pdds/pdd13_bytecode.pod

Modified: trunk/docs/pdds/pdd13_bytecode.pod
==============================================================================
--- trunk/docs/pdds/pdd13_bytecode.pod	Tue Mar 17 17:06:13 2009	(r37523)
+++ trunk/docs/pdds/pdd13_bytecode.pod	Tue Mar 17 17:09:52 2009	(r37524)
@@ -184,10 +184,11 @@
   |        |        |    n = u % 16 ? 16 - (u % 16) : 0                      |
   +--------+--------+--------------------------------------------------------+
 
-Everything beyond the header is an opcode, with word length and byte ordering
-as defined in the header. If the word length and byte ordering of the machine
-that is reading the PBC file do not match these, it needs to transform the
-words making up the rest of the packfile.
+Everything beyond the header is an opcode, with word length and byte ordering as
+defined in the header.
+If the word length and byte ordering of the machine that is reading the PBC file
+do not match these, it needs to transform the words making up the rest of the
+packfile.
 
 =over 4
 
@@ -279,6 +280,12 @@
   | 0      | 1      | The total size of the segment in opcodes, including    |
   |        |        | this header.                                           |
   +--------+--------+--------------------------------------------------------+
+  | 1      | 1      | Internal type of the segment                           |
+  +--------+--------+--------------------------------------------------------+
+  | 2      | 1      | Internal id                                            |
+  +--------+--------+--------------------------------------------------------+
+  | 3      | 1      | Size of the following op array, 0 if none              |
+  +--------+--------+--------------------------------------------------------+
 
 
 =head4 Segment Padding
@@ -352,8 +359,10 @@
 =head4 Bytecode Segment
 
 This segment has no additional headers. It stores a stream of instructions in
-bytecode format. Instructions have variable length. Each instruction starts
-with an operation code (opcode).
+bytecode format, with the length given in the last field of the segment header.
+
+Instructions have variable length. Each instruction starts with an operation
+code (opcode).
 
   +--------+--------+--------------------------------------------------------+
   | Offset | Length | Description                                            |
@@ -393,8 +402,9 @@
 
 =head4 Constants Segment
 
-This segment stores number, string and PMC constants. It adds one extra field
-to its header.
+This segment stores number, string and PMC constants.
+
+The first element is the number of constants contained.
 
   +--------+--------+--------------------------------------------------------+
   | Offset | Length | Description                                            |
@@ -450,6 +460,8 @@
   | 5      | n      | String data with trailing zero padding as required.    |
   +--------+--------+--------------------------------------------------------+
 
+Note: the Encoding field is not implemented yet.
+
 =item * PMC Constants
 
 PMCs that can be saved in packfiles as constants implement the freeze and thaw
@@ -496,17 +508,12 @@
 
 =head4 Fixup Segment
 
-The fixup segment maps names of subs to offsets in the bytecode stream. It
-adds one extra field to its header.
+The fixup segment maps names of subs to offsets in the bytecode stream.
 
-{{ TODO: I think label fixups are no longer used. Check if that is so. }}
+The number of fixup table entries, n, is given by the last field of the
+segment header.
 
-  +--------+--------+--------------------------------------------------------+
-  | Offset | Length | Description                                            |
-  +--------+--------+--------------------------------------------------------+
-  | 1      | 1      | Number of fixup table entries that follow.             |
-  |        |        |    n                                                   |
-  +--------+--------+--------------------------------------------------------+
+{{ TODO: I think label fixups are no longer used. Check if that is so. }}
 
 This is followed by n fixup table entries, of variable length, that take the
 following form.
@@ -515,14 +522,16 @@
   | Offset | Length | Description                                            |
   +--------+--------+--------------------------------------------------------+
   | 0      | 1      | Type of the fixup. Must be:                            |
-  |        |        |    0x01 - Subroutine fixup                             |
+  |        |        |    0x01 - Subroutine fixup constant string             |
+  |        |        |    0x02 - Subroutine fixup ascii string                |
   +--------+--------+--------------------------------------------------------+
-  | 1      | 1      | The label that is being fixed up. A string constant,   |
-  |        |        | stored as an index into the constants table.           |
+  | 1      | -      | The label that is being fixed up. A string constant,   |
+  |        |        | stored as an index into the constants table in the 01  |
+  |        |        | case, a NULL terminated ASCII string padded to word    |
+  |        |        | length with zeroes in the 02.                          |
   +--------+--------+--------------------------------------------------------+
-  | 2      | 1      | For subroutine fixups, this is an index into the       |
-  |        |        | constants table for the sub PMC corresponding to the   |
-  |        |        | label.                                                 |
+  | -      | 1      | This is an index into the constants table for the sub  |
+  |        |        |  PMC corresponding to the label.                       |
   +--------+--------+--------------------------------------------------------+
 
 
@@ -533,24 +542,28 @@
 
 =over 4
 
+=item A list of mappings between instructions in the bytecode and line
+numbers, with one entry per instruction
+
 =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:
+The length of the table of line numbers mapping is given by the last field
+of the segment header.
+
+Then come the table:
 
   +--------+--------+--------------------------------------------------------+
   | Offset | Length | Description                                            |
   +--------+--------+--------------------------------------------------------+
-  | 1      | 1      | Number of filename mappings that follow.               |
-  |        |        |    n                                                   |
+  | 0      | 1      | Line number for the offset in the bytecode.            |
   +--------+--------+--------------------------------------------------------+
 
+Then come an opcode with n, the number of file mappings.
+
 Then come n mappings.
 
   +--------+--------+--------------------------------------------------------+
@@ -562,9 +575,6 @@
   |        |        | index into the constants table.                        |
   +--------+--------+--------------------------------------------------------+
 
-This is followed by the line number for each instruction in the bytecode
-segment.
-
 
 =head4 Annotations Segment
 
@@ -591,6 +601,8 @@
 
 =back
 
+The last field of the segment header is not used.
+
 The first word in the segment supplies the number of keys.
 
   +--------+--------+--------------------------------------------------------+


More information about the parrot-commits mailing list