Skip to content

Commit

Permalink
More simplifications.
Browse files Browse the repository at this point in the history
Now that exception handlers are outside of the fast path, we can just use a block.
  • Loading branch information
guillep committed Sep 7, 2023
1 parent 3d5c5ca commit e1ec3bc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 38 deletions.
4 changes: 4 additions & 0 deletions src/MethodProxies/MpCannotInstall.class.st
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"
I'm an exception raised when a proxy cannot be installed.
This usually happens when the wrapped method is a very special method whose instrumentation could break the system.
"
Class {
#name : #MpCannotInstall,
#superclass : #Error,
Expand Down
7 changes: 7 additions & 0 deletions src/MethodProxies/MpHiddenSelector.class.st
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"
I represent a selector that is hidden for the user, used to install hidden methods in method dictionaries.
I'm not a string, so I cannot be typed, avoiding potential conflicts.
I'm used as key of the original method wrapped by proxies, to ensure this wrapped method can be called using myself as selector.
Check my usages during proxy installation.
"
Class {
#name : #MpHiddenSelector,
#superclass : #Object,
Expand Down
18 changes: 16 additions & 2 deletions src/MethodProxies/MpMethodProxy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1157,8 +1157,22 @@ MpMethodProxy >> install [
(proxyMethod hasPragmaNamed: #noInstrumentation) ifTrue: [
^ MpCannotInstall signalWith: self ].

deactivator := MpProxyInstrumentationDeactivator new.
deactivator handler: handler.
deactivator := [ "Execution handler for the slow path. An exception or a non local return happened during proxy execution"
| wasMeta trapContext |

"Jump to the meta level (to avoid meta-recursions) to observe if the handler was in a meta level, marked by the wasMeta flag.
During the meta-jump call the handler to tell there was an unwind.
"
thisProcess shiftLevelUp.
trapContext := thisContext findContextSuchThat: [ :ctx | ctx isUnwindContext ].
wasMeta := trapContext tempNamed: 'wasMeta'.
handler aboutToReturnWithReceiver: trapContext receiver arguments: trapContext arguments.
thisProcess shiftLevelDown.

"If the handler was in a meta-state (i.e., the exception or non-local return happened in the handler), shift it back to the base level before returning.
Otherwise, we were already in the base level and we need to do nothing!"
wasMeta ifTrue: [ thisProcess shiftLevelDown ].
].

newTrap := self trapMethodPrototype copy.
trapSelector := newTrap selector.
Expand Down
36 changes: 0 additions & 36 deletions src/MethodProxies/MpProxyInstrumentationDeactivator.class.st

This file was deleted.

0 comments on commit e1ec3bc

Please sign in to comment.