Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lua's bytecode specification [closed]

Can anyone tell me where to find Lua's bytecode specification? I've been searching for 15 minutes, and I can't find anything.

like image 257
Wilfred Springer Avatar asked Sep 26 '09 07:09

Wilfred Springer


People also ask

Does Lua have bytecode?

luac produces a single output file containing the bytecodes for all source files given. By default, the output file is named luac.

What is Lua bytecode?

Instruction Summary 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.

Does Lua use a VM?

Lua VM is a register machine. Lua's interpreter is a bytecode virtual machine. The interpreter first walks the program text to transform it into a sequence of bytecode instructions for a virtual processor, and then a simple while-switch dispatch loop is used for running the program, one instruction at a time.

Is Lua stack based?

For ten years (since 1993, when Lua was first released), Lua used a stack- based virtual machine, in various incarnations. Since 2003, with the release of Lua 5.0, Lua uses a register-based virtual machine. This register-based machine also uses a stack, for allocating activation records, wherein the registers live.


1 Answers

The official definition is in lopcodes.h.

like image 183
lhf Avatar answered Oct 15 '22 13:10

lhf