3 ms·
I know a lot about Lua and LuaJIT, but never heard of Dis until today. After reading a bit about Dis, it sounds like the two have very different designs. Dis
by haberman 11y ago
I know a lot about Lua and LuaJIT, but never heard of Dis until today. After reading a bit about Dis, it sounds like the two have very different designs.
Dis is defined by its instruction set. The instruction set is typed, so the programming language pretty much needs to by statically typed (Lua is dynamically typed). It appears to only support interpreted or fully-compiled modes; ie. it doesn't appear to support a hybrid interpreted/compiled mode where hotspots get compiled (I can't be 100% sure about this from what I read though).
LuaJIT is defined by the Lua programming language -- it has bytecode internally, but this is not really designed to be targeted by other code generators, and the bytecode is heavily biased towards Lua language semantics (some smart people tried compiling JavaScript to LuaJIT and made a lot of progress, but ultimately found that even the slight incompatibilities between JavaScript and Lua made life very difficult: https://tessel.io/blog/112888410737/moving-faster-with-io-js https://tessel.io/blog/112888410737/moving-faster-with-io-js).
LuaJIT is built on a fast interpreter written in assembly language, and uses trace compiling to identify hot traces and JIT-compiles only those. Its compiler is pretty sophisticated, using a SSA internal representation and many optimizations (http://wiki.luajit.org/Optimizations http://wiki.luajit.org/Optimizations). I suspect this is far beyond what the Dis VM does in its JIT compiler -- the Dis VM emphasizes how many Dis VM instructions can be translated directly into CPU instructions. It seems to expect that most optimization will happen at byte-code generation time, which is a more practical assumption with statically-typed languages.
Overall I expect that LuaJIT is as fast or faster than Dis, despite Lua being a dynamically-typed language. LuaJIT is one of the fastest VMs out there. But it's not a multi-language VM like Dis could potentially be.
- pjmlp 11y ago> But it's not a multi-language VM like Dis could potentially be. Dis also supports Java. http://doc.cat-v.org/inferno/java_on_dis/ http://doc.cat-v.org/inferno/java_on_dis/