[Vm-dev] A possible Cog bug (was: Re: [squeak-dev] Direct
implementation of shift/reset in Smalltalk)
Levente Uzonyi
leves at elte.hu
Sun Apr 24 20:08:10 UTC 2011
On Thu, 21 Apr 2011, Frank Shearar wrote:
> I finished a preliminary version of the shift/reset control operator for
> creating and using partial continuations:
>
> http://www.squeaksource.com/Control.html
>
> It's pretty easy to use:
>
snip
> Comments welcome!
I thought it's a bit easier to use notifications instead of control
operators. Here's an example:
c := [ 3 + PartialContinuationNotification signal ]
on: PartialContinuationNotification
do: [ :not | not continuation ].
c value: 4. "==> 7"
So I implemented it and uploaded it to
http://leves.web.elte.hu/squeak/Control-ul.5.mcz . I also refactored the
code a bit. Even though some Pharo folks always wanted to be able to use
streams with OrderedCollection (which works in Squeak btw), it's kinda
pointless thing to use #streamContents: with them, because
OrderedCollections can grow by themselves, unlike Arrays or Strings.
The code works, the tests are green, etc.
But I wasn't happy with the results, because ContextPart already
implements #copyTo: (which I think can also be simplified by removing
BlockContext support), which can be used to serialize the stack. So I
wrote the code, but it didn't work for some reason. The execution always
ran into the error 'computation has been terminated' in MethodContext >>
#cannotReturn: and the method context (which stitches the continuation
onto the stack) was broken (nil in temporaries where should be non nil
values). Finally I tried it in SqueakVM instead of Cog and it worked. The
tests are green, the example code works, etc. The code with these changes
is available at http://leves.web.elte.hu/squeak/Control-ul.6.mcz . I
prepared an image to ease the debugging process, which is available at
http://leves.web.elte.hu/squeak/ContextBug.zip .
Levente
P.S.: Feel free to add an issue to the Cog tracker. :)
>
> frank
>
> [1]
> http://www.lshift.net/blog/2011/04/20/direct-implementation-of-shiftreset-in-smalltalk
>
>
More information about the Vm-dev
mailing list