2 ms·
> you want to emit instructions to somewhere in memory and then jump to them, something inherently unsafe Isn't this only for JIT? My understanding was that no
by lolinder 4y ago
> you want to emit instructions to somewhere in memory and then jump to them, something inherently unsafe
Isn't this only for JIT? My understanding was that non-JIT VMs basically function as emulators of a non-existent CPU, so they interpret each bytecode instruction rather than asking the CPU proper to do a jump.
- efficax 4y agoeven a bytecode vm has to emit bytecode and then move an instruction pointer around. You can do it without using C pointer manipulation but it will always be less than ideal. This is a nice little blog post about it: https://pliniker.github.io/post/dispatchers/ https://pliniker.github.io/post/dispatchers/
- lolinder 4y agoThanks! I'm starting work on a VM right now for a side project and was seriously considering using Rust, so this will be really helpful!