File consists sections:
  Header
  Roots
  Stack
  Heap
  Context


Header:
  CHAR[4] MAGIC     "PMAT"
  U8      FLAGS     0x01 : big-endian
                    0x02 : INT/UV/IV are 64-bit
                    0x04 : PTR is 64-bit
                    0x08 : NV is long double
                    0x10 : ithreads
  U8      zero
  U8      FORMATVER_MAJOR 0
  U8      FORMATVER_MINOR 6
  U32     PERLVER   rev<<24 | ver<<16 | sub

  U8      NTYPES
  {U8     HEADERLEN
   U8     NPTRS
   U8     NSTRS}*$NTYPES
            -- type=0 is common, then actual SV types

  U8      NEXTNS
  {U8     HEADERLEN
   U8     NPTRS
   U8     NSTRS}*$NEXTNS

  U8      NCONTEXTS
  {U8     HEADERLEN
   U8     NPTRS
   U8     NSTRS}*$NTYPES
            -- type=0 is common, then actual Context types

Roots:
  PTR     UNDEF         the "undef" immortal
  PTR     YES           the "yes" immortal
  PTR     NO            the "no" immortal

  U32     NROOTS=$n
  {STR    ROOTNAME
   PTR    ROOT} * $n

          main_cv         = the main code
          defstash        = the default stash
          mainstack       = the main stack AV
          beginav         = the BEGIN list
          checkav         = the CHECK list
          unitcheckav     = the UNITCHECK list
          initav          = the INIT list
          endav           = the END list
          strtab          = the shared string table HV
          envgv           = the ENV GV
          incgv           = the INC GV
          statgv          = the stat GV
          statname        = the statname SV
          tmpsv           = the temporary SV
          defgv           = the default GV
          argvgv          = the ARGV GV
          argoutgv        = the argvout GV
          argvout_stack   = the argout stack AV
          fdpidav         = the FD-to-PID mapping AV
          preambleav      = the compiler preamble AV
          modglobalhv     = the module data globals HV
          regex_padav     = the REGEXP pad AV
          sortstash       = the sort stash
          firstgv         = the *a GV
          secondgv        = the *b GV
          debstash        = the debugger stash
          stashcache      = the stash cache
          isarev          = the reverse map of @ISA dependencies
          registered_mros = the registered MROs HV
          rs              = the IRS
          last_in_gv      = the last input GV
          ofsgv           = the OFS GV
          defoutgv        = the default output GV
          hintgv          = the hints (%^H) GV
          patchlevel      = the patch level
          apiversion      = the API version
          e_script        = the '-e' script
          mess_sv         = the message SV
          ors_sv          = the ORS SV
          encoding        = the encoding
          blockhooks      = the block hooks
          custom_ops      = the custom ops HV
          custom_op_names = the custom op names HV
          custom_op_descs = the custom op descriptions HV

          # Plus miscellaneous other internal UTF-8 / text encoding support SVs

Stack:
  UINT    SIZE = $n
  {PTR    ELEM}*$n

Heap:
  type==0-terminated list of SVs


An SV:
  U8      TYPE       (0xff == UNKNOWN)
  Header(4+P+I):
    PTR     ADDRESS
    U32     REFCNT
    UINT    SIZE
  PTRs(1):
            BLESSED
  STRs(0)

  type: SCALAR:
    Header(1+2I+N):
      U8      FLAGS  0x01 : has IV
                     0x02 : IV is UV
                     0x04 : has NV
                     0x08 : has STR
                     0x10 : STR is UTF8
      UINT    IV
      double  NV
      UINT    PVLEN
    PTRs(1):
              OURSTASH
    STRs(1):
              PV

  type: REF:
    Header(1):
      U8      FLAGS  0x01 : RV is weak
    PTRs(2):
              RV
              OURSTASH

  type: GLOB
    Header(I+P):
      UINT    LINE
      PTR     NAME_HEK
    PTRs(8):
              STASH
              SCALAR
              ARRAY
              HASH
              CODE
              EGV
              IO
              FORM
    STRs(2):
              NAME
              FILE

  type: ARRAY
    Header(1+I):
      UINT    COUNT = $n
      U8      FLAGS  0x01 : AV is not REAL
    PTRs(0)
    STRs(0)
    Body:
      {PTR    ELEM}*$n

  type: HASH
    Header(I):
      UINT    COUNT = $n
    PTRs(1):
              BACKREFS
    Body:
      {STR    KEY
       PTR    HEK
       PTR    VALUE}*$n

  type: STASH
    [extends fields of a hash]
    PTRs(4):
              MRO_LINEAR_ALL
              MRO_LINEAR_CURRENT
              MRO_NEXTMETHOD
              MRO_ISA
    STRs(1):
              NAME

  type: CODE
    Header(1+I+2P):
      UINT    LINE
      U8      FLAGS  0x01 : CLONE
                     0x02 : CLONED
                     0x04 : XSUB
                     0x08 : WEAKOUTSIDE
                     0x10 : CVGV_RC
                     0x20 : LEXICAL
      PTR     OPROOT
      U32     DEPTH
      PTR     NAME_HEK
    PTRs(5):
              STASH
              GLOB
              OUTSIDE
              PADLIST
              CONSTVAL
    STRs(2):
              FILE
              NAME
    Body:
      {U8     TYPE
       ...         }    until TYPE==0

     type: CONSTSV
       PTR  SV

     type: CONSTIX
       UINT PADIX

     type: GVSV
       PTR  SV

     type: GVIX
       UINT PADIX

     type: PADNAMES
       PTR  PADNAMES

     type: PAD
       UINT DEPTH
       PTR  PAD

     type: PADNAME
       UINT PADIX
       STR  PADNAME
       PTR  OURSTASH

     type: PADNAME_FLAGS
       UINT PADIX
       U8   FLAGS  0x01 : OUTER
                   0x02 : STATE
                   0x04 : LVALUE
                   0x08 : TYPED
                   0x10 : OUR

      type: PADNAME_FIELD
        UINT PADIX
        UINT FIELDIX
        PTR  FIELDSTASH

  type: IO
    Header(2I):
      UINT    IFILENO
      UINT    OFILENO
    PTRs(3):
              TOP
              FORMAT
              BOTTOM

  type: LVALUE
    Header(1 + 2I):
      U8      TYPE
      UINT    OFF
      UINT    LEN
    PTRs(1):
              TARG

  type: REGEXP

  type: FORMAT

  type: UNDEF

  type: YES

  type: NO

  type: OBJ
    Header(1+I):
      UINT    COUNT = $n
    PTRs(0)
    STRs(0)
    Body:
      {PTR    FIELD}*$n

  type: CLASS
    [extends fields of a stash]
    PTRs(1)
            ADJUST_BLOCKS

  type: STRUCT
    Header(0):
    FIELD(n): -- given by META

SV extensions:
  PTR   SV

  type: MAGIC (0x80)
    Header(2):
      U8    TYPE
      U8    FLAGS  0x01 : MGf_REFCOUNTED
    PTRs(3):
            MG_OBJ
            MG_PTR
            MG_VTBL

  type: SAVED_SV (0x81)
    Header(0)
    PTRs(1):
            SV

  type: SAVED_AV (0x82)
    Header(0)
    PTRs(1):
            AV

  type: SAVED_HV (0x83)
    Header(0)
    PTRs(1):
            HV

  type: SAVED_AELEM (0x84)
    Header(I):
      UINT  INDEX
    PTRs(1):
            SV

  type: SAVED_HELEM (0x85)
    Header(0)
    PTRs(2):
            KEY
            SV

  type: SAVED_CV (0x86)
    Header(0)
    PTRs(1):
            CV

  type: SVSV note (0x87)
    Header(0)
    PTRs(1):
            SV
    STRs(1):
            NAME

  type: DEBUGREPORT (DEBUG_LEAKING_SCALARS) (0x88)
    Header(2I):
      UINT  SERIAL
      UINT  LINE
    STRs(1):
            FILE

  type: PV_SHARED_HEK (0x89)
    Header(P):
      PTR   HEK

  type: META_STRUCT (0xF0)
    Header(2I):
      UINT  STRUCTID
      UINT  NFIELDS
    STRs(1)
            NAME
    Body:
      {STR  FIELDNAME
       U8   TYPE
              0x00 : Pointer (PTR)
              0x01 : Boolean (U8)
              0x02 : Number (U8)
              0x03 : Number (U32)
              0x04 : Number (UINT)
       }*$n

Context:
  type==0-terminated list of CTXs

  CTX:
    U8    TYPE
    U8    GIMME
    UINT  LINE
    STR   FILE

  type: SUB
    U32   OLDDEPTH
    PTR   CV
    PTR   ARGS

  type: TRY

  type: EVAL
    PTR   CODESV

Mortals:
  UINT    COUNT = $n
  {PTR    ELEM}*$n
  UINT    FLOOR
