From 1fb4d539254b67e7e35ed698250c66d1edff0e08 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 12 Jul 2019 16:13:50 -0300 Subject: 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.) --- lopcodes.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lopcodes.h') diff --git a/lopcodes.h b/lopcodes.h index 7bbbb0e5..0b23fa6f 100644 --- a/lopcodes.h +++ b/lopcodes.h @@ -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 -- cgit v1.2.3-55-g6feb