mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
Allow linking to already compiled functions.
This commit is contained in:
parent
b11eeab906
commit
bbe7d818d9
@ -1734,22 +1734,40 @@ static void check_call_unroll(jit_State *J)
|
||||
}
|
||||
}
|
||||
|
||||
static void rec_func_lua(jit_State *J)
|
||||
/* Record Lua function setup. */
|
||||
static void rec_func_setup(jit_State *J)
|
||||
{
|
||||
GCproto *pt = J->pt;
|
||||
BCReg s, numparams = pt->numparams;
|
||||
if ((pt->flags & PROTO_NO_JIT))
|
||||
lj_trace_err(J, LJ_TRERR_CJITOFF);
|
||||
lua_assert(!(pt->flags & PROTO_IS_VARARG));
|
||||
if (J->baseslot + pt->framesize >= LJ_MAX_JSLOTS)
|
||||
lj_trace_err(J, LJ_TRERR_STACKOV);
|
||||
/* Fill up missing args with nil. */
|
||||
while (J->maxslot < pt->numparams)
|
||||
J->base[J->maxslot++] = TREF_NIL;
|
||||
/* Fill up missing parameters with nil. */
|
||||
for (s = J->maxslot; s < numparams; s++)
|
||||
J->base[s] = TREF_NIL;
|
||||
/* The remaining slots should never be read before they are written. */
|
||||
J->maxslot = pt->numparams;
|
||||
J->maxslot = numparams;
|
||||
}
|
||||
|
||||
/* Record entry to a Lua function. */
|
||||
static void rec_func_lua(jit_State *J)
|
||||
{
|
||||
rec_func_setup(J);
|
||||
check_call_unroll(J);
|
||||
}
|
||||
|
||||
/* Record entry to an already compiled function. */
|
||||
static void rec_func_jit(jit_State *J, TraceNo lnk)
|
||||
{
|
||||
rec_func_setup(J);
|
||||
J->instunroll = 0; /* Cannot continue across a compiled function. */
|
||||
if (J->pc == J->startpc && J->framedepth + J->retdepth == 0)
|
||||
lnk = J->curtrace; /* Can form an extra tail-recursive loop. */
|
||||
rec_stop(J, lnk); /* Link to the function. */
|
||||
}
|
||||
|
||||
/* -- Record allocations -------------------------------------------------- */
|
||||
|
||||
static TRef rec_tnew(jit_State *J, uint32_t ah)
|
||||
@ -2127,9 +2145,8 @@ void lj_record_ins(jit_State *J)
|
||||
case BC_FUNCF:
|
||||
rec_func_lua(J);
|
||||
break;
|
||||
|
||||
case BC_JFUNCF:
|
||||
lj_trace_err(J, LJ_TRERR_NYILNKF);
|
||||
rec_func_jit(J, rc);
|
||||
break;
|
||||
|
||||
case BC_FUNCV:
|
||||
|
@ -23,7 +23,6 @@ TREDEF(BADTYPE, "bad argument type")
|
||||
TREDEF(CJITOFF, "call to JIT-disabled function")
|
||||
TREDEF(CUNROLL, "call unroll limit reached")
|
||||
TREDEF(NYIRECU, "NYI: recursive calls")
|
||||
TREDEF(NYILNKF, "NYI: linking/patching function calls")
|
||||
TREDEF(NYIVF, "NYI: vararg function")
|
||||
TREDEF(NYICF, "NYI: C function %p")
|
||||
TREDEF(NYIFF, "NYI: FastFunc %s")
|
||||
|
Loading…
Reference in New Issue
Block a user