lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Mike Pall <mikelu-1102 <at> mike.de> writes:
> Alex Bradbury wrote:
> > So at its core, it's just a loop which fetches each instruction,
> > decodes it and then does a switch on the opcode number. The
> > performance numbers I've managed so far aren't competitive with the C
> > implementation and I'm interested in suggestions for improving that.
> 
> The main loop of an interpreter is a tough job for compilers (and
> CPUs). Most interpreters have been written in C, so C compilers
> have been tuned for this case over the years. They still generate
> mediocre code, compared to what you can achieve in assembler.

Could you possibly summarize the few biggest strategies that you
use to beat C compilers when it comes to interpreter loops?  I'm
really interested in this problem.  I can (and do) read the LuaJIT
code, but that doesn't tell me what was deficient about the original
compiler output.

Josh