diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-10-04 16:01:53 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-10-04 16:01:53 -0300 |
commit | 5ee87acd6b920a6a122277cd817aea4cfd618671 (patch) | |
tree | 5e931c1db32c2be6378fde498ffcc5ee9dec0d6a /lvm.c | |
parent | 5d834bdf571ef3ee343b21fde2d49de1e4ea08b4 (diff) | |
download | lua-5ee87acd6b920a6a122277cd817aea4cfd618671.tar.gz lua-5ee87acd6b920a6a122277cd817aea4cfd618671.tar.bz2 lua-5ee87acd6b920a6a122277cd817aea4cfd618671.zip |
small optimization for boolean constants + new format for SETLIST opcode
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.13 2004/08/12 14:19:51 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.14 2004/09/15 20:39:42 roberto Exp $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -710,21 +710,19 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
710 | dojump(L, pc, GETARG_sBx(i)); | 710 | dojump(L, pc, GETARG_sBx(i)); |
711 | continue; | 711 | continue; |
712 | } | 712 | } |
713 | case OP_SETLIST: | 713 | case OP_SETLIST: { |
714 | case OP_SETLISTO: { | 714 | int n = GETARG_B(i); |
715 | int bc = GETARG_Bx(i); | 715 | int c = GETARG_C(i); |
716 | int n, last; | 716 | int last; |
717 | Table *h; | 717 | Table *h; |
718 | runtime_check(L, ttistable(ra)); | 718 | runtime_check(L, ttistable(ra)); |
719 | h = hvalue(ra); | 719 | h = hvalue(ra); |
720 | if (GET_OPCODE(i) == OP_SETLIST) | 720 | if (n == 0) { |
721 | n = (bc&(LFIELDS_PER_FLUSH-1)) + 1; | ||
722 | else { | ||
723 | n = L->top - ra - 1; | 721 | n = L->top - ra - 1; |
724 | L->top = L->ci->top; | 722 | L->top = L->ci->top; |
725 | } | 723 | } |
726 | bc &= ~(LFIELDS_PER_FLUSH-1); /* bc = bc - bc%FPF */ | 724 | if (c == 0) c = cast(int, *pc++); |
727 | last = bc + n + LUA_FIRSTINDEX - 1; | 725 | last = ((c-1)*LFIELDS_PER_FLUSH) + n + LUA_FIRSTINDEX - 1; |
728 | if (last > h->sizearray) /* needs more space? */ | 726 | if (last > h->sizearray) /* needs more space? */ |
729 | luaH_resize(L, h, last, h->lsizenode); /* pre-alloc it at once */ | 727 | luaH_resize(L, h, last, h->lsizenode); /* pre-alloc it at once */ |
730 | for (; n > 0; n--) { | 728 | for (; n > 0; n--) { |