Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What's a record & stack when talking about Lua VMs?

Asked by
Psudar 882 Moderation Voter
4 years ago
Edited 4 years ago

I was reading today and I was wondering what it was talking about when it mentions "record" and "stack" and why they were important.

Perhaps you have already read somewhere that, since version 5.0, Lua uses a register-based virtual machine. The “registers” of this virtual machine do not correspond to real registers in the CPU, because this correspondence would be not portable and quite limited in the number of registers available. Instead, Lua uses a stack (implemented as an array plus some indices) to accommodate its registers. Each active function has an activation record, which is a stack slice wherein the function stores its registers. So, each function has its own registers2. Each function may use up to 250 registers because each instruction has only 8 bits to refer to a register.

Any help? I tried looking it up online but I could only find confusing answers. A simple answer, if possible, would be helpful.

Thanks.

Answer this question