Previous Section Next Section Table of Contents Glossary Index

Chapter 17. Implementation Details of Clozure CL

17.6. Fasl files

Saving and loading of Fasl files is implemented in xdump/faslenv.lisp, level-0/nfasload.lisp, and lib/nfcomp.lisp. The information here is only an overview, which might help when reading the source.

The Clozure CL Fasl format is forked from the old MCL Fasl format; there are a few differences, but they are minor. The name "nfasload" comes from the fact that this is the so-called "new" Fasl system, which was true in 1986 or so.

A Fasl file begins with a "file header", which contains version information and a count of the following "blocks". There's typically only one "block" per Fasl file. The blocks are part of a mechanism for combining multiple logical files into a single physical file, in order to simplify the distribution of precompiled programs.

Each block begins with a header for itself, which just describes the size of the data that follows.

The data in each block is treated as a simple stream of bytes, which define a bytecode program. The actual bytecodes, "fasl operators", are defined in xdump/faslenv.lisp. The descriptions in the source file are terse, but, according to Gary, "probably accurate".

Some of the operators are used to create a per-block "object table", which is a vector used to keep track of previously-loaded objects and simplify references to them. When the table is created, an index associated with it is set to zero; this is analogous to an array fill-pointer, and allows the table to be treated like a stack.

The low seven bits of each bytecode are used to specify the fasl operator; currently, about fifty operators are defined. The high byte, when set, indicates that the result of the operation should be pushed onto the object table.

Most bytecodes are followed by operands; the operand data is byte-aligned. How many operands there are, and their type, depend on the bytecode. Operands can be indices into the object table, immediate values, or some combination of these.

An exception is the bytecode #xFF, which has the symbolic name ccl::$faslend; it is used to mark the end of the block.


Previous Section Next Section Table of Contents Glossary Index