Making a VM, what should be implemented in bytecode?

  • From: Robin Heggelund Hansen <skinneyz89@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sat, 30 Nov 2013 10:55:50 +0100

I've toyed with the idea of creating my own VM for a Lisp/Clojure like
language, and have been reading alot of documents, research papers and
LuaJIT source code. One question I've ended up with is what type of
operations should be implemented in bytecode, and what should be
implemented in sourcecode?

Scanning through the bytecode specification for LuaJIT, I see that bitops
aren't bytecode, but provided through the FFI. Why not specified in the
bytecode along with +, -, * and the rest?

Also, tables. I understand that for tables to be fast in the interpreter,
they would have to be implemented in C, but the trace compiler would be
able to make them pretty fast right? Considering a language like Lisp,
where collections are used *EVERYWHERE*, would it be at all smart to
implement collections in Lisp, or should them be defined in the interpreter
and the operations specified in bytecode?

Other related posts: