I read mostly the JIT and LuaJIT compiler, and I had some questions.
From what I understand, LuaJIT JIT does not compile hot methods like Java HotSpot, it compiles hot paths coming from loops. Does this mean that if something does not come from the loop (let's say I call Lua functions from C-api), then the code will never be skewed? And what happens when you hit another loop? Will there be a path to the second JIT'ed loop, and then a new path from this loop, and will the second loop also be part of the same path?
How does the interpreter choose the most optimal hot way? Let's say I have a hash table of strings ints ->. Now imagine that I called table [x] with x equal to 3 and 5 enough to become hot tracks and jitted, as the interpreter decided which jitted code to call for table [x], where x is 4?
Another thing that was breaking my brain. Since paths are compiled, not functions, will the trace compiler require more memory? Since you cannot really reuse the compiled code of another path, I mean, and since in the general case the paths will have more single functions ...
source share