Friday, July 24, 2009

JITting native code

Although arguably it hasn't happened yet, JIT technology can theoretically exceed statically compiled C code, as far as I know.

What if there were a way to take execution of a normal (perhaps compiled from C) native program, trace its execution paths, and then do in-lining and whatever else JIT functions upon it? Perhaps just treat the x86 like any other bytecode and emulate it, except or the JIT'd parts which are more-or-less directly copied?

Although the problem with that is that emulating x86 (even on x86) is probably way slower than emulating normal language bytecodes, because x86 instructions are a lot more primitive and involve the architecture's peculiarities of register usage, etc. But I wonder if there's a way to trace paths without emulating it? It seems that somehow V8 does that, because they claim that it never executes bytecode. I don't really understand it myself.

modify the compiler to include calls in the (originally statically compiled) code that update an object by telling it that it execution passed through that code. then another thread can analyze this data and based on waht's there, and perhaps based on other meta-data included in the compiled program such as function boundaries and so on (if not even a complete or semi-complete bytecode, that's never executed), can take those paths and do things like in-lining, condition guards, moving variables to registers, and so on by creating new code sections in memory.

No comments: