mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +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];
|
ir = &T->ir[ir->op1];
|
||||||
}
|
}
|
||||||
#if LJ_HASFFI
|
#if LJ_HASFFI
|
||||||
if (ir->o == IR_KINT64 && !ctype_ctsG(G(L))) {
|
if (ir->o == IR_KINT64) ctype_loadffi(L);
|
||||||
ptrdiff_t oldtop = savestack(L, L->top);
|
|
||||||
luaopen_ffi(L); /* Load FFI library on-demand. */
|
|
||||||
L->top = restorestack(L, oldtop);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
lj_ir_kvalue(L, L->top-2, ir);
|
lj_ir_kvalue(L, L->top-2, ir);
|
||||||
setintV(L->top-1, (int32_t)irt_type(ir->t));
|
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 ((flags & BCDUMP_F_FFI)) {
|
||||||
#if LJ_HASFFI
|
#if LJ_HASFFI
|
||||||
lua_State *L = ls->L;
|
lua_State *L = ls->L;
|
||||||
if (!ctype_ctsG(G(L))) {
|
ctype_loadffi(L);
|
||||||
ptrdiff_t oldtop = savestack(L, L->top);
|
|
||||||
luaopen_ffi(L); /* Load FFI library on-demand. */
|
|
||||||
L->top = restorestack(L, oldtop);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -389,6 +389,16 @@ static LJ_AINLINE CTState *ctype_cts(lua_State *L)
|
|||||||
return cts;
|
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. */
|
/* Save and restore state of C type table. */
|
||||||
#define LJ_CTYPE_SAVE(cts) CTState savects_ = *(cts)
|
#define LJ_CTYPE_SAVE(cts) CTState savects_ = *(cts)
|
||||||
#define LJ_CTYPE_RESTORE(cts) \
|
#define LJ_CTYPE_RESTORE(cts) \
|
||||||
|
@ -118,11 +118,7 @@ static void lex_number(LexState *ls, TValue *tv)
|
|||||||
GCcdata *cd;
|
GCcdata *cd;
|
||||||
lj_assertLS(fmt == STRSCAN_I64 || fmt == STRSCAN_U64 || fmt == STRSCAN_IMAG,
|
lj_assertLS(fmt == STRSCAN_I64 || fmt == STRSCAN_U64 || fmt == STRSCAN_IMAG,
|
||||||
"unexpected number format %d", fmt);
|
"unexpected number format %d", fmt);
|
||||||
if (!ctype_ctsG(G(L))) {
|
ctype_loadffi(L);
|
||||||
ptrdiff_t oldtop = savestack(L, L->top);
|
|
||||||
luaopen_ffi(L); /* Load FFI library on-demand. */
|
|
||||||
L->top = restorestack(L, oldtop);
|
|
||||||
}
|
|
||||||
if (fmt == STRSCAN_IMAG) {
|
if (fmt == STRSCAN_IMAG) {
|
||||||
cd = lj_cdata_new_(L, CTID_COMPLEX_DOUBLE, 2*sizeof(double));
|
cd = lj_cdata_new_(L, CTID_COMPLEX_DOUBLE, 2*sizeof(double));
|
||||||
((double *)cdataptr(cd))[0] = 0;
|
((double *)cdataptr(cd))[0] = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user