OP_NEWTABLE keeps exact size of arrays

OP_NEWTABLE is followed by an OP_EXTRAARG, so that it can keep
the exact size of the array part of the table to be created.
(Functions 'luaO_int2fb'/'luaO_fb2int' were removed.)
This commit is contained in:
Roberto Ierusalimschy
2019-07-12 16:13:50 -03:00
parent f6aab3ec1f
commit 1fb4d53925
10 changed files with 67 additions and 88 deletions

View File

@@ -324,7 +324,8 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
(*) In OP_SETLIST, if (B == 0) then real B = 'top'; if (C == 0) then
next 'instruction' is EXTRAARG(real C).
(*) In OP_LOADKX, the next 'instruction' is always EXTRAARG.
(*) In OP_LOADKX and OP_NEWTABLE, the next 'instruction' is always
EXTRAARG.
(*) For comparisons, k specifies what condition the test should accept
(true or false).
@@ -375,4 +376,11 @@ LUAI_DDEC(const lu_byte luaP_opmodes[NUM_OPCODES];)
#define LFIELDS_PER_FLUSH 50
/*
** In OP_NEWTABLE, array sizes smaller than LIMTABSZ are represented
** directly in R(B). Otherwise, array size is given by
** (R(B) - LIMTABSZ) + EXTRAARG * LFIELDS_PER_FLUSH
*/
#define LIMTABSZ (MAXARG_B - LFIELDS_PER_FLUSH)
#endif