diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-15 14:59:35 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-15 14:59:35 -0300 |
commit | 758c1ef445ab27d89bace746111add04083a8e20 (patch) | |
tree | 8136726cfaa1dc0841547987f2cb0555d02f2303 /lopcodes.h | |
parent | dd6d8db49acda5d5353a0a9c42485d9b4bde419d (diff) | |
download | lua-758c1ef445ab27d89bace746111add04083a8e20.tar.gz lua-758c1ef445ab27d89bace746111add04083a8e20.tar.bz2 lua-758c1ef445ab27d89bace746111add04083a8e20.zip |
Unification of size representation in OP_NEWTABLE and OP_SETLIST
Opcodes OP_NEWTABLE and OP_SETLIST use the same representation to
store the size of the array part of a table. This new representation
can go up to 2^33 (8 + 25 bits).
Diffstat (limited to 'lopcodes.h')
-rw-r--r-- | lopcodes.h | 23 |
1 files changed, 10 insertions, 13 deletions
@@ -214,7 +214,7 @@ OP_SETTABLE,/* A B C R(A)[R(B)] := RK(C) */ | |||
214 | OP_SETI,/* A B C R(A)[B] := RK(C) */ | 214 | OP_SETI,/* A B C R(A)[B] := RK(C) */ |
215 | OP_SETFIELD,/* A B C R(A)[K(B):string] := RK(C) */ | 215 | OP_SETFIELD,/* A B C R(A)[K(B):string] := RK(C) */ |
216 | 216 | ||
217 | OP_NEWTABLE,/* A B C R(A) := {} (size = B,C) */ | 217 | OP_NEWTABLE,/* A B C R(A) := {} */ |
218 | 218 | ||
219 | OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C):string] */ | 219 | OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C):string] */ |
220 | 220 | ||
@@ -321,12 +321,17 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ | |||
321 | 321 | ||
322 | (*) In OP_RETURN, if (B == 0) then return up to 'top'. | 322 | (*) In OP_RETURN, if (B == 0) then return up to 'top'. |
323 | 323 | ||
324 | (*) In OP_SETLIST, if (B == 0) then real B = 'top'; if (C == 0) then | 324 | (*) In OP_LOADKX and OP_NEWTABLE, the next instruction is always |
325 | next 'instruction' is EXTRAARG(real C). | ||
326 | |||
327 | (*) In OP_LOADKX and OP_NEWTABLE, the next 'instruction' is always | ||
328 | EXTRAARG. | 325 | EXTRAARG. |
329 | 326 | ||
327 | (*) In OP_SETLIST, if (B == 0) then real B = 'top'; if k, then | ||
328 | real C = EXTRAARG _ C (the bits of EXTRAARG concatenated with the | ||
329 | bits of C). | ||
330 | |||
331 | (*) In OP_NEWTABLE, B is log2 of the hash size (which is always a | ||
332 | power of 2) plus 1, or zero for size zero. If not k, the array size | ||
333 | is C. Otherwise, the array size is EXTRAARG _ C. | ||
334 | |||
330 | (*) For comparisons, k specifies what condition the test should accept | 335 | (*) For comparisons, k specifies what condition the test should accept |
331 | (true or false). | 336 | (true or false). |
332 | 337 | ||
@@ -375,12 +380,4 @@ LUAI_DDEC(const lu_byte luaP_opmodes[NUM_OPCODES];) | |||
375 | /* number of list items to accumulate before a SETLIST instruction */ | 380 | /* number of list items to accumulate before a SETLIST instruction */ |
376 | #define LFIELDS_PER_FLUSH 50 | 381 | #define LFIELDS_PER_FLUSH 50 |
377 | 382 | ||
378 | |||
379 | /* | ||
380 | ** In OP_NEWTABLE, array sizes smaller than LIMTABSZ are represented | ||
381 | ** directly in R(B). Otherwise, array size is given by | ||
382 | ** (R(B) - LIMTABSZ) + EXTRAARG * LFIELDS_PER_FLUSH | ||
383 | */ | ||
384 | #define LIMTABSZ (MAXARG_B - LFIELDS_PER_FLUSH) | ||
385 | |||
386 | #endif | 383 | #endif |