Hacker News new | ask | show | jobs
by skybrian 2880 days ago
At first glance, this looks like an ordinary interpreter loop [1] using a large switch statement. I didn't think this was all that fast in Go, compared to C. And yet the JIT version isn't hugely faster and can be slower. Are there performance tricks I'm missing?

[1] https://github.com/perlin-network/life/blob/master/exec/vm.g...

1 comments

Do you mean the JIT engine in this same codebase?

It looks like it generates C code and compiles it on the fly. The generated code seems to do manual stack operations, rather than assigning values to variables, and it’s compiled with -O1 so it won’t be heavily optimized. It will be a bit faster than the interpreter because it avoids the opcode dispatch overhead, but if I understand the code right it’s not surprising that it isn’t a ton faster.