lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,

For my Ph.D. thesis, I'm working on an optimizing JIT for JavaScript written in JavaScript. The IR I designed is SSA-based, and currently not very efficient. Being in JavaScript, and for readability, it's currently very object-oriented... And thus very space hungry and not nearly as fast as it could be. I read Mike Pall's 2009 blog post where he briefly talks about the LuaJIT IR and I got curious about the design choices you made for LuaJIT. I'd be very happy if someone had the time to answer some of my questions:

1. The post mentions using bidirectionally extensible arrays to store instructions. Is one such array used per basic block? If not, how are basic blocks efficiently allocated/moved within the array? What's the advantage of being able to extend the array bidirectionally? My optimizer does alot of IR transforms which merge/eliminate basic blocks, remove/replace/insert new instructions. How is that done efficiently in LuaJIT?

2. In my current layout I also keep a list of uses for each IR instruction (all instructions reading the output value of a given instruction). This is very useful when I want to replace the value of an instruction by that of another instruction. What kind of trick does LuaJIT use to do this efficiently?

3. How are constants encoded in the LuaJIT IR? I saw it uses 16 bit references to refer (I assume) to indices of other IR instructions elsewhere in the instruction array. Are constants also stored in the array, as instructions?

4. I saw the IR instructions have up to 2 operands. What about call instructions?

Thank you for your time,

- Maxime