Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concise description of the Lua vm?

Tags:

lua

I've skimmed Programming in Lua, I've looked at the Lua Reference.

However, they both tells me this function does this, but not how.

When reading SICP, I got this feeling of: "ah, here's the computational model underlying scheme"; I'm trying to get the same sense concerning Lua -- i.e. a concise description of it's vm, a "how" rather than a "what".

Does anyone know of a good document (besides the C source) describing this?

like image 593
anon Avatar asked May 04 '10 22:05

anon


People also ask

Does Lua use a virtual machine?

Since 2003, with the release of Lua 5.0, Lua uses a register-based virtual machine.

How does Lua compiler work?

The Lua compiler uses no intermediate representation. It emits instructions for the virtual machine “on the fly” as it parses a program. Nevertheless, it does perform some optimizations. For instance, it delays the generation of code for base expressions like variables and constants.

What is Lua bytecode?

Lua bytecode instructions are 32-bits in size. All instructions have an opcode in the first 6 bits. Instructions can have the following fields: 'A' : 8 bits 'B' : 9 bits 'C' : 9 bits 'Ax' : 26 bits ('A', 'B', and 'C' together) 'Bx' : 18 bits ('B' and 'C' together) 'sBx' : signed Bx.


1 Answers

You might want to read the No-Frills Intro to Lua 5(.1) VM Instructions (pick a link, click on the Docs tab, choose English -> Go).

I don't remember exactly where I've seen it, but I remember reading that Lua's authors specifically discourage end-users from getting into too much detail on the VM; I think they want it to be as much of an implementation detail as possible.

like image 99
Mark Rushakoff Avatar answered Sep 28 '22 11:09

Mark Rushakoff