On Wed, Nov 23, 2011 at 2:25 PM, Stefan Marr <ph...@stefan-marr.de> wrote:

> Hi:
>
> On 23 Nov 2011, at 22:59, Stéphane Ducasse wrote:
> > imagine that I want to bootstrap our nice kernel.
> > I will need to somehow create a new nil, true, false, instances of new
> classes Undefined, True, False.
> > Such instances will then be put on the SpecialObjectArray somehow.
>
> Something kind of related:
>
> When debugging the VM, I am happy that I always encounter the same object
> as the first object in the heap. It is some strange string (think it
> encodes an error message or so).
>
> However, my thought was, also for other purposes, would it be possible to
> have these special objects sorted to the beginning? Especially, the nilObj
> would be very handy to have as the first object.
>

Note that Cog assumes that false and true are next to each other.  You'll
find in all Pharo/Squeak images that the first three objects are nil,
false, true in that order.  Assuming they're contiguous allows the JIT to
generate more compact conditional branch code since true = false + 8, and
so it only has to load one 32-bit constant and can derive the other by
adding a small constant.


> That would need special VM support to arrange it that way, but knowing the
> nilObj from the very beginning would allow my to initialize some of my
> hacks more consistently, avoiding C-level NULLs and runtime checks.
>

It's safe to assume nil comes first.  One can imagine experimental contexts
where one would want to become nil but the current VMs will very likely
crash without some work.  But why waste cycles on every run when it is so
unlilkely anyone will try this?


> Just an idea, vaguely related to the question.
>
> Would be interesting to hear whether there are any historical insights
> with regard to ordering objects in the image.
> Guess it is not done because nobody needed it. (and then there isn't
> really a primitive for it, and a moving GC might also be contra-productive,
> etc.)
>
> Best regards
> Stefan
>
>
>
> >
> > Stef
>
> --
> Stefan Marr
> Software Languages Lab
> Vrije Universiteit Brussel
> Pleinlaan 2 / B-1050 Brussels / Belgium
> http://soft.vub.ac.be/~smarr
> Phone: +32 2 629 2974
> Fax:   +32 2 629 3525
>
>
>


-- 
best,
Eliot

Reply via email to