yoy.be "Why-o-Why"

TIL: JVM and CIL both use the stack instead of registers.

2016-05-30 16:03  jvmcilstack  coding  [permalink]

Thing I learned today: both JVM and CIL use the stack instead of registers!
JVM: https://jakubdziworski.github.io/enkel/2016/03/16/enkel_3_hello_enkel.html#generating-bytecode-based-on-instructions-queue 
CIL: https://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes(v=vs.110).aspx

Sounds like a bad decision, not only because most other intermediate stuff I've seen uses SSA, but especially it makes the work for JIT-compilers that much harder.

At least, that's my first impression, just from thinking about what a JIT-compiler would have to do: assigning the processor's available registers to what they'll be used for in a section of logic, is a science and an artform all on its own; but if you don't have anything roughly materialized to work with from the beginning, you're bound to eke it out of the given logic and see what it's supposed to do, by following the things that hop on and off the stack... With the lot of guesswork, statistics and heuristics that comes with it.

I guess that's where the recent hype in JIT-compiler innovation comes from. If you get a cleaner conversion to something as if it was written with SSA, you'll probably get better results, but it still feels like a step backward and two steps forward.

And all this because I was comtemplating which back-end to (re)use in case I would have a go at having a play language of my own compile into something executable.

So, sorry guys, but I guess I'm back to looking into LLVM or GCC for a back-end... (unless...)

twitter reddit linkedin facebook