rune
rune copied to clipboard
feature: a bytecode format for units
Units have been designed so that they can be serialized. This can be used in the future cache a compilation or distribute units in bytecode format for later execution.
This task is to design a preliminary format which will probably be subject to change before becoming stable.
A unit contains:
- A sequence of instructions, starting at
0x0
. - A hash-to-function map.
- A hash-to-type information map, which answers the question "what is this type hash?".
- Zero-based collection of static strings, byte arrays, and object keys.
To allow for checking that a context is compatible to execute a unit, the format should also include:
- The hashes of all functions used.
- The hashes of all types used.
- Optional debug information that can be shed to reduce size.
Since 216daa3125838204531c9c95c2af8308ab2677df Unit
now implements Serialize
and Deserialize
. And there's a prototype implementation in rune_cli which uses bincode to cache the compilation unit.
we could also emit a .rnu.map
a file that contains a map of the functions, locations that could be used for debugging .. I would prefer that to be a separate file instead of been embedded into the .rnu
that would be similar to typescript source maps