diff options
author | Mike Pall <mike> | 2013-05-13 21:07:14 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2013-05-13 21:07:14 +0200 |
commit | 09ef8d10773f604452510c9fb3c32b3cdc424ae4 (patch) | |
tree | f488ec047c253d1f827f59849ada173de738fd4d | |
parent | acda75ad2cc30cff0a390ae0d232a098296e517e (diff) | |
download | luajit-09ef8d10773f604452510c9fb3c32b3cdc424ae4.tar.gz luajit-09ef8d10773f604452510c9fb3c32b3cdc424ae4.tar.bz2 luajit-09ef8d10773f604452510c9fb3c32b3cdc424ae4.zip |
FFI: Load FFI library on-demand for -jdump.
-rw-r--r-- | src/Makefile.dep | 6 | ||||
-rw-r--r-- | src/lib_jit.c | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/Makefile.dep b/src/Makefile.dep index 06ad20b1..376e2d2f 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep | |||
@@ -24,9 +24,9 @@ lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ | |||
24 | lj_strfmt.h lj_ff.h lj_ffdef.h lj_lib.h lj_libdef.h | 24 | lj_strfmt.h lj_ff.h lj_ffdef.h lj_lib.h lj_libdef.h |
25 | lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h \ | 25 | lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h \ |
26 | lj_obj.h lj_def.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \ | 26 | lj_obj.h lj_def.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \ |
27 | lj_bc.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_target.h \ | 27 | lj_state.h lj_bc.h lj_ctype.h lj_gc.h lj_ir.h lj_jit.h lj_ircall.h \ |
28 | lj_target_*.h lj_dispatch.h lj_vm.h lj_vmevent.h lj_lib.h luajit.h \ | 28 | lj_iropt.h lj_target.h lj_target_*.h lj_dispatch.h lj_vm.h \ |
29 | lj_libdef.h | 29 | lj_vmevent.h lj_lib.h luajit.h lj_libdef.h |
30 | lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ | 30 | lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ |
31 | lj_def.h lj_arch.h lj_lib.h lj_vm.h lj_libdef.h | 31 | lj_def.h lj_arch.h lj_lib.h lj_vm.h lj_libdef.h |
32 | lib_os.o: lib_os.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ | 32 | lib_os.o: lib_os.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ |
diff --git a/src/lib_jit.c b/src/lib_jit.c index 125b48ce..555e581c 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c | |||
@@ -16,7 +16,11 @@ | |||
16 | #include "lj_debug.h" | 16 | #include "lj_debug.h" |
17 | #include "lj_str.h" | 17 | #include "lj_str.h" |
18 | #include "lj_tab.h" | 18 | #include "lj_tab.h" |
19 | #include "lj_state.h" | ||
19 | #include "lj_bc.h" | 20 | #include "lj_bc.h" |
21 | #if LJ_HASFFI | ||
22 | #include "lj_ctype.h" | ||
23 | #endif | ||
20 | #if LJ_HASJIT | 24 | #if LJ_HASJIT |
21 | #include "lj_ir.h" | 25 | #include "lj_ir.h" |
22 | #include "lj_jit.h" | 26 | #include "lj_jit.h" |
@@ -332,6 +336,13 @@ LJLIB_CF(jit_util_tracek) | |||
332 | slot = ir->op2; | 336 | slot = ir->op2; |
333 | ir = &T->ir[ir->op1]; | 337 | ir = &T->ir[ir->op1]; |
334 | } | 338 | } |
339 | #if LJ_HASFFI | ||
340 | if (ir->o == IR_KINT64 && !ctype_ctsG(G(L))) { | ||
341 | ptrdiff_t oldtop = savestack(L, L->top); | ||
342 | luaopen_ffi(L); /* Load FFI library on-demand. */ | ||
343 | L->top = restorestack(L, oldtop); | ||
344 | } | ||
345 | #endif | ||
335 | lj_ir_kvalue(L, L->top-2, ir); | 346 | lj_ir_kvalue(L, L->top-2, ir); |
336 | setintV(L->top-1, (int32_t)irt_type(ir->t)); | 347 | setintV(L->top-1, (int32_t)irt_type(ir->t)); |
337 | if (slot == -1) | 348 | if (slot == -1) |