[FIX] thisOop become: thisOop

Stephan Rudlof sr at evolgo.de
Sun Nov 25 23:50:33 UTC 2001


Leandro Caniglia wrote:
> 
> Stephan Rudlof wrote:
> >
> > "Change Set:            becomeFix
> > Date:                   22 November 2001
> > Author:                 Stephan Rudlof
> >
> > Avoids the following crash...:
> >         a _ 'a'.
> >         a become: a
> >
> > Most work is done in
> >         Array>>elementsExchangeIdentitySaveWith: otherArray
> > from its comment:
> >         'This method calls #elementsExchangeIdentityWith: after a check
> >         ensuring that no pointers occure more than once, which can lead to a
> >         crash (don't know, if it always does).'
> 
> Thank you Stephan.
> 
> But don't you think that a VM fix would be better (for
> performance)?

No.

1.
I haven't seen any penalties by #macroBenchmarks.

2.
Methods
	Array>>elementsExchangeIdentityWith: otherArray (used by the original
>>become:)
	Array>>elementsExchangeIdentitySaveWith: otherArray (used by the fixed
>>become:)
are using Arrays, so implementing the same functionality inside the VM isn't
trivial:
- simple version: to check for uniqueness each oop could be compared with
each other by two nested loops, which is very expensive for many oops;
- advanced: implementing Sets in C could give better performance, but needs
much implementation with nasty mem management at the wrong place IMHO;
- much less safe: just checking for exchanging an oop with itself.
In the last case you first have to understand
	ObjectMemory>>become: array1 with: array2 twoWay: twoWayFlag
and its submethods to know where to make the appropriate changes just to
have little more safety.

3.
Since >>elementsExchangeIdentityWith is used by many methods probably giving
it mostly more than one element Arrays as args, I first had decided to
provide the second save method for everybody who *wants* to make this safety
check and just to call it by >>become:, which only creates one element
Arrays.

But now I've made an improved CS (see [FIX] thisOop become: thisOop, version
2) with a simple shortcut of this check inside >>become:, which is now
calling the unsafe Array>>elementsExchangeIdentityWith: again. I have left
in the safe Array>>elementsExchangeIdentitySaveWith: for everybody's use.


Greetings and thanks,

Stephan

> 
> /Leandro

-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3




More information about the Squeak-dev mailing list