| 1127 | |
| 1128 | |
| 1129 | void luaV_execute (lua_State *L, CallInfo *ci) { |
| 1130 | LClosure *cl; |
| 1131 | TValue *k; |
| 1132 | StkId base; |
| 1133 | const Instruction *pc; |
| 1134 | int trap; |
| 1135 | #if LUA_USE_JUMPTABLE |
| 1136 | #include "ljumptab.h" |
| 1137 | #endif |
| 1138 | startfunc: |
| 1139 | trap = L->hookmask; |
| 1140 | returning: /* trap already set */ |
| 1141 | cl = clLvalue(s2v(ci->func)); |
| 1142 | k = cl->p->k; |
| 1143 | pc = ci->u.l.savedpc; |
| 1144 | if (l_unlikely(trap)) { |
| 1145 | if (pc == cl->p->code) { /* first instruction (not resuming)? */ |
| 1146 | if (cl->p->is_vararg) |
| 1147 | trap = 0; /* hooks will start after VARARGPREP instruction */ |
| 1148 | else /* check 'call' hook */ |
| 1149 | luaD_hookcall(L, ci); |
| 1150 | } |
| 1151 | ci->u.l.trap = 1; /* assume trap is on, for now */ |
| 1152 | } |
| 1153 | base = ci->func + 1; |
| 1154 | /* main loop of interpreter */ |
| 1155 | for (;;) { |
| 1156 | Instruction i; /* instruction being executed */ |
| 1157 | StkId ra; /* instruction's A register */ |
| 1158 | vmfetch(); |
| 1159 | // low-level line tracing for debugging Lua |
| 1160 | // printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p))); |
| 1161 | lua_assert(base == ci->func + 1); |
| 1162 | lua_assert(base <= L->top && L->top < L->stack_last); |
| 1163 | /* invalidate top for instructions not expecting it */ |
| 1164 | lua_assert(isIT(i) || (cast_void(L->top = base), 1)); |
| 1165 | vmdispatch (GET_OPCODE(i)) { |
| 1166 | vmcase(OP_MOVE) { |
| 1167 | setobjs2s(L, ra, RB(i)); |
| 1168 | vmbreak; |
| 1169 | } |
| 1170 | vmcase(OP_LOADI) { |
| 1171 | lua_Integer b = GETARG_sBx(i); |
| 1172 | setivalue(s2v(ra), b); |
| 1173 | vmbreak; |
| 1174 | } |
| 1175 | vmcase(OP_LOADF) { |
| 1176 | int b = GETARG_sBx(i); |
| 1177 | setfltvalue(s2v(ra), cast_num(b)); |
| 1178 | vmbreak; |
| 1179 | } |
| 1180 | vmcase(OP_LOADK) { |
| 1181 | TValue *rb = k + GETARG_Bx(i); |
| 1182 | setobj2s(L, ra, rb); |
| 1183 | vmbreak; |
| 1184 | } |
| 1185 | vmcase(OP_LOADKX) { |
| 1186 | TValue *rb; |
no test coverage detected