diff options
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -1247,18 +1247,19 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1247 | vmbreak; | 1247 | vmbreak; |
1248 | } | 1248 | } |
1249 | vmcase(OP_NEWTABLE) { | 1249 | vmcase(OP_NEWTABLE) { |
1250 | int b = GETARG_B(i); | 1250 | int b = GETARG_B(i); /* log2(hash size) + 1 */ |
1251 | int c = GETARG_C(i); | 1251 | int c = GETARG_C(i); /* array size */ |
1252 | Table *t; | 1252 | Table *t; |
1253 | c = (c == 0) ? 0 : 1 << (c - 1); /* size is 2^c */ | 1253 | if (b > 0) |
1254 | if (b >= LIMTABSZ) | 1254 | b = 1 << (b - 1); /* size is 2^(b - 1) */ |
1255 | b += LFIELDS_PER_FLUSH * GETARG_Ax(*pc) - LIMTABSZ; | 1255 | if (TESTARG_k(i)) |
1256 | c += GETARG_Ax(*pc) * (MAXARG_C + 1); | ||
1256 | pc++; /* skip extra argument */ | 1257 | pc++; /* skip extra argument */ |
1257 | L->top = ci->top; /* correct top in case of GC */ | 1258 | L->top = ci->top; /* correct top in case of GC */ |
1258 | t = luaH_new(L); /* memory allocation */ | 1259 | t = luaH_new(L); /* memory allocation */ |
1259 | sethvalue2s(L, ra, t); | 1260 | sethvalue2s(L, ra, t); |
1260 | if (b != 0 || c != 0) | 1261 | if (b != 0 || c != 0) |
1261 | luaH_resize(L, t, b, c); /* idem */ | 1262 | luaH_resize(L, t, c, b); /* idem */ |
1262 | checkGC(L, ra + 1); | 1263 | checkGC(L, ra + 1); |
1263 | vmbreak; | 1264 | vmbreak; |
1264 | } | 1265 | } |
@@ -1763,18 +1764,17 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1763 | } | 1764 | } |
1764 | vmcase(OP_SETLIST) { | 1765 | vmcase(OP_SETLIST) { |
1765 | int n = GETARG_B(i); | 1766 | int n = GETARG_B(i); |
1766 | int c = GETARG_C(i); | 1767 | unsigned int last = GETARG_C(i); |
1767 | unsigned int last; | 1768 | Table *h = hvalue(s2v(ra)); |
1768 | Table *h; | ||
1769 | if (n == 0) | 1769 | if (n == 0) |
1770 | n = cast_int(L->top - ra) - 1; | 1770 | n = cast_int(L->top - ra) - 1; /* get up to the top */ |
1771 | else | 1771 | else |
1772 | L->top = ci->top; /* correct top in case of GC */ | 1772 | L->top = ci->top; /* correct top in case of GC */ |
1773 | if (c == 0) { | 1773 | last += n; |
1774 | c = GETARG_Ax(*pc); pc++; | 1774 | if (TESTARG_k(i)) { |
1775 | last += GETARG_Ax(*pc) * (MAXARG_C + 1); | ||
1776 | pc++; | ||
1775 | } | 1777 | } |
1776 | h = hvalue(s2v(ra)); | ||
1777 | last = ((c-1)*LFIELDS_PER_FLUSH) + n; | ||
1778 | if (last > luaH_realasize(h)) /* needs more space? */ | 1778 | if (last > luaH_realasize(h)) /* needs more space? */ |
1779 | luaH_resizearray(L, h, last); /* preallocate it at once */ | 1779 | luaH_resizearray(L, h, last); /* preallocate it at once */ |
1780 | for (; n > 0; n--) { | 1780 | for (; n > 0; n--) { |