[squeak-dev] The Inbox: Kernel-nice.1391.mcz
Jakob Reschke
jakres+squeak at gmail.com
Sun Apr 25 15:33:58 UTC 2021
Hi Nicolas,
Please find Tests-jr.456 in the Inbox. It contains a test case that
reveals that reactivateHandlers is too eager at the moment. I tested
it with Kernel-nice.1391 loaded.
Kind regards,
Jakob
Am Fr., 23. Apr. 2021 um 10:58 Uhr schrieb <commits at source.squeak.org>:
>
> Nicolas Cellier uploaded a new version of Kernel to project The Inbox:
> http://source.squeak.org/inbox/Kernel-nice.1391.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-nice.1391
> Author: nice
> Time: 23 April 2021, 10:58:48.925778 am
> UUID: bde1d6d3-e3ba-48ad-b432-3ac5a1531880
> Ancestors: Kernel-nice.1390
>
> Remove the questionable ifCurtailed: block that did reactivate the handler in handleSignal:, and make the handling symetric, whether the handlerAction explicitily use exception return or not.
>
> Document the mysterious tempAt:/tempAt:put: intention by using proper method names as requested by Marcel.
> The slowdown shall be marginal, and system understanding should be improved.
>
> Provide messages to selectively reactivate some handler contexts. For gurus: handle with care!
>
> =============== Diff against Kernel-nice.1390 ===============
>
> Item was changed:
> ----- Method: Context>>canHandleSignal: (in category 'private-exceptions') -----
> canHandleSignal: exception
> "Sent to handler (on:do:) contexts only. If my exception class (first arg) handles exception then return true, otherwise forward this message to the next handler context. If none left, return false (see nil>>canHandleSignal:)"
>
> + ^ (self willHandleSignal: exception)
> - ^ (((self tempAt: 1) handles: exception) and: [self tempAt: 3])
> or: [self nextHandlerContext canHandleSignal: exception].
> !
>
> Item was added:
> + ----- Method: Context>>deactivateHandler (in category 'private-exceptions') -----
> + deactivateHandler
> + "Private - sent to exception handler context only (on:do:)"
> +
> + stackp >= 3 ifTrue: [self tempAt: 3 put: false] "this is temporary handlerActive in #on:do:"!
>
> Item was added:
> + ----- Method: Context>>fireHandlerActionWith: (in category 'private-exceptions') -----
> + fireHandlerActionWith: exception
> + "Sent to handler (on:do:) contexts only.
> + Perform the second argument, which is the handler action"
> +
> + ^(self tempAt: 2) cull: exception!
>
> Item was changed:
> ----- Method: Context>>handleSignal: (in category 'private-exceptions') -----
> handleSignal: exception
> "Sent to handler (on:do:) contexts only. If my exception class (first arg) handles exception
> and the handler is active then execute my handle block (second arg), otherwise forward
> this message to the next handler context. If none left, execute exception's defaultAction
> (see nil>>handleSignal:)."
>
> + | val |
> + (self willHandleSignal: exception) ifFalse:
> + [self deactivateHandler.
> - | handlerActive val |
> - "If the context has been returned from the handlerActive temp var may not be accessible."
> - handlerActive := stackp >= 3 and: [(self tempAt: 3) == true].
> - (((self tempAt: 1) handles: exception) and: [handlerActive]) ifFalse:
> - [stackp >= 3 ifTrue: [self tempAt: 3 put: false].
> ^self nextHandlerContext handleSignal: exception].
>
> exception privHandlerContext: self contextTag.
> + self deactivateHandler. "disable self while executing handle block"
> + val := self fireHandlerActionWith: exception.
> - self tempAt: 3 put: false. "disable self while executing handle block"
> - val := [(self tempAt: 2) cull: exception]
> - ifCurtailed: [self tempAt: 3 put: true].
> self return: val "return from self if not otherwise directed in handle block"
> !
>
> Item was added:
> + ----- Method: Context>>isHandlerActive (in category 'private-exceptions') -----
> + isHandlerActive
> + "Private - sent to exception handler context only (on:do:)"
> +
> + ^stackp >= 3 and: [(self tempAt: 3) == true] "this is temporary handlerActive in #on:do:"!
>
> Item was added:
> + ----- Method: Context>>reactivateHandler (in category 'private-exceptions') -----
> + reactivateHandler
> + "Private - sent to exception handler context only (on:do:)"
> +
> + stackp >= 3 ifTrue: [self tempAt: 3 put: true] "this is temporary handlerActive in #on:do:"!
>
> Item was changed:
> ----- Method: Context>>reactivateHandlers (in category 'private-exceptions') -----
> reactivateHandlers
> "Private - sent to exception handler context only (on:do:).
> Reactivate all the handlers into the chain"
>
> + self reactivateHandler.
> - self tempAt: 3 put: true. "this is temporary handlerActive in #on:do:"
> self nextHandlerContext reactivateHandlers!
>
> Item was added:
> + ----- Method: Context>>reactivateHandlersUpTo: (in category 'private-exceptions') -----
> + reactivateHandlersUpTo: aHandlerContext
> + "Private - sent to exception handler context only (on:do:).
> + Reactivate the inner handlers into the chain, up to, but not including, aHandlerContext"
> +
> + self == aHandlerContext ifTrue: [^self].
> + self reactivateHandler.
> + self nextHandlerContext reactivateHandlersUpTo: aHandlerContext!
>
> Item was added:
> + ----- Method: Context>>reactivateHandlersWhich:upTo: (in category 'private-exceptions') -----
> + reactivateHandlersWhich: selectBlock upTo: aHandlerContext
> + "Private - sent to exception handler context only (on:do:).
> + Reactivate the inner handlers into the chain, up to, but not including, aHandlerContext, that satisfy the selectBlock predicate"
> +
> + self == aHandlerContext ifTrue: [^self].
> + (selectBlock value: self) ifTrue: [self reactivateHandler].
> + self nextHandlerContext reactivateHandlersWhich: selectBlock upTo: aHandlerContext!
>
> Item was changed:
> ----- Method: Context>>rearmHandlerDuring: (in category 'private-exceptions') -----
> rearmHandlerDuring: aBlock
> "Sent to handler (on:do:) contexts only. Makes me re-entrant for the duration of aBlock. Only works in a closure-enabled image"
>
> + ^ [self reactivateHandler. aBlock value]
> + ensure: [self deactivateHandler]!
> - ^ [self tempAt: 3 put: true. aBlock value]
> - ensure: [self tempAt: 3 put: false]!
>
> Item was added:
> + ----- Method: Context>>willHandleSignal: (in category 'private-exceptions') -----
> + willHandleSignal: exception
> + "Sent to handler (on:do:) contexts only."
> +
> + ^self isHandlerActive and: [(self tempAt: 1) handles: exception]
> + !
>
> Item was added:
> + ----- Method: Exception>>reactivateHandlersUpTo: (in category 'priv handling') -----
> + reactivateHandlersUpTo: aHandlerContext
> + "reactivate all the exception handlers in the context chain"
> + self canSearchForSignalerContext
> + ifTrue: [signalContext nextHandlerContext reactivateHandlersUpTo: aHandlerContext]!
>
> Item was added:
> + ----- Method: UndefinedObject>>reactivateHandlersUpTo: (in category 'bottom context') -----
> + reactivateHandlersUpTo: aHandlerContext
> +
> + ^ self!
>
> Item was added:
> + ----- Method: UndefinedObject>>reactivateHandlersWhich:upTo: (in category 'bottom context') -----
> + reactivateHandlersWhich: selectBlock upTo: aHandlerContext
> +
> + ^ self!
>
>
More information about the Squeak-dev
mailing list
|