Safe Return

Paul McDonough paulm at 4thEstate.com
Mon Jan 17 01:36:34 UTC 2000


Muchos gracias to Stephen for providing us an escape from the foul
clutches of #valueUninterruptably!  That method was in there originally
as a neat trick (picked up from Craig L) to avoid having to make vm
changes to implement ensured execution.  As Stephen and Rob have shown,
however, the bloody thing is pretty broken and (imo) should be quietly
buried out back with a stake through its heart.

Asap, I'll see if I can get it recompiled for a Mac - might be a few
days, as I need to go out and buy some C tools first.

Conceptually, Stephen's approach sounds right to me, and that leads to a
suggestion:  since the EHS is in "core Squeak" now, might SqC be
inclined to take Stephen's vm changes (after suitable vetting of course)
into the main stream quickly?  If that were done, a nontrivial portion
of the EHS code could evaporate shortly thereafter, many
as-yet-undiscovered bugs would go away, and with a bit of luck we might
get it all nice and solid well before 2.8 release.  Exception handling
is basic enough that it needs to be 100% bug free, and I doubt it can
get there without Stephen's (or equivalent) vm changes - if I correctly
understand what he's done.

Standard disclaimer:  all of the above opinion from me, not TFEI,
although I'm pretty sure TFEI agrees in this case.

Paul

Robert Withers wrote:
> 
> Hi,
> 
> I installed Stephen's fix and recompiled for Linux on a RH6.0 box with
> an i686.
> You can get it here:  http://smalltalk.swiki.net
> 
> cheers,
> Rob
> 
> Pair wrote:
> >
> > I have discovered that #valueUninterruptably does not work in a lot of
> > cases.  In fact, it's pretty easy to get Squeak to crash using #ensure:.  If
> > you call a method, passing in a block that has a return embedded in it, and
> > that method in turn evaluates the passed in block inside of another block
> > protected by #ensure: you get a nice way to exit Squeak in a hurry.
> >
> > I modified the interpreter such that any section of code can be protected
> > with #ensure: in a reliable way, without the need for #valueUninterruptably.
> > I fear that this solution comes at the cost of some performance.  Perhaps
> > someone can enhance it.  It works by checking if the return context is not
> > the sender, in which case it sends #aboutToReturn:to: to the context.  This
> > hook can then be used to send #unwindTo:.  Returns to sender are handled
> > just as they used to be.
> >
> > One enhancement might be to make the VM check that the context is in fact a
> > BlockContext.  But I'm not sure.
> >
> > The change set postscript recreates the special objects array, you'll need
> > to ensure that it has executed, then save your image, and finally launch the
> > image with the new VM.  You should not launch other images on the new VM as
> > the VM needs the new entry in special objects.
> >
> > - Stephen
> >
> > -----
> > This change set modifies the interpreter to support returns that
> > can happen in block, but allow for curtail and ensure block to
> > be executed.  This was developed in Squeak2.7.
> >
> > This change set is also located at: http://safereturn-squeak.swiki.net
> >
> > This modification requires you to generate a new interp.c and
> > compile a new VM.  I've compiled the VM for Windows (based on BLD2 from
> > Andreas), which can be downloaded here:
> > http://safereturn-squeak.swiki.net/.uploads/squeak_sr.exe
> >
> > Note, I have yet to benchmark the performance of this VM as compared with
> > the shipped VM.  If anyone has any ideas of how to acquire such
> > measurements, please let me know:  spair at acm.org
> >
> > Also, if someone can enhance the code to make it perform better, let me now.
> >
> >   ------------------------------------------------------------------------
> >                     Name: SafeReturn.cs
> >    SafeReturn.cs    Type: unspecified type (application/octet-stream)
> >                 Encoding: quoted-printable
> 
> --
> --------------------------------------------------
> Smalltalking by choice.  Isn't it nice to have one!





More information about the Squeak-dev mailing list