Re: StackInterp/Cog>>transferTo: - assertValidExecutionPointe:r:s differences
Posted by
Eliot Miranda-2 on
Jun 10, 2016; 2:51am
URL: https://forum.world.st/StackInterp-Cog-transferTo-assertValidExecutionPointe-r-s-differences-tp4900241p4900242.html
Hi Ben,
> On Jun 9, 2016, at 6:46 PM, Ben Coman <
[hidden email]> wrote:
>
>
> Just curious about the difference in instructionPointer between these two...
>
> StackInterpreter>>transferTo:
> self assertValidExecutionPointe: instructionPointer + 1 r:
> framePointer s: stackPointer.
>
>
> CoIntepreter>>transferTo:from:
> self assertValidExecutionPointe: instructionPointer r:
> framePointer s: stackPointer.
The difference is to support richer logging of process switch events in the Cog VM.
In the StackInterpreter context switches only occur in two contexts, within a primitive or checkForEventsMayContextSwitch:.
One might think that the Cog VM is similar but it's much more complicated because a primitive can be invoked in different ways. One way is from the interpreter via slowPrimitiveResponse, just like the StackInterpreter. Another way is from a jitted method containing a primitive. Yet another way is in the attempt to lookup and link a send from machine code that binds to a method with a primitive. Yet another way is in invoking a primitive in a method that should be interpreted (because it has more literals than the limit for jitting) from machine code. The VM optimises this transition by using a PIC which can have entries that speed up invoking interpreted methods or MNUs, not just polymorphic sends.
To debug context switch in these contexts (and one more historical context that I think no longer occurs) I needed the richer logging that the from: argument gave me to discover the actual path taken to a process switch.
HTH
>
> cheers -ben