@@ -562,6 +562,18 @@ int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func,
562562 setnilvalue (s2v (func + narg1 )); /* complete missing arguments */
563563 ci -> top .p = func + 1 + fsize ; /* top for new function */
564564 lua_assert (ci -> top .p <= L -> stack_last .p );
565+ #ifdef USE_YK
566+ // If this is a recursive call and we don't yet have a yk_location,
567+ // create one now.
568+ if (p -> called && yk_location_is_null (p -> yklocs [0 ])) {
569+ p -> yklocs [0 ] = yk_location_new ();
570+ #if YKLUA_DEBUG_STRS
571+ yk_location_set_debug_str (& p -> yklocs [0 ], p -> instdebugstrs [0 ]);
572+ #endif
573+ } else if (!p -> called ) {
574+ p -> called = true;
575+ }
576+ #endif
565577 ci -> u .l .savedpc = p -> code ; /* starting point */
566578 ci -> callstatus |= CIST_TAIL ;
567579 L -> top .p = func + narg1 ; /* set top */
@@ -606,6 +618,18 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) {
606618 for (; narg < nfixparams ; narg ++ )
607619 setnilvalue (s2v (L -> top .p ++ )); /* complete missing arguments */
608620 lua_assert (ci -> top .p <= L -> stack_last .p );
621+ #ifdef USE_YK
622+ // If this is a recursive call and we don't yet have a yk_location,
623+ // create one now.
624+ if (p -> called && yk_location_is_null (p -> yklocs [0 ])) {
625+ p -> yklocs [0 ] = yk_location_new ();
626+ #if YKLUA_DEBUG_STRS
627+ yk_location_set_debug_str (& p -> yklocs [0 ], p -> instdebugstrs [0 ]);
628+ #endif
629+ } else if (!p -> called ) {
630+ p -> called = true;
631+ }
632+ #endif
609633 return ci ;
610634 }
611635 default : { /* not a function */
0 commit comments