[Vm-dev] StackInterp/Cog>>transferTo: - assertValidExecutionPointe:r:s differences

Ben Coman btc at openinworld.com
Fri Jun 10 03:44:03 UTC 2016


On Fri, Jun 10, 2016 at 11:30 AM, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>
> Hi Ben,
>
>> On Jun 9, 2016, at 6:46 PM, Ben Coman <btc at openinworld.com> 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.


Thanks Eliot.  Great info that I'll file for reference, but this seems
only to describe the addition to Cog of the #from: argument, and I'm
not sure how that relates to my query on why the assert for
StackInterpreter increments the instructionPointer by one, and the
assert for the CoInterpreter does not.  Sorry if my question was too
brief an unclear?

cheers -ben


More information about the Vm-dev mailing list