[squeak-dev] Re: MicroSqueak
Andreas Raab
andreas.raab at gmx.de
Mon Mar 2 03:54:15 UTC 2009
Stephen Pair wrote:
> Hmm, I think the key question here is: what do you want to be able to do
> with the image you create? I've no idea how John did this, but I think
> I would start by writing a method that did all the things I'd want to be
> able to do in the image I ultimately create. This might be things like
> compiling a string of code, loading something from a file (or socket),
> etc...the bare minimum of things you'd absolutely need to do in a
> minimal image. Then I'd guess you could create a shadow M* class with
> this method in it and some sort of proxies for literals and global
> references. With a little doesNotUnderstand: magic I'd think you could
> run that method, hit those proxies and copy over other classes and
> methods as you hit them. I'm sure the devil is in the details, but this
> top level method that expresses exactly the things that you'd want to be
> able to do in this minimal image seems like it would be an interesting
> artifact in and of itself. It would be in a sense a specification of
> this image.
That is one way to do it. The alternative (which I used a couple of
years back) is to say: Everything in Kernel-* should make for a
self-contained kernel image. So I started by writing a script which
would copy all the classes and while doing so rename all references to
classes (regardless of whether defined in kernel or not).
At the end of the copying process you end up with a huge number of
Undeclared variables. This is your starting point. Go in and add, remove
or rewrite classes and methods so that they do not refer to entities
outside of your environment. This requires applying some judgement
calls, for example I had a category Kernel-Graphics which included
Color, Point, and Rectangle. Then I did another pass removing lots of
unused methods which I had determined to be unused.
At the end of the process I wrote a script that (via some arcane means)
did a self-transformation of the image I was running and magically
dropped from 30MB to 400k in size. Then I had a hard disk crash and most
of the means that I've been using in this work were lost :-(((
I still have the resulting image but there is really no realistic way of
recovering the process. Which is why I would argue that the better way
to go is to write an image compiler that takes packages and compiles
them into a new object memory. That way you are concentrating on the
process rather than on the artifact (in my experience all the shrinking
processes end up with nonrepeatable one-offs)
Cheers,
- Andreas
More information about the Squeak-dev
mailing list
|