MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / luaV_execute

Function luaV_execute

xrepo/packages/l/lua/port/lua/src/lvm.c:1139–1838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

ccallFunction · 0.85
unrollFunction · 0.85
resumeFunction · 0.85

Calls 15

luaD_hookcallFunction · 0.85
luaG_getfunclineFunction · 0.85
luaV_finishgetFunction · 0.85
luaV_finishsetFunction · 0.85
luaH_resizeFunction · 0.85
luaV_shiftlFunction · 0.85
luaT_trybinTMFunction · 0.85
luaT_trybiniTMFunction · 0.85
luaT_trybinassocTMFunction · 0.85
luaV_objlenFunction · 0.85
luaF_newtbcupvalFunction · 0.85
luaV_equalobjFunction · 0.85

Tested by

no test coverage detected