lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 9/7/2017 9:00 AM, Soni L. wrote:


On 2017-09-06 03:21 PM, Egor Skriptunoff wrote:
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.



SELF takes 2 inputs and produces 2 outputs, so why's it 1 1 3 and
not 1 1 2?

Register based virtual machine, is it.  Yes, hmmm. [1]

[1] Sorry, couldn't resist. :-p
Converted using: http://www.yodaspeak.co.uk/index.php

--
Cheers,
Kein-Hong Man (esq.)
Selangor, Malaysia