[Vm-dev] StackInterp/Cog>>transferTo: -
assertValidExecutionPointe:r:s differences
Eliot Miranda
eliot.miranda at gmail.com
Fri Jun 10 12:17:01 UTC 2016
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 <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.
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)
More information about the Vm-dev
mailing list