dibyendumajumdar / ravi

Ravi is a dialect of Lua, featuring limited optional static typing, JIT and AOT compilers
http://ravilang.github.io/
Other
1.16k stars 60 forks source link

Performance tuning of tables #115

Open dibyendumajumdar opened 7 years ago

dibyendumajumdar commented 7 years ago

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.

dibyendumajumdar commented 7 years ago

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.