02-Jun-2013 22:25, Alex Rønne Petersen пишет:
On 02-06-2013 19:58, Dmitry Olshansky wrote:

One pointer to a struct MyInterpreterState. Think of it as 'this'
pointer :)

That's one load and store for every single step in the interpreter.
Sounds harmless, but every cycle matters when every goto start(...)
amounts to a single instruction in the program you're running.


If the instruction set is RISC-y then you are in trouble anyway (writing interpreter not in ASM). One way out is fusing multiple simple instructions into macro-instructions and interpreting those.

Either way, evidence suggests that this style of interpreter has
performance advantages in practice.


Agreed. Though this day I'd go for what I call "bastardized JIT". In essense just produce a chunk of "call XYZ" instructions, comnditionals would have to have a test + jmp. And then there is 'ret' at the end of this chunk ~4 instructions to have to deal with. What you get is branch prediction done on the hardware level and no instruction counter to worry about.

--
Dmitry Olshansky

Reply via email to