On Wed, Sep 6, 2017 at 4:28 PM, Soni L. wrote:
While playing with the Lua parser I noticed OP_SELF uses an
unnecessary extra register, but this is only visible if you have
more than 256 constants.
771 [258] LOADK 3 -257 ; "print"
772 [258] SELF 1 1 3
This is not a bug.
Instruction "SELF 1 1 -257" is impossible due to limitation of 9 bits
per constant index (operand C) for opcode SELF.
On the contrary, LOADK can address any constant using 18-bit field
(field Bx).
That's why all constants except first 256 have to be passed through
intermediate register.