[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: byte code format



Quoting "Trevor Clarke":
> Could someone point me to some information about the format of the
> byte code in a .zo?

There is none (other than the source, as you point out).

A .zo file is essentially a compacted S-expression. The details are
complex, including a hash table for symbols (i.e., the first instance
of a symbol is encoded as a index--symbol pair, and later instances
just use the index), a vector-like representaton for lists, index-based
references to primitives, and various S-expression encodings of
primitive syntactic forms. Furthermore, the details change fairly
often, either because the primitive indices shift when a new primitive
is added, because I notice a new trick to make bytecode files more
compact, or because a new kind of literal is added. As an example of
the last reason, the v200 format is greatly complicated by the presence
of syntax objects.

The S-expression encoded in a .zo file, in turn, is an encoding of a
(fairly small) set of records representing the actual bytecodes that
MzScheme executes. Those records do not change very often, though they
can be somewhat complex (e.g., the record representing a module
declaration) and they are very much tune d to the evaluator's
achitecture.

So, unfortunately, the .zo format is not remotely friendly as a medium
for getting MzScheme version XYZ code to anywhere other than MzScheme
version XYZ.

Matthew