Some notes about current PackFile status quo as of patch #8.

Short summary:
* Parrot can load a compiled bytecode file call a subroutine
  in there and return back again. s. imcc/t/syn/file.t (#6)

How it works:
* A subroutine using Parrot Calling Conventions (PCC) has an entry
  in the constant table, which is a constant Sub PMC.
  This PMC has Class, entry_label, start_offset and end_offset,
  currently a string like "Sub _sub2 0 32"[1].
  A PCC sub has a fixup (aka symbol) table entry of type
  "enum_type_sub" with the offset being the index in the constant
  table.
* And the Sub PMC gets stored in the global interpreter stash, the
  key is the subroutine entry label
* At PBC load time C<fixup_subs> walks the fixup table and replace
  relative offset with absolute addresses in the bytecode stream.
* The C<load_bytecode> opcode loads a PBC file into a new
  "struct PackFile". This gets appended to the current master
  directory.
* $P0 = global "_ext_sub" returns this constant subroutine object
  and allows invoking it[2]
* C<invoke> does a bytecode segment or a packfile switch, when this
  is needed.
* returning is just the same: C<invoke P1>.

Missing:
* cleanup: packfile probably needs a split
* the subroutine class can't be set yet with the ".pcc_sub" directive,
  "Sub" is hardwired for now.
* let F<pdump> spit out PFC_PMC constants (and keys)
* JIT and/or prederef the code (the sub) at load time (call time)
  meaning: this stuff doesn't work yet with -j, -P, -S
* load .pasm, .imc too
* probably a lot more

[1] when we have some serializing API, we can replace that stuff.
[2] I don't know yet, if we always can reuse this constant PMC for
    calling the sub from different locations.

Have fun,
leo



Reply via email to