[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Feature request: hiding upvalues
- From: Philippe Verdy <verdy_p@...>
- Date: Fri, 16 Nov 2018 22:22:24 +0100
the term "word" was chosen purpusely and accuretely: it indicates the basic unit of data managed at the instruction level by the instruction set used by the interpreting part of the engine. Even in the Lua.org's VM, this unit of information is the same a a standard Lua value: it has both a
a type and a value (not necessarily numeric), which are unseparatable.
In a classic CPU, the "word" has no distinctive type, it's just a fixed-size set of bits with arithmetic properties.
In Lua.org's VM, the "word" is also fixed size but contain other bits that have no arithmetic properties but are assiocated with specific behavior affecting what the VM does or infers in addition to what is specified by the instruction set.
I used "word" exactly, I did not say "byte" or "bits", or "integer": "word" is the abstract term that covers other kind of data (here data which includes itself its own datatype information, something not encoded at all in "words" used by CPU where datatype is implicit and unchangeable, and only depends on the instructions in code, plus some other constraints like the state of internal registers, notably those controlling access to external memory when these words are used as "adresses" by specifically instructions).
In the formal Turing machine, a "word" is any information stored in a distinct memory cell, but the machine does not restrict at all the type of information stored there (it's not necessarily an integer in a restricted range, like in CPUs).
anyway I think that what the Lua authors name "registers" is abusive, it is just a frame format, except that it uses a separate store than the call stack, and that the callstack itself is not necessarily represented as a single vector but can as well be a chained list: VM are free to use the represetnation that is more convenient to them and the integration contraint or memory constraints.
The word 'registers' is used to differentiate the PUC Lua interpreter's approach of defining the VM from the typical stack machine instruction set, where most of the time the operands are the top few entries of a stack, and the instructions do not explicitly reference them. At the right level of abstraction (the VM instruction level) they are 'registers'. At the VM implementation level they're arrays of numbers/pointers with tag bits. I have to disagree with the use of the word "abusive" here.