ravi
ravi copied to clipboard
Performance tuning of tables
There are a few things we can try to improve the interpreter/JIT performance.
One of them is to try to inline some table lookups where keys are known to be strings or integers.
Also for hash lookups, we can adopt the LuaJIT approach of caching the hashmask (size of hash array - 1) rather than calculating it every time as Lua does.
Implemented a cached hashmask, and also modified LLVM code generation for GETTABLE_SK to generate inline code if the variable is a table and key is short string.
The inline code however only tries the first hash lookup and falls back to a function call if this doesn't return the required key. Maybe we can extend this to do another inline lookup before giving up - i.e. unroll the loop for first two iterations.