[squeak-dev] Re: Retrying a message send
siguctua at gmail.com
Sun Apr 11 08:48:44 UTC 2010
On 11 April 2010 11:33, Igor Stasenko <siguctua at gmail.com> wrote:
> suppose you having a method:
> <primitive: ... >
> self recompileAndRetry
> a #recompileAndRetry should do following:
> 1) recompile method #foo and install new version of #foo into class
> 2) restart execution from callee of #foo, so that it will call the
> same method again (but its renewed version)
> This is similar to what debugger does, when you changing a method in
> code pane and accepting it, except that it restarting a
> context of called method, instead of restarting from a point where
> caller context did a message send (and so, if a new method contains a
> it will be called by VM).
> Any ideas, how i can do (2) easily?
> My own thoughts is following:
> | retryCtx retryMethod caller method rcvr |
> retryCtx := thisContext sender.
> caller := retryCtx sender.
> method := retryCtx method.
> "here we recompile a method, like following: "
> method := method methodClass recompile: method selector.
> "now we're resending the same message"
> args := Array new: method numArgs.
> 1 to: args size do: [ :i | args at: i put: (retryCtx tempAt: i) ].
> thisContext terminateTo: caller.
> ^ retryCtx receiver perform: method selector arguments: args
Forgot to add:
the problem with the above, that if i restart it in that way, a call
stack, when i enter the new #foo method will be following:
caller context -> #recompileAndRetry context -> #foo
while i want, obviously, a clean stack state, as if this method
invoked naturally by interpreter:
caller context -> #foo
> Best regards,
> Igor Stasenko AKA sig.
Igor Stasenko AKA sig.
More information about the Squeak-dev