.c	Friday  Jan 28,1983  00:05  FQ+6D.19H.54M.35S.  -*- Bolio -*-

.chapter "Hacking the Kernel"

where things are, what does what, ...

All pathnames are on NIL$DISK, whether that is stated or not.

.section "The CLINK and SLINK"

In lan{nil}, the register 3r11* (known to lan{nil} as
3slp*) is used as an index into three tables which are allocated
contiguously, but are relocatable for expansion or contraction.  One
such table is the term_i{clink}.  This contains things at fixed
offsets (known by the compiler), which are useful, used for data
sharing, or keeping code compact.  For instance, it contains a table
of type-bit masks, which are referenced by the compiler for various
open-compilations (rather than inline coding the bits directly, which
might require longword literal operands).  It also contains the
addresses of the term_i{minisubr}s used to implement efficient
subroutine calls from compiled code.

The term_i{slink} comes right after the clink, at least in the
initial environment.  It holds the value cells of lan{nil} symbols.
Each "value cell" is implemented as an index into this table.  For
each, there is one entry for the current value cell, and the
immediately following entry is the "canonical" value cell (...).
Growing in parallel to the slink is the term_i{blintz}.  This is the
slot used by the lan{nil} interpreter to record the contour level at
which a variable is bound by the interpreter (as described in
ref{NILBind}, and on (nil-binding-internals)).  The second entry
in the blintz for each value cell is a back-pointer to the symbol;
this is what allows code of various sorts to invert an term_i{slink
index} into the symbol it is a value-cell pointer for.

The file 7[NIL.VMLISP]SYMBOLS.LSP* contains a lan{lisp}-format
database which is used to construct the initial symbols used by the
lan{nil} kernel.
.defun si:make-initial-symbols
This function, which must be loaded from 7[NIL.VM]MAKECLINK.VAS*,
reads in the 7SYMBOLS* file and produces three lan{macro32}
output files:  7[NIL.VM]SYMCELL.MAX*, 7[NIL.VM]SLINK.MAX*, and
7[NIL.VM]BLINTZ.MAX*.  This is what must be done to add a new
symbol to the lan{nil} kernel.  (Those three files may all be
assembled by running the command file 7[NIL.VM]NEWSYMC.COM*.)
.end_defun
The format of the 7SYMBOLS* file is described at the front of the
source file 7MAKECLINK*.

.defun si:make-clink
This processes the fixed-offset portion of the clink.  It reads the
file 7[NIL.VMLISP]CLINK.LSP, and writes both a lan{macro32} file
7[NIL.VM]CLINK.MAX* and a lan{lisp}-format database for the
compiler, into 7[NIL.H]SLPASS.DAT*.  The former must obviously be
assembled.  The latter is read during the lan{lisp} compilation of
the file 7[NIL.H]VASSLP.LSP* (it does not become active
otherwise).  Note that these offsets are then "wired" into code by the
compiler, so they must not be changed blithely.
.end_defun

Note that if the size of the clink is increased, one must necessarily 
