MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / luaV_execute

Function luaV_execute

deps/lua/src/lvm.c:377–766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375
376
377void luaV_execute (lua_State *L, int nexeccalls) {
378 LClosure *cl;
379 StkId base;
380 TValue *k;
381 const Instruction *pc;
382 reentry: /* entry point */
383 lua_assert(isLua(L->ci));
384 pc = L->savedpc;
385 cl = &clvalue(L->ci->func)->l;
386 base = L->base;
387 k = cl->p->k;
388 /* main loop of interpreter */
389 for (;;) {
390 const Instruction i = *pc++;
391 StkId ra;
392 if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&
393 (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
394 traceexec(L, pc);
395 if (L->status == LUA_YIELD) { /* did hook yield? */
396 L->savedpc = pc - 1;
397 return;
398 }
399 base = L->base;
400 }
401 /* warning!! several calls may realloc the stack and invalidate `ra' */
402 ra = RA(i);
403 lua_assert(base == L->base && L->base == L->ci->base);
404 lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
405 lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
406 switch (GET_OPCODE(i)) {
407 case OP_MOVE: {
408 setobjs2s(L, ra, RB(i));
409 continue;
410 }
411 case OP_LOADK: {
412 setobj2s(L, ra, KBx(i));
413 continue;
414 }
415 case OP_LOADBOOL: {
416 setbvalue(ra, GETARG_B(i));
417 if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
418 continue;
419 }
420 case OP_LOADNIL: {
421 TValue *rb = RB(i);
422 do {
423 setnilvalue(rb--);
424 } while (rb >= ra);
425 continue;
426 }
427 case OP_GETUPVAL: {
428 int b = GETARG_B(i);
429 setobj2s(L, ra, cl->upvals[b]->v);
430 continue;
431 }
432 case OP_GETGLOBAL: {
433 TValue g;
434 TValue *rb = KBx(i);

Callers 2

luaD_callFunction · 0.85
resumeFunction · 0.85

Calls 15

traceexecFunction · 0.85
luaG_checkopenopFunction · 0.85
luaV_gettableFunction · 0.85
luaV_settableFunction · 0.85
luaH_newFunction · 0.85
luaO_fb2intFunction · 0.85
ArithFunction · 0.85
luaH_getnFunction · 0.85
call_binTMFunction · 0.85
luaG_typeerrorFunction · 0.85
luaV_concatFunction · 0.85
luaV_lessthanFunction · 0.85

Tested by

no test coverage detected