diff --git a/lib/dump.lua b/lib/dump.lua index 5c127ae9..fdb28833 100644 --- a/lib/dump.lua +++ b/lib/dump.lua @@ -295,6 +295,9 @@ local function formatk(tr, idx) s = format("[%p]", k) if s == "[0x00000000]" then s = "NULL" end end + elseif t == 21 then -- int64_t + s = sub(tostring(k), 1, -3) + if sub(s, 1, 1) ~= "-" then s = "+"..s end else s = tostring(k) -- For primitives. end diff --git a/src/Makefile.dep b/src/Makefile.dep index 31c54bcf..f3a2e710 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -91,7 +91,7 @@ lj_gdbjit.o: lj_gdbjit.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_dispatch.h lj_ir.o: lj_ir.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ - lj_bc.h lj_traceerr.h lj_lib.h + lj_bc.h lj_traceerr.h lj_ctype.h lj_cdata.h lj_lib.h lj_lex.o: lj_lex.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cdata.h lualib.h \ lj_lex.h lj_parse.h lj_char.h diff --git a/src/lj_ir.c b/src/lj_ir.c index 89be71aa..e2ec22b2 100644 --- a/src/lj_ir.c +++ b/src/lj_ir.c @@ -21,6 +21,10 @@ #include "lj_jit.h" #include "lj_iropt.h" #include "lj_trace.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#include "lj_cdata.h" +#endif #include "lj_lib.h" /* Some local macros to save typing. Undef'd at the end. */ @@ -380,8 +384,14 @@ void lj_ir_kvalue(lua_State *L, TValue *tv, const IRIns *ir) case IR_KGC: setgcV(L, tv, ir_kgc(ir), irt_toitype(ir->t)); break; case IR_KPTR: case IR_KNULL: setlightudV(tv, mref(ir->ptr, void)); break; case IR_KNUM: setnumV(tv, ir_knum(ir)->n); break; - /* NYI: use FFI int64_t. */ - case IR_KINT64: setnumV(tv, (lua_Number)(int64_t)ir_kint64(ir)->u64); break; +#if LJ_HASFFI + case IR_KINT64: { + GCcdata *cd = lj_cdata_new_(L, CTID_INT64, 8); + *(uint64_t *)cdataptr(cd) = ir_kint64(ir)->u64; + setcdataV(L, tv, cd); + break; + } +#endif default: lua_assert(0); break; } } diff --git a/src/lj_ir.h b/src/lj_ir.h index 4cf412cf..7d1e6daf 100644 --- a/src/lj_ir.h +++ b/src/lj_ir.h @@ -553,6 +553,7 @@ typedef union IRIns { #define ir_kstr(ir) (gco2str(ir_kgc((ir)))) #define ir_ktab(ir) (gco2tab(ir_kgc((ir)))) #define ir_kfunc(ir) (gco2func(ir_kgc((ir)))) +#define ir_kcdata(ir) (gco2cd(ir_kgc((ir)))) #define ir_knum(ir) check_exp((ir)->o == IR_KNUM, mref((ir)->ptr, cTValue)) #define ir_kint64(ir) check_exp((ir)->o == IR_KINT64, mref((ir)->ptr,cTValue)) #define ir_k64(ir) \