[squeak-dev] Re: The solution of (Was: Creating an image from first principles)

Igor Stasenko siguctua at gmail.com
Thu Aug 7 01:20:49 UTC 2008


2008/8/7 Andreas Raab <andreas.raab at gmx.de>:
> Igor Stasenko wrote:
>>
>> Okay, let me review the steps, how i seeing it with doing everything
>> in same interpreter without the need of simulation:
>>
>>> Read a series of class definitions (you can use either MC class defs or
>>> simply parse simple class definitions from sources) that are sufficient
>>> to
>>> define all of the kernel structures that are required by the running VM
>>> (incl. Object, Behavior, Class, Integer, Array, Process, CompiledMethod,
>>> ContextPart, Semaphore etc. etc. etc.).
>>
>> - use a ClassBuilder, or add single method to Behavior to be able to
>> create the abovementioned classes, but without installing/registering
>> them anywhere (SystemDictionary etc) and treat them as anonymous
>> classes.
>
> This doesn't work (try it sometime). It is impossible to create an empty
> metaclass hierarchy since you can't send any messages to it. Which is why
> you need a simulator to do it because the simulator can operate on the data
> structures without requiring any of the objects to understand any message.
> Most of the steps in your proposal have similar fundamental flaws (like
> creating "new" SmallInteger instances etc).
>

Oh, come on!
Not sure if it will work, but hey:

Behavior subclass: #BootsrappingBehavior .

Which having special 'intercepting'  #basicNew and #basicNew: method
with something like:

| newObject |
newObject := super basicNew.
newObject primitiveChangeClassTo: (Substitutions
findOrCreateSubstitutionOf: self).
NewHeap add: newObject.
^ newObject

and then:

ClassDescription superclass: BootstrappingBehavior.
Behavior flushCache.

".. now you can run arbitrary code, and all objects created during it
will eventually find themselves in NewHeap and already with proper
class set.

At the end, you reverting hack:
"

ClassDescription superclass: Behavior.
Behavior flushCache.


Another thing, that you can populate method dicts on the fly while code running:

[ newObject some code involving sending potentially unknown messages
to an object which class having empty method dict ] on:
MessageNotUnderstood do: [:ex |
    (NewHeap findAndCompileAndInstallMethodForMessage: ex message
receiver: ex receiver) ifTrue: [
      ex return: ex message value. ] ifFalse: [
    ex pass. ]
].


> FWIW, I've followed a similar set of ideas for a while back in 2002 and the
> end result was dead-ugly and impossible to bootstrap cleanly. Every step of
> your proposal is a mine field and the only recommendation I have is to try
> it sometime and you'll be *amazed* how difficult the process is that you are
> describing.
>

I like to be amazed and i like to be challenged :)

> Cheers,
>  - Andreas
>


-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list