Re: StackInterp/Cog>>transferTo: - assertValidExecutionPointe:r:s differences
Posted by
Eliot Miranda-2 on
Jun 10, 2016; 11:38am
URL: https://forum.world.st/StackInterp-Cog-transferTo-assertValidExecutionPointe-r-s-differences-tp4900241p4900372.html
Hi Ben,
this time I'll try and answer your question rather than my brain fart...
> 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.
In the StackInterpreter, as in the context Interpreter the next bytecode is fetched by pre-incrementing the instructionPointer and then fetching the byte it points to. Hence it may point to before the first bytecode and hence the + 1 above. 1 is subtracted from a context's pc (2 actually cuz pc is 1-relative and instructionPointer is 0-relative) to derive instructionPointer.
In the Cog VM instructionPointer may also be a machine code pc. So rather than add one, which only makes sense for interpreted methods, the CoInterpreter's assertValidExecutionPointer:s: allows for the - 1 if a frame us interpreted. The StackInterpreter's method predates the CoInterpreter.
>
>
> cheers -ben
_,,,^..^,,,_ (phone)