Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
0 points
s_baby
13y ago
0 comments
Share
I thought Lua used a register based VM.
undefined | Better HN
0 comments
default
newest
oldest
wereHamster
13y ago
No, it's a stack machine. See
http://www.lua.org/manual/5.1/manual.html#3
munificent
13y ago
You're both right. It has a stack that it uses for callframes and local variables, but the opcodes have operands to directly reference variables on it by index. In other words, it treats all of the stack for a given callframe as a set of registers.
LeafStorm
13y ago
The stack is an abstraction used in the C API. If you look at the actual bytecode generated, it's all register-based.
j
/
k
navigate · click thread line to collapse