Slate's bootstrap process (was Re: [squeak-dev] Re: The solution of)

Tony Garnock-Jones tonyg at lshift.net
Wed Aug 13 08:14:00 UTC 2008


Hi Stef,

I hope the following is of interest to you and other readers :-)

stephane ducasse wrote:
> what is Image?

Defined in src/lib/image.slate. Now, it's been a long time since I read 
much slate, so please forgive any mistakes I make in reading the code.

Image is a singleton that is the chosen place to hang methods and non-VM 
state related to the current, running image: for instance, command-line 
options (??) and startup and shutdown actions.

So it has a role in everyday operation of a slate system.

It *also* has a special, but coincidental, role when bootstrapping a new 
image from sources, in bootstrap.slate. However, the bootstrap.slate 
code could have been hung anywhere: Image was simply convenient and 
mnemonic. If you look at bootstrap.slate, notice how "Image" is never 
(other than in the first line) used alone: it's always used as "Image 
Bootstrap".

Now, Image Bootstrap contains tools for modelling an image. The tools 
are completely VM-independent. For example, "Image Bootstrap 
BytesPerWord" describes the model's notion of how many bytes there are 
in a machine word, that may be different to the number of bytes per word 
used by the VM that is running the image-building code.

Within the Image Bootstrap namespace exist

  - Chunk
  - SlotEntry
  - RoleEntry
  - MethodDefinition
  - Map
  - Object
  - Array
  - OopArray
  - ByteArray
  - CompiledMethod

and Generator. All of the above (except Generator) despite confusingly 
having the same names as classes/objects in the image-building, running, 
system, are completely distinct -- they could perhaps less confusingly 
be called "ObjectModel", "ArrayModel" etc, since they *describe* objects 
and arrays, without *being* objects and arrays in the running VM instance.

Generator's method "generateImageBooting:withPrims:" is what kick-starts 
the whole image-building process.

   gen generateKernel.
   gen generateUtilities.
   gen generateKernelAccessors.
   gen generateInterpreterBooting: method.
   gen generateLobby.
   prims do: [| :assoc |
     gen generatePrimitive: assoc value at: assoc key].
   gen generateMaps.
   gen generateLinkage.

Each step constructs (in an abstract way) and encodes (concretely, for 
the a particular model of a VM) models of objects in the model of the 
image being built.

Perhaps most interesting is the generateKernel method, which creates the 
models of the objects that form the "primeval soup", such as Root, 
Boolean, Array, SmallInteger, Symbol, Method etc.

Once the kernel objects are constructed, the system can go on to put the 
rest of the system together. It uses a model of the VM that the image is 
intended for to compile the methods that go into the image (although I'm 
not clear on the exact mechanism in play here).

Tony




More information about the Squeak-dev mailing list