help-smalltalk
[Top][All Lists]
Advanced

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

[Help-smalltalk] Re: GST bootstrapping process


From: Paolo Bonzini
Subject: [Help-smalltalk] Re: GST bootstrapping process
Date: Sat, 24 Feb 2007 16:55:10 +0100
User-agent: Thunderbird 1.5.0.9 (Macintosh/20061207)

Can you give me a little overview and/or
point me to the source code?

The source code is dict.c and lib.c. Here is a short LaTeX document that describes it (you can of course read it from here).

Paolo




\documentclass{article}
\usepackage{hyperref}
\begin{document}

\newcommand{\code}[1]{%
  \texorpdfstring{%
     {\texttt{\hyphenchar\font=`-%
       \begingroup\protect\frenchspacing#1\endgroup}}}{%
     #1}}

Unlike most other image-based Smalltalk systems, GNU Smalltalk is
able to create an image from scratch, only starting from the
definitions of the base classes and the source code to them (that is,
the definitions are not expressed as Smalltalk source code, but
separately).  Other systems, instead, always create an image from a
pre-existing one, possibly stripping out unneeded components.

The bootstrapping process is complex due to the necessity of
recreating the parallel hierarchy of classes and metaclasses, and then
merging them together.

First of all, the system creates the builtin objects (nil, true, false
and the 256 instances of \code{Character}).  The pointer to their
class is not known yet, but the system can store pointers to them even
if they are still in an embryonal state: it is easier to plug the 259
pointers to the classes \code{UndefinedObject}, \code{True},
\code{False} and \code{Character}, than to put back all the pointers
to \code{nil} where they are needed.

As mentioned, the virtual machine code contains the description on the
core classes\footnote{It would be possible to load them from an
  external source, with a parser for a subset of Smalltalk or from an
  XML description.}.  The hierarchy tree is visited breadth-first,
creating classes and metaclasses along the way.  A few fields are
initialized in class objects: the superclass field, the pointer to the
metaclass, and the \code{instanceSpec}. This is enough for the system to
create their instances.

Now, builtin objects are given a class and other objects can be
created: these include namespaces, and some \code{VariableBinding}
objects through which the virtual machine can pass some information
about the system to the Smalltalk code\footnote{Such as the underlying
operating system, or \code{sizeof(void *)}.}.  C code manipulates
namespaces and fills them with \code{VariableBinding} objects for the
classes.

The remaining fields of class and metaclass objects are filled in,
including linking metaclasses back to their sole instance, making
Metaclass the class of metaclasses and making Class the superclass of
`Object class'.

In order to compile the source code for the core classes, GNU
Smalltalk includes a compiler written in C.  This compiler is invoked
once manually to compile the \code{methodsFor:} primitive, and then to
file in the sources for the kernel. As more and more classes are loaded,
the system takes shape: later on, it will be complete enough to be able
to create new classes, and possibly to run another compiler which is
written in Smalltalk.  At this point, the system has bootstrapped.

\end{document}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]