diff options
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 39 |
1 files changed, 20 insertions, 19 deletions
@@ -235,11 +235,11 @@ static int forprep (lua_State *L, StkId ra) { | |||
235 | } | 235 | } |
236 | else { /* try making all values floats */ | 236 | else { /* try making all values floats */ |
237 | lua_Number init; lua_Number limit; lua_Number step; | 237 | lua_Number init; lua_Number limit; lua_Number step; |
238 | if (unlikely(!tonumber(plimit, &limit))) | 238 | if (l_unlikely(!tonumber(plimit, &limit))) |
239 | luaG_forerror(L, plimit, "limit"); | 239 | luaG_forerror(L, plimit, "limit"); |
240 | if (unlikely(!tonumber(pstep, &step))) | 240 | if (l_unlikely(!tonumber(pstep, &step))) |
241 | luaG_forerror(L, pstep, "step"); | 241 | luaG_forerror(L, pstep, "step"); |
242 | if (unlikely(!tonumber(pinit, &init))) | 242 | if (l_unlikely(!tonumber(pinit, &init))) |
243 | luaG_forerror(L, pinit, "initial value"); | 243 | luaG_forerror(L, pinit, "initial value"); |
244 | if (step == 0) | 244 | if (step == 0) |
245 | luaG_runerror(L, "'for' step is zero"); | 245 | luaG_runerror(L, "'for' step is zero"); |
@@ -292,7 +292,7 @@ void luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val, | |||
292 | if (slot == NULL) { /* 't' is not a table? */ | 292 | if (slot == NULL) { /* 't' is not a table? */ |
293 | lua_assert(!ttistable(t)); | 293 | lua_assert(!ttistable(t)); |
294 | tm = luaT_gettmbyobj(L, t, TM_INDEX); | 294 | tm = luaT_gettmbyobj(L, t, TM_INDEX); |
295 | if (unlikely(notm(tm))) | 295 | if (l_unlikely(notm(tm))) |
296 | luaG_typeerror(L, t, "index"); /* no metamethod */ | 296 | luaG_typeerror(L, t, "index"); /* no metamethod */ |
297 | /* else will try the metamethod */ | 297 | /* else will try the metamethod */ |
298 | } | 298 | } |
@@ -346,7 +346,7 @@ void luaV_finishset (lua_State *L, const TValue *t, TValue *key, | |||
346 | } | 346 | } |
347 | else { /* not a table; check metamethod */ | 347 | else { /* not a table; check metamethod */ |
348 | tm = luaT_gettmbyobj(L, t, TM_NEWINDEX); | 348 | tm = luaT_gettmbyobj(L, t, TM_NEWINDEX); |
349 | if (unlikely(notm(tm))) | 349 | if (l_unlikely(notm(tm))) |
350 | luaG_typeerror(L, t, "index"); | 350 | luaG_typeerror(L, t, "index"); |
351 | } | 351 | } |
352 | /* try the metamethod */ | 352 | /* try the metamethod */ |
@@ -651,7 +651,7 @@ void luaV_concat (lua_State *L, int total) { | |||
651 | /* collect total length and number of strings */ | 651 | /* collect total length and number of strings */ |
652 | for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) { | 652 | for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) { |
653 | size_t l = vslen(s2v(top - n - 1)); | 653 | size_t l = vslen(s2v(top - n - 1)); |
654 | if (unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) | 654 | if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) |
655 | luaG_runerror(L, "string length overflow"); | 655 | luaG_runerror(L, "string length overflow"); |
656 | tl += l; | 656 | tl += l; |
657 | } | 657 | } |
@@ -695,7 +695,7 @@ void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) { | |||
695 | } | 695 | } |
696 | default: { /* try metamethod */ | 696 | default: { /* try metamethod */ |
697 | tm = luaT_gettmbyobj(L, rb, TM_LEN); | 697 | tm = luaT_gettmbyobj(L, rb, TM_LEN); |
698 | if (unlikely(notm(tm))) /* no metamethod? */ | 698 | if (l_unlikely(notm(tm))) /* no metamethod? */ |
699 | luaG_typeerror(L, rb, "get length of"); | 699 | luaG_typeerror(L, rb, "get length of"); |
700 | break; | 700 | break; |
701 | } | 701 | } |
@@ -711,7 +711,7 @@ void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) { | |||
711 | ** otherwise 'floor(q) == trunc(q) - 1'. | 711 | ** otherwise 'floor(q) == trunc(q) - 1'. |
712 | */ | 712 | */ |
713 | lua_Integer luaV_idiv (lua_State *L, lua_Integer m, lua_Integer n) { | 713 | lua_Integer luaV_idiv (lua_State *L, lua_Integer m, lua_Integer n) { |
714 | if (unlikely(l_castS2U(n) + 1u <= 1u)) { /* special cases: -1 or 0 */ | 714 | if (l_unlikely(l_castS2U(n) + 1u <= 1u)) { /* special cases: -1 or 0 */ |
715 | if (n == 0) | 715 | if (n == 0) |
716 | luaG_runerror(L, "attempt to divide by zero"); | 716 | luaG_runerror(L, "attempt to divide by zero"); |
717 | return intop(-, 0, m); /* n==-1; avoid overflow with 0x80000...//-1 */ | 717 | return intop(-, 0, m); /* n==-1; avoid overflow with 0x80000...//-1 */ |
@@ -731,7 +731,7 @@ lua_Integer luaV_idiv (lua_State *L, lua_Integer m, lua_Integer n) { | |||
731 | ** about luaV_idiv.) | 731 | ** about luaV_idiv.) |
732 | */ | 732 | */ |
733 | lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) { | 733 | lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) { |
734 | if (unlikely(l_castS2U(n) + 1u <= 1u)) { /* special cases: -1 or 0 */ | 734 | if (l_unlikely(l_castS2U(n) + 1u <= 1u)) { /* special cases: -1 or 0 */ |
735 | if (n == 0) | 735 | if (n == 0) |
736 | luaG_runerror(L, "attempt to perform 'n%%0'"); | 736 | luaG_runerror(L, "attempt to perform 'n%%0'"); |
737 | return 0; /* m % -1 == 0; avoid overflow with 0x80000...%-1 */ | 737 | return 0; /* m % -1 == 0; avoid overflow with 0x80000...%-1 */ |
@@ -1049,7 +1049,8 @@ void luaV_finishOp (lua_State *L) { | |||
1049 | #define updatebase(ci) (base = ci->func + 1) | 1049 | #define updatebase(ci) (base = ci->func + 1) |
1050 | 1050 | ||
1051 | 1051 | ||
1052 | #define updatestack(ci) { if (trap) { updatebase(ci); ra = RA(i); } } | 1052 | #define updatestack(ci) \ |
1053 | { if (l_unlikely(trap)) { updatebase(ci); ra = RA(i); } } | ||
1053 | 1054 | ||
1054 | 1055 | ||
1055 | /* | 1056 | /* |
@@ -1107,7 +1108,7 @@ void luaV_finishOp (lua_State *L) { | |||
1107 | 1108 | ||
1108 | /* fetch an instruction and prepare its execution */ | 1109 | /* fetch an instruction and prepare its execution */ |
1109 | #define vmfetch() { \ | 1110 | #define vmfetch() { \ |
1110 | if (trap) { /* stack reallocation or hooks? */ \ | 1111 | if (l_unlikely(trap)) { /* stack reallocation or hooks? */ \ |
1111 | trap = luaG_traceexec(L, pc); /* handle hooks */ \ | 1112 | trap = luaG_traceexec(L, pc); /* handle hooks */ \ |
1112 | updatebase(ci); /* correct stack */ \ | 1113 | updatebase(ci); /* correct stack */ \ |
1113 | } \ | 1114 | } \ |
@@ -1135,7 +1136,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1135 | cl = clLvalue(s2v(ci->func)); | 1136 | cl = clLvalue(s2v(ci->func)); |
1136 | k = cl->p->k; | 1137 | k = cl->p->k; |
1137 | pc = ci->u.l.savedpc; | 1138 | pc = ci->u.l.savedpc; |
1138 | if (trap) { | 1139 | if (l_unlikely(trap)) { |
1139 | if (pc == cl->p->code) { /* first instruction (not resuming)? */ | 1140 | if (pc == cl->p->code) { /* first instruction (not resuming)? */ |
1140 | if (cl->p->is_vararg) | 1141 | if (cl->p->is_vararg) |
1141 | trap = 0; /* hooks will start after VARARGPREP instruction */ | 1142 | trap = 0; /* hooks will start after VARARGPREP instruction */ |
@@ -1678,23 +1679,23 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1678 | goto ret; | 1679 | goto ret; |
1679 | } | 1680 | } |
1680 | vmcase(OP_RETURN0) { | 1681 | vmcase(OP_RETURN0) { |
1681 | if (L->hookmask) { | 1682 | if (l_unlikely(L->hookmask)) { |
1682 | L->top = ra; | 1683 | L->top = ra; |
1683 | savepc(ci); | 1684 | savepc(ci); |
1684 | luaD_poscall(L, ci, 0); /* no hurry... */ | 1685 | luaD_poscall(L, ci, 0); /* no hurry... */ |
1685 | trap = 1; | 1686 | trap = 1; |
1686 | } | 1687 | } |
1687 | else { /* do the 'poscall' here */ | 1688 | else { /* do the 'poscall' here */ |
1688 | int nres = ci->nresults; | 1689 | int nres; |
1689 | L->ci = ci->previous; /* back to caller */ | 1690 | L->ci = ci->previous; /* back to caller */ |
1690 | L->top = base - 1; | 1691 | L->top = base - 1; |
1691 | while (nres-- > 0) | 1692 | for (nres = ci->nresults; l_unlikely(nres > 0); nres--) |
1692 | setnilvalue(s2v(L->top++)); /* all results are nil */ | 1693 | setnilvalue(s2v(L->top++)); /* all results are nil */ |
1693 | } | 1694 | } |
1694 | goto ret; | 1695 | goto ret; |
1695 | } | 1696 | } |
1696 | vmcase(OP_RETURN1) { | 1697 | vmcase(OP_RETURN1) { |
1697 | if (L->hookmask) { | 1698 | if (l_unlikely(L->hookmask)) { |
1698 | L->top = ra + 1; | 1699 | L->top = ra + 1; |
1699 | savepc(ci); | 1700 | savepc(ci); |
1700 | luaD_poscall(L, ci, 1); /* no hurry... */ | 1701 | luaD_poscall(L, ci, 1); /* no hurry... */ |
@@ -1708,8 +1709,8 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1708 | else { | 1709 | else { |
1709 | setobjs2s(L, base - 1, ra); /* at least this result */ | 1710 | setobjs2s(L, base - 1, ra); /* at least this result */ |
1710 | L->top = base; | 1711 | L->top = base; |
1711 | while (--nres > 0) /* complete missing results */ | 1712 | for (; l_unlikely(nres > 1); nres--) |
1712 | setnilvalue(s2v(L->top++)); | 1713 | setnilvalue(s2v(L->top++)); /* complete missing results */ |
1713 | } | 1714 | } |
1714 | } | 1715 | } |
1715 | ret: /* return from a Lua function */ | 1716 | ret: /* return from a Lua function */ |
@@ -1812,7 +1813,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1812 | } | 1813 | } |
1813 | vmcase(OP_VARARGPREP) { | 1814 | vmcase(OP_VARARGPREP) { |
1814 | ProtectNT(luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p)); | 1815 | ProtectNT(luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p)); |
1815 | if (trap) { | 1816 | if (l_unlikely(trap)) { /* previous "Protect" updated trap */ |
1816 | luaD_hookcall(L, ci); | 1817 | luaD_hookcall(L, ci); |
1817 | L->oldpc = 1; /* next opcode will be seen as a "new" line */ | 1818 | L->oldpc = 1; /* next opcode will be seen as a "new" line */ |
1818 | } | 1819 | } |