[Vm-dev] Works in SqueakVM but not Cog

Igor Stasenko siguctua at gmail.com
Mon Dec 13 19:52:52 UTC 2010

On 13 December 2010 20:21, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> On Mon, Dec 13, 2010 at 6:14 AM, Igor Stasenko <siguctua at gmail.com> wrote:
>> | newNil |
>> newNil := UndefinedObject basicNew.
>> nil becomeForward: newNil.
>> (Array new: 1) first == newNil
>> In Cog it just hangs VM (under Mac)
>> Any ideas how to fix that?
> I don't think it's worth fixing.  It is advantageous for the performance of the VM to be able to embed nil in machine code without needing to mark it as a GCable object, and nil doesn't really have to change.  Instead you can change the UndefinedObject class via a become.  So for me it's not worth fixing and in fact I would actively encourage expecting /not/ to be able to redefine nil, true or false.  For example in Cog better code is generated for conditional branches by assuming that true and false are contiguous (in current images 8 bytes apart).  IMO, there are flexibilities that are so unusual they are not worth paying for, and being able to become nil, true and false are in this category.

I agree its not worth changing.
So, the 'fix' is to replace the class, since nil is singleton anyways.

The problem i that we want to swap special objects array. And there
are two approaches:

1  - create a full object memory , which is a copy of existing objects
(but not everything, just selected pieces). This means that there will
be two 'nils' and therefore need a working #become: for swapping.

2  - mark a set of objects for inclusion in 'new' image, and throw
away the rest via stubbing. So, this approach avoids copying, but also
it doesn't allows to hold two object memories in object memory at same
time (host and baby one).

I advocating for a second approach. It is more simpler as to me, but
at same time, it is only one way road. While with first one,
potentially you could switch between two object memories at will ,
which opening interesting possibilities.

Btw, are there any other objects which can't freely use #become: due
to some Cog intrinsics?

> best
> Eliot

Best regards,
Igor Stasenko AKA sig.

More information about the Vm-dev mailing list