From f11243be8a3564654a606a6bb94b184245d7d1fe Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Mon, 2 Mar 2026 18:45:40 +0000 Subject: [PATCH] Sprinkle `yk_is_interpreting` as appropriate. --- src/ldo.c | 30 ++++++++++++++++-------------- src/lvm.c | 4 +++- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/ldo.c b/src/ldo.c index a9e0c5a..0837ce4 100644 --- a/src/ldo.c +++ b/src/ldo.c @@ -574,15 +574,15 @@ int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, ci->top.p = func + 1 + fsize; /* top for new function */ lua_assert(ci->top.p <= L->stack_last.p); #ifdef USE_YK - // If this is a recursive call and we don't yet have a yk_location, - // create one now. - if (p->called && yk_location_is_null(p->yklocs[0])) { - p->yklocs[0] = yk_location_new(); + if (yk_is_interpreting()) { + // If this is a recursive call and we don't yet have a yk_location, + // create one now. + if (p->called && yk_location_is_null(p->yklocs[0])) { + p->yklocs[0] = yk_location_new(); #if YKLUA_DEBUG_STRS - yk_location_set_debug_str(&p->yklocs[0], p->instdebugstrs[0]); + yk_location_set_debug_str(&p->yklocs[0], p->instdebugstrs[0]); #endif - } else if (!p->called) { - p->called = true; + } } #endif ci->u.l.savedpc = p->code; /* starting point */ @@ -631,15 +631,17 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) { setnilvalue(s2v(L->top.p++)); /* complete missing arguments */ lua_assert(ci->top.p <= L->stack_last.p); #ifdef USE_YK - // If this is a recursive call and we don't yet have a yk_location, - // create one now. - if (p->called && yk_location_is_null(p->yklocs[0])) { - p->yklocs[0] = yk_location_new(); + if (yk_is_interpreting()) { + // If this is a recursive call and we don't yet have a yk_location, + // create one now. + if (p->called && yk_location_is_null(p->yklocs[0])) { + p->yklocs[0] = yk_location_new(); #if YKLUA_DEBUG_STRS - yk_location_set_debug_str(&p->yklocs[0], p->instdebugstrs[0]); + yk_location_set_debug_str(&p->yklocs[0], p->instdebugstrs[0]); #endif - } else if (!p->called) { - p->called = true; + } else if (!p->called) { + p->called = true; + } } #endif return ci; diff --git a/src/lvm.c b/src/lvm.c index 4768b84..978c995 100644 --- a/src/lvm.c +++ b/src/lvm.c @@ -1857,7 +1857,9 @@ void luaV_execute (lua_State *L, CallInfo *ci) { } ret: /* return from a Lua function */ #ifdef USE_YK - cl->p->called = false; + if (yk_is_interpreting()) { + cl->p->called = false; + } #endif if (ci->callstatus & CIST_FRESH) return; /* end this frame */