<div dir="ltr"><div>Anyone willing to compare with Inbox: Kernel-nice.857.mcz ?<br><a href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2014-June/178492.html">http://lists.squeakfoundation.org/pipermail/squeak-dev/2014-June/178492.html</a><br><br>follow up:<br><a href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2014-June/178493.html">http://lists.squeakfoundation.org/pipermail/squeak-dev/2014-June/178493.html</a><br><a href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2014-June/178497.html">http://lists.squeakfoundation.org/pipermail/squeak-dev/2014-June/178497.html</a><br><a href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2014-June/178506.html">http://lists.squeakfoundation.org/pipermail/squeak-dev/2014-June/178506.html</a><br><br>Note that rearmHandlerDuring: is used by some of Eliot's scripts (see above).<br></div><div>So I tried to preserve it.<br></div><div><br><div>IMO testHandlerReentrancy is fallacy.<br></div>It's just that it seems to be used by Island mechanism in latest versions of in Tweak see
<a href="https://code.google.com/p/pharo/issues/detail?id=2519">https://code.google.com/p/pharo/issues/detail?id=2519</a><br><br></div><div class="gmail_extra">Note that Andres' code still use tempAt: 1 & 2 (understand the temps of on:do: context) so removing tempAt: 3, while possibly a good thing, is not that spectacular: we still need some introspection of execution stack, one way or another...<br><br></div><div class="gmail_extra"><div class="gmail_quote">2014-09-13 2:57 GMT+02:00 Andres Valloud <span dir="ltr"><<a href="mailto:avalloud@smalltalk.comcastbiz.net" target="_blank">avalloud@smalltalk.comcastbiz.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Feel free to improve the code. I merely adapted the Pharo changes to Cuis. I am not really aware of your long term plans. Please let me know what you decide to do in the end, as I'd like to keep Cuis in the loop.<span class=""><br>
<br>
On 9/12/14 17:14 , Eliot Miranda wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<br>
<br>
On Fri, Sep 12, 2014 at 2:12 PM, Frank Shearar <<a href="mailto:frank.shearar@gmail.com" target="_blank">frank.shearar@gmail.com</a><br></span><span class="">
<mailto:<a href="mailto:frank.shearar@gmail.com" target="_blank">frank.shearar@gmail.<u></u>com</a>>> wrote:<br>
<br>
On 12 September 2014 21:49, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a><br></span><div><div class="h5">
<mailto:<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.<u></u>com</a>>> wrote:<br>
> Hi Frank,<br>
><br>
> I'd rather see<br>
><br>
> on: exception do: handlerAction<br>
> "Evaluate the receiver in the scope of an exception handler.<br>
> The following primitive is just a marker used to find the error<br>
> handling context.<br>
> See MethodContext>>#<u></u>isHandlerOrSignalingContext. "<br>
> <primitive: 199><br>
> <handler><br>
> ^ self value!<br>
><br>
> isHandlerContext<br>
> "is this context for #on:do:?"<br>
> ^self isHandlerOrSignalingContext and: [ (self method pragmaAt:<br>
> #handler) notNil: ]<br>
><br>
> etc, rather than testing the selector.<br>
<br>
OK, I see what you're doing there. I guess the only worry I have is<br>
that <handler> doesn't seem terribly specific to me.<br>
<br>
<br>
it can be as specific a label as you'd like.<br>
<br>
<br>
One thing I don't get is the tempAt: 3 stuff. This code removes it,<br>
and that seems to be the root of why #testHandlerReentrancy fails. But<br>
this is beyond my depth (which is most of why I made Andres' code more<br>
available for those for home this is _not_ out of depth).<br>
<br>
<br>
I hear you.<br>
<br>
> I'd also like to see the code in<br>
> MethodCOntext (e.g. where method can be directly accessed) than in<br>
> ContextPart. Remember that some time soon we can collapse ContextPart and<br>
> MethodContext onto Context as the Pharo folks have already done.<br>
<br>
Right, because BlockContext has been marked for death? (Because<br>
MethodContext has a closureOrNil instvar, which disambiguates between<br>
MethodContexts-for-block-<u></u>activations and<br>
MethodContexts-for-method-<u></u>activations.)<br>
<br>
<br>
Right. BlockCOntext is obsolete and unused.<br>
<br>
But since at some point we're going to merge MethodContext and<br>
ContextPart, why not just leave the code where it is? I guess it just<br>
depends on whether we merge MethodContext -> ContextPart, or<br>
ContextPart -> MethodContext.<br>
<br>
<br>
Well, the inst vars contexts need are defined in InstructionStream and<br>
MethodContext. So implementing in MethodCOntext allows e.g. direct<br>
access to method. So I don't recommend putting things in ContextPart<br>
any more.<br>
<br>
<br>
frank<br>
<br>
> On Fri, Sep 12, 2014 at 1:40 PM, <<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a><br></div></div><div><div class="h5">
<mailto:<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.<u></u>org</a>>> wrote:<br>
>><br>
>> Frank Shearar uploaded a new version of Kernel to project The Inbox:<br>
>> <a href="http://source.squeak.org/inbox/Kernel-fbs.870.mcz" target="_blank">http://source.squeak.org/<u></u>inbox/Kernel-fbs.870.mcz</a><br>
>><br>
>> ==================== Summary ====================<br>
>><br>
>> Name: Kernel-fbs.870<br>
>> Author: fbs<br>
>> Time: 12 September 2014, 9:40:45.406 pm<br>
>> UUID: 868e0d8a-5e9d-d34d-ba2d-<u></u>688800331f5b<br>
>> Ancestors: Kernel-eem.869<br>
>><br>
>> These are the changes Andres Valloud made to Cuis, to address a<br>
>> long-standing bug in Cuis, Squeak and Pharo, in ExceptionsTests >><br>
>> #testHandlerFromAction.<br>
>><br>
>> However, it causes a regression in #testHandlerReentrancy, so as<br>
it stands<br>
>> it is NOT READY FOR MERGING.<br>
>><br>
>> Please take a look, and see if we can bend Andres' code slightly<br>
so that<br>
>> we get both the fix and don't break anything.<br>
>><br>
>> =============== Diff against Kernel-eem.869 ===============<br>
>><br>
>> Item was changed:<br>
>> ----- Method: BlockClosure>>on:do: (in category 'exceptions')<br>
-----<br>
>> on: exception do: handlerAction<br>
>> + "Evaluate the receiver in the scope of an exception handler.<br>
>> + The following primitive is just a marker used to find<br>
the error<br>
>> handling context.<br>
>> + See MethodContext>>#<u></u>isHandlerOrSignalingContext. "<br>
>> + <primitive: 199><br>
>> - "Evaluate the receiver in the scope of an exception<br>
handler."<br>
>> -<br>
>> - | handlerActive |<br>
>> - <primitive: 199> "just a marker, fail and execute the<br>
following"<br>
>> - handlerActive := true.<br>
>> ^ self value!<br>
>><br>
>> Item was changed:<br>
>> ----- Method: BlockContext>>on:do: (in category 'exceptions')<br>
-----<br>
>> on: exception do: handlerAction<br>
>> + "Evaluate the receiver in the scope of an exception handler.<br>
>> + The following primitive is just a marker used to find<br>
the error<br>
>> handling context.<br>
>> + See MethodContext>>#<u></u>isHandlerOrSignalingContext. "<br>
>> + <primitive: 199><br>
>> + ^ self value!<br>
>> - "Evaluate the receiver in the scope of an exception<br>
handler."<br>
>> - | handlerActive |<br>
>> - <primitive: 199><br>
>> - handlerActive := true.<br>
>> - ^self value!<br>
>><br>
>> Item was changed:<br>
>> ----- Method: ContextPart>>canHandleSignal: (in category<br>
>> 'private-exceptions') -----<br>
>> canHandleSignal: exception<br>
>> "Sent to handler (on:do:) contexts only. If my<br>
exception class<br>
>> (first arg) handles exception then return true, otherwise<br>
forward this<br>
>> message to the next handler context. If none left, return false<br>
(see<br>
>> nil>>canHandleSignal:)"<br>
>><br>
>> + ^ (self exceptionClass handles: exception)<br>
>> + or: [ self nextHandlerContext canHandleSignal:<br>
exception<br>
>> ].!<br>
>> - ^ (((self tempAt: 1) handles: exception) and: [self<br>
tempAt: 3])<br>
>> - or: [self nextHandlerContext canHandleSignal:<br>
exception].<br>
>> - !<br>
>><br>
>> Item was added:<br>
>> + ----- Method: ContextPart>>evaluateSignal: (in category<br>
>> 'private-exceptions') -----<br>
>> + evaluateSignal: exception<br>
>> + "The following primitive is just a marker used to find the<br>
>> evaluation context.<br>
>> + See MethodContext>>#<u></u>isHandlerOrSignalingContext. "<br>
>> +<br>
>> + <primitive: 199><br>
>> + | value |<br>
>> + exception privHandlerContext: self contextTag.<br>
>> + value := self exceptionHandlerBlock<br>
valueWithPossibleArgument:<br>
>> exception.<br>
>> + "return from self if not otherwise directed in handle block"<br>
>> + self return: value!<br>
>><br>
>> Item was added:<br>
>> + ----- Method: ContextPart>>exceptionClass (in category<br>
>> 'private-exceptions') -----<br>
>> + exceptionClass<br>
>> +<br>
>> + ^self tempAt: 1!<br>
>><br>
>> Item was added:<br>
>> + ----- Method: ContextPart>><u></u>exceptionHandlerBlock (in category<br>
>> 'private-exceptions') -----<br>
>> + exceptionHandlerBlock<br>
>> + "handler context only. access temporaries from<br>
>> BlockClosure>>#on:do:"<br>
>> +<br>
>> + ^self tempAt: 2!<br>
>><br>
>> Item was added:<br>
>> + ----- Method: ContextPart>><u></u>findNextHandlerContext (in category<br>
>> 'private-exceptions') -----<br>
>> + findNextHandlerContext<br>
>> + "Return the next handler marked context, returning nil<br>
if there is<br>
>> none. Search starts with self and proceeds up to nil."<br>
>> +<br>
>> + | context |<br>
>> + context := self findNextHandlerOrSignalingCont<u></u>ext.<br>
>> + context isNil<br>
>> + ifTrue: [ ^ nil ].<br>
>> + context isHandlerContext<br>
>> + ifTrue: [ ^ context ]. "If it isn't a handler<br>
context, it<br>
>> must be a signaling context.<br>
>> + When we reach a signaling context we must skip over any<br>
handlers<br>
>> + that might be on the stack between the signaling context<br>
and the<br>
>> handler<br>
>> + context for that signal."<br>
>> + ^ context exceptionClass privHandlerContext<br>
nextHandlerContext!<br>
>><br>
>> Item was removed:<br>
>> - ----- Method: ContextPart>><u></u>findNextHandlerContextStarting (in<br>
category<br>
>> 'private-exceptions') -----<br>
>> - findNextHandlerContextStarting<br>
>> - "Return the next handler marked context, returning nil<br>
if there is<br>
>> none. Search starts with self and proceeds up to nil."<br>
>> -<br>
>> - | ctx |<br>
>> - <primitive: 197><br>
>> - ctx := self.<br>
>> - [ctx isHandlerContext ifTrue:[^ctx].<br>
>> - (ctx := ctx sender) == nil ] whileFalse.<br>
>> - ^nil!<br>
>><br>
>> Item was added:<br>
>> + ----- Method: ContextPart>><u></u>findNextHandlerOrSignalingCont<u></u>ext (in<br>
>> category 'private-exceptions') -----<br>
>> + findNextHandlerOrSignalingCont<u></u>ext<br>
>> + "Return the next handler/signaling marked context,<br>
answering nil<br>
>> if there is none.<br>
>> + Search starts with self and proceeds up to nil."<br>
>> +<br>
>> + <primitive: 197><br>
>> + | context |<br>
>> + context := self.<br>
>> + [<br>
>> + context isHandlerOrSignalingContext<br>
>> + ifTrue: [ ^ context ].<br>
>> + (context := context sender) == nil ] whileFalse.<br>
>> + ^ nil!<br>
>><br>
>> Item was changed:<br>
>> ----- Method: ContextPart>>handleSignal: (in category<br>
>> 'private-exceptions') -----<br>
>> handleSignal: exception<br>
>> "Sent to handler (on:do:) contexts only. If my<br>
exception class<br>
>> (first arg) handles exception then execute my handle block<br>
(second arg),<br>
>> otherwise forward this message to the next handler context. If<br>
none left,<br>
>> execute exception's defaultAction (see nil>>handleSignal:)."<br>
>><br>
>> + (self exceptionClass handles: exception)<br>
>> + ifFalse: [ ^ self nextHandlerContext handleSignal:<br>
>> exception ].<br>
>> + self evaluateSignal: exception!<br>
>> - | val |<br>
>> - (((self tempAt: 1) handles: exception) and: [self<br>
tempAt: 3])<br>
>> ifFalse: [<br>
>> - ^ self nextHandlerContext handleSignal: exception].<br>
>> -<br>
>> - exception privHandlerContext: self contextTag.<br>
>> - self tempAt: 3 put: false. "disable self while<br>
executing handle<br>
>> block"<br>
>> - val := [(self tempAt: 2) cull: exception ]<br>
>> - ensure: [self tempAt: 3 put: true].<br>
>> - self return: val. "return from self if not otherwise<br>
directed in<br>
>> handle block"<br>
>> - !<br>
>><br>
>> Item was changed:<br>
>> ----- Method: ContextPart>>isHandlerContext (in category<br>
>> 'private-exceptions') -----<br>
>> isHandlerContext<br>
>> + "is this context for #on:do:?"<br>
>> + ^self isHandlerOrSignalingContext and: [ self selector<br>
== #on:do:<br>
>> ]!<br>
>> - ^false!<br>
>><br>
>> Item was added:<br>
>> + ----- Method: ContextPart>><u></u>isHandlerOrSignalingContext (in<br>
category<br>
>> 'private-exceptions') -----<br>
>> + isHandlerOrSignalingContext<br>
>> + "Both BlockClosure>>on:do: (handler) and<br>
>> ContextPart>>evaluateSignal: (signaling)<br>
>> + are marked with primitive 199."<br>
>> +<br>
>> + ^false!<br>
>><br>
>> Item was changed:<br>
>> ----- Method: ContextPart>><u></u>nextHandlerContext (in category<br>
>> 'private-exceptions') -----<br>
>> nextHandlerContext<br>
>><br>
>> + ^ self sender findNextHandlerContext!<br>
>> - ^ self sender findNextHandlerContextStarting<u></u>!<br>
>><br>
>> Item was removed:<br>
>> - ----- Method: ContextPart>><u></u>rearmHandlerDuring: (in category<br>
>> 'private-exceptions') -----<br>
>> - rearmHandlerDuring: aBlock<br>
>> - "Sent to handler (on:do:) contexts only. Makes me<br>
re-entrant for<br>
>> the duration of aBlock. Only works in a closure-enabled image"<br>
>> -<br>
>> - ^ [self tempAt: 3 put: true. aBlock value]<br>
>> - ensure: [self tempAt: 3 put: false]!<br>
>><br>
>> Item was added:<br>
>> + ----- Method: Exception>>privHandlerContext (in category 'priv<br>
>> handling') -----<br>
>> + privHandlerContext<br>
>> +<br>
>> + ^handlerContext!<br>
>><br>
>> Item was removed:<br>
>> - ----- Method: Exception>>rearmHandlerDuring: (in category<br>
'handling')<br>
>> -----<br>
>> - rearmHandlerDuring: aBlock<br>
>> - "Make the current error handler re-entrant while it is running<br>
aBlock.<br>
>> Only works in a closure-enabled image"<br>
>> -<br>
>> - ^ handlerContext rearmHandlerDuring: aBlock!<br>
>><br>
>> Item was removed:<br>
>> - ----- Method: MethodContext>><u></u>isHandlerContext (in category<br>
>> 'private-exceptions') -----<br>
>> - isHandlerContext<br>
>> - "is this context for method that is marked?"<br>
>> - ^method primitive = 199!<br>
>><br>
>> Item was added:<br>
>> + ----- Method: MethodContext>><u></u>isHandlerOrSignalingContext (in<br>
category<br>
>> 'private-exceptions') -----<br>
>> + isHandlerOrSignalingContext<br>
>> + "Both BlockClosure>>on:do: (handler) and<br>
>> ContextPart>>evaluateSignal: (signaling)<br>
>> + are marked with primitive 199."<br>
>> +<br>
>> + ^method primitive = 199!<br>
>><br>
>><br>
><br>
><br>
><br>
> --<br>
> best,<br>
> Eliot<br>
><br>
><br>
><br>
<br>
<br>
<br>
<br>
--<br>
best,<br>
Eliot<br>
<br>
<br>
<br>
</div></div></blockquote>
<br>
</blockquote></div><br></div></div>