Fastest portable runtime
November 7, 2006
What is the best implementation for a portable language runtime? That is, if I wanted to implement something for a new language, what’s the best technique? Obviously, if all the expensive operations are implemented in high-performance compiled code (DirectX, databases, web stuff, etc), then the runtime performance doesn’t matter, but I’d still like it to be fast. The easy answer is a CISC machine implemented on a threaded bytecode interpreter. A hybrid stack-interpreter can be ~10% faster. Selective inlining can improve performance markedly (>50% in this paper), but then you need a RISC instruction set. When I was writing a compiler for .NET and Java runtimes, someone pointed out that I should simply write an interpreter in .NET and let the JIT’s inliner generate faster, compiled code. Basically, the runtimes can do selective inlining for me automatically. I never tried it but I think he’s absolutely right. I should run a little test and check if the runtime is inlining my code properly.