mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
Abstract out on-demand loading of FFI library.
This commit is contained in:
parent
61990cef05
commit
50d6883e60
@ -346,11 +346,7 @@ LJLIB_CF(jit_util_tracek)
|
||||
ir = &T->ir[ir->op1];
|
||||
}
|
||||
#if LJ_HASFFI
|
||||
if (ir->o == IR_KINT64 && !ctype_ctsG(G(L))) {
|
||||
ptrdiff_t oldtop = savestack(L, L->top);
|
||||
luaopen_ffi(L); /* Load FFI library on-demand. */
|
||||
L->top = restorestack(L, oldtop);
|
||||
}
|
||||
if (ir->o == IR_KINT64) ctype_loadffi(L);
|
||||
#endif
|
||||
lj_ir_kvalue(L, L->top-2, ir);
|
||||
setintV(L->top-1, (int32_t)irt_type(ir->t));
|
||||
|
@ -399,11 +399,7 @@ static int bcread_header(LexState *ls)
|
||||
if ((flags & BCDUMP_F_FFI)) {
|
||||
#if LJ_HASFFI
|
||||
lua_State *L = ls->L;
|
||||
if (!ctype_ctsG(G(L))) {
|
||||
ptrdiff_t oldtop = savestack(L, L->top);
|
||||
luaopen_ffi(L); /* Load FFI library on-demand. */
|
||||
L->top = restorestack(L, oldtop);
|
||||
}
|
||||
ctype_loadffi(L);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -389,6 +389,16 @@ static LJ_AINLINE CTState *ctype_cts(lua_State *L)
|
||||
return cts;
|
||||
}
|
||||
|
||||
/* Load FFI library on-demand. */
|
||||
#define ctype_loadffi(L) \
|
||||
do { \
|
||||
if (!ctype_ctsG(G(L))) { \
|
||||
ptrdiff_t oldtop = (char *)L->top - mref(L->stack, char); \
|
||||
luaopen_ffi(L); \
|
||||
L->top = (TValue *)(mref(L->stack, char) + oldtop); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Save and restore state of C type table. */
|
||||
#define LJ_CTYPE_SAVE(cts) CTState savects_ = *(cts)
|
||||
#define LJ_CTYPE_RESTORE(cts) \
|
||||
|
@ -118,11 +118,7 @@ static void lex_number(LexState *ls, TValue *tv)
|
||||
GCcdata *cd;
|
||||
lj_assertLS(fmt == STRSCAN_I64 || fmt == STRSCAN_U64 || fmt == STRSCAN_IMAG,
|
||||
"unexpected number format %d", fmt);
|
||||
if (!ctype_ctsG(G(L))) {
|
||||
ptrdiff_t oldtop = savestack(L, L->top);
|
||||
luaopen_ffi(L); /* Load FFI library on-demand. */
|
||||
L->top = restorestack(L, oldtop);
|
||||
}
|
||||
ctype_loadffi(L);
|
||||
if (fmt == STRSCAN_IMAG) {
|
||||
cd = lj_cdata_new_(L, CTID_COMPLEX_DOUBLE, 2*sizeof(double));
|
||||
((double *)cdataptr(cd))[0] = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user