lua-users home
lua-l archive

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


云风 Cloud Wu <cloudwu@gmail.com>于2016年7月19日周二 上午10:22写道:
Roberto Ierusalimschy <roberto@inf.puc-rio.br>于2016年7月18日周一 下午11:53写道:
Roughly: (1 + _ENV.B) should generate the following code, when '1' and 'B'
do not fit as immediate operands:

    7 - LOADK          0    5            -- R0 = "B"
    8 - LOADK          1    6            -- R1 = 1
    9 - GETTABUP       0    0    0       -- R0 = _ENV[R0]
   10 - ADD            0    1    0       -- R0 = R1 + R0


I tried to compile the test code in lua 5.3.3 . It generate the following code :

      460     [35]    LOADK           1 -257  ; "B"
      461     [35]    LOADK           2 -258  ; 1
      462     [35]    GETTABUP         2 0 1   ; _ENV
      463     [35]    ADD            1 2 2

I think it's wrong but no assertion :(

Sorry, I forgot to define lua_assert, and I know why the order of luaK_exp2RK is important now.

e1->k can never be VINDEXED, and when e2->k is VINDEXED, it tries to reuse the register just allocate.

Thanks Roberto for explanation.