Advertisement

questions about the jit

Started by May 19, 2011 08:38 PM
2 comments, last by pabloreda 13 years, 5 months ago
1.what is the difference between jit and virtual machines?
2. are there any library for creating and running machine codes at run-time?
3. using jit in my scripting language can help me to increase running performance?

1.what is the difference between jit and virtual machines?
2. are there any library for creating and running machine codes at run-time?
3. using jit in my scripting language can help me to increase running performance?


JIT stand for just in time (a JIT compiler is a compiler that compiles the code while the program is running)

JIT compilers require a virtual machine since the code isn't compiled ahead of time, (Some JIT compilers will compile everything as the program launches, others will only compile code segments that are used heavily).

Basically a VM can use JIT compilation to improve its performance

As far as i know there are no JIT compiler libraries that you can just plug in to be used with your own scripting language that easily.

You could however compile your language to java bytecode and use the JVM to run it or you could build something of the LuaJIT compiler.

and yes, using JIT compilation will boost runtime performance allthough the actual compilation isn't free so for a game it might be a good idea to compile your scripts when the game starts or a level is loaded and then cache the compiled code.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Advertisement

As far as i know there are no JIT compiler libraries that you can just plug in to be used with your own scripting language that easily.


Indeed, the closest you are likely to get to that is using LLVM as a code compiling backend and that requires a fair chunk of work to get going with and isn't simple.. but then JIT compiling code isn't simple anyway :)
[color=#1C2837][size=2]2. are there any library for creating and running machine codes at run-time?
[color=#1C2837][size=2]

[color=#1C2837][size=2]yes, simply put the bytes in memory and call.
http://code.google.com/p/jitasm/

and others i not remember..

you can see others jit compilers in projects like

http://code.google.com/p/pcsx2/
or
http://code.google.com/p/dolphin-emu/

a nice introduction in
http://www.strchr.com/code_generator

This topic is closed to new replies.

Advertisement