[Vm-dev] Re: [Pharo-project] BlockClosure>>ensure: implementation
Eliot Miranda
eliot.miranda at gmail.com
Tue Oct 23 22:57:15 UTC 2012
On Mon, Oct 22, 2012 at 2:17 AM, Clément Bera <clement.bera at inria.fr> wrote:
> Hello,
>
> I don't understand something on BlockClosure>>ensure:. Why does it use
> 'self valueNoContextSwitch' and not 'self value' ? In which case is there
> an issue ?
Prior to my closure implementation BlockContext>>value[:value:*] was not a
context switch point. So to preserve the threading semantics of ensure: we
implemented ensure: in terms of BlockClosure>>valueNoContextSwitch, which
is not a context-switch point, as opposed to BlockClosure>>value[:value:*].
The context switch points in the VM are non-primitive sends (or failing
primitives, i.e. full method activation), backward branches, the Process
primitives suspend, resume, signal and wait (and CrtiticalSection/Mutex
enter and exit) and block evaluation.
>
> Thank you for any answers
>
> BlockClosure>>ensure: is implemented this way :
>
> ensure: aBlock
> "Evaluate a termination block after evaluating the receiver, regardless of
> whether the receiver's evaluation completes. N.B. This method is *not*
> implemented as a primitive. Primitive 198 always fails. The VM uses prim
> 198 in a context's method as the mark for an ensure:/ifCurtailed:
> activation."
>
> | complete returnValue |
> <primitive: 198>
> returnValue := *self valueNoContextSwitch*.
> complete ifNil:[
> complete := true.
> aBlock value.
> ].
> ^ returnValue
>
>
--
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20121023/f3d2bb94/attachment-0001.htm
More information about the Vm-dev
mailing list