immunio 0.15.4 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +0 -27
- data/ext/immunio/Rakefile +9 -0
- data/lib/immunio/plugins/active_record.rb +1 -1
- data/lib/immunio/plugins/active_record_relation.rb +1 -1
- data/lib/immunio/plugins/environment_reporter.rb +20 -0
- data/lib/immunio/rufus_lua_ext/ref.rb +1 -3
- data/lib/immunio/version.rb +1 -1
- data/lib/immunio/vm.rb +1 -2
- data/lua-hooks/Makefile +97 -0
- data/lua-hooks/ext/all.c +41 -52
- data/lua-hooks/ext/all.o +0 -0
- data/lua-hooks/ext/libinjection/libinjection_html5.o +0 -0
- data/lua-hooks/ext/libinjection/libinjection_sqli.o +0 -0
- data/lua-hooks/ext/libinjection/libinjection_xss.o +0 -0
- data/lua-hooks/ext/libinjection/lualib.c +2 -2
- data/lua-hooks/ext/lpeg/lpcap.c +2 -2
- data/lua-hooks/ext/lpeg/lpcap.o +0 -0
- data/lua-hooks/ext/lpeg/lpcode.c +2 -2
- data/lua-hooks/ext/lpeg/lpcode.h +1 -1
- data/lua-hooks/ext/lpeg/lpcode.o +0 -0
- data/lua-hooks/ext/lpeg/lpprint.o +0 -0
- data/lua-hooks/ext/lpeg/lptree.c +2 -2
- data/lua-hooks/ext/lpeg/lptypes.h +1 -1
- data/lua-hooks/ext/lpeg/lpvm.c +2 -2
- data/lua-hooks/ext/lpeg/lpvm.o +0 -0
- data/lua-hooks/ext/lua-cmsgpack/lua_cmsgpack.c +16 -3
- data/lua-hooks/ext/lua-snapshot/snapshot.c +14 -7
- data/lua-hooks/ext/luajit/COPYRIGHT +56 -0
- data/lua-hooks/ext/luajit/Makefile +159 -0
- data/lua-hooks/ext/luajit/README +16 -0
- data/lua-hooks/ext/luajit/doc/bluequad-print.css +166 -0
- data/lua-hooks/ext/luajit/doc/bluequad.css +325 -0
- data/lua-hooks/ext/luajit/doc/changes.html +804 -0
- data/lua-hooks/ext/luajit/doc/contact.html +104 -0
- data/lua-hooks/ext/luajit/doc/ext_c_api.html +189 -0
- data/lua-hooks/ext/luajit/doc/ext_ffi.html +332 -0
- data/lua-hooks/ext/luajit/doc/ext_ffi_api.html +570 -0
- data/lua-hooks/ext/luajit/doc/ext_ffi_semantics.html +1261 -0
- data/lua-hooks/ext/luajit/doc/ext_ffi_tutorial.html +603 -0
- data/lua-hooks/ext/luajit/doc/ext_jit.html +201 -0
- data/lua-hooks/ext/luajit/doc/ext_profiler.html +365 -0
- data/lua-hooks/ext/luajit/doc/extensions.html +448 -0
- data/lua-hooks/ext/luajit/doc/faq.html +186 -0
- data/lua-hooks/ext/luajit/doc/img/contact.png +0 -0
- data/lua-hooks/ext/luajit/doc/install.html +659 -0
- data/lua-hooks/ext/luajit/doc/luajit.html +236 -0
- data/lua-hooks/ext/luajit/doc/running.html +309 -0
- data/lua-hooks/ext/luajit/doc/status.html +118 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_arm.h +456 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_arm.lua +1125 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_arm64.h +518 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_arm64.lua +1166 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_mips.h +416 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_mips.lua +953 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_ppc.h +419 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_ppc.lua +1919 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_proto.h +83 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_x64.lua +12 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_x86.h +471 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_x86.lua +1945 -0
- data/lua-hooks/ext/luajit/dynasm/dynasm.lua +1094 -0
- data/lua-hooks/ext/luajit/etc/luajit.1 +88 -0
- data/lua-hooks/ext/luajit/etc/luajit.pc +25 -0
- data/lua-hooks/ext/luajit/src/Makefile +697 -0
- data/lua-hooks/ext/luajit/src/Makefile.dep +244 -0
- data/lua-hooks/ext/luajit/src/host/README +4 -0
- data/lua-hooks/ext/luajit/src/host/buildvm +0 -0
- data/lua-hooks/ext/luajit/src/host/buildvm.c +518 -0
- data/lua-hooks/ext/luajit/src/host/buildvm.h +105 -0
- data/lua-hooks/ext/luajit/src/host/buildvm.o +0 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_arch.h +7449 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_asm.c +345 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_asm.o +0 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_fold.c +229 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_fold.o +0 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_lib.c +457 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_lib.o +0 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_libbc.h +45 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_peobj.c +368 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_peobj.o +0 -0
- data/lua-hooks/ext/luajit/src/host/genlibbc.lua +197 -0
- data/lua-hooks/ext/luajit/src/host/genminilua.lua +428 -0
- data/lua-hooks/ext/luajit/src/host/minilua +0 -0
- data/lua-hooks/ext/luajit/src/host/minilua.c +7770 -0
- data/lua-hooks/ext/luajit/src/host/minilua.o +0 -0
- data/lua-hooks/ext/luajit/src/jit/bc.lua +190 -0
- data/lua-hooks/ext/luajit/src/jit/bcsave.lua +661 -0
- data/lua-hooks/ext/luajit/src/jit/dis_arm.lua +689 -0
- data/lua-hooks/ext/luajit/src/jit/dis_mips.lua +428 -0
- data/lua-hooks/ext/luajit/src/jit/dis_mipsel.lua +17 -0
- data/lua-hooks/ext/luajit/src/jit/dis_ppc.lua +591 -0
- data/lua-hooks/ext/luajit/src/jit/dis_x64.lua +17 -0
- data/lua-hooks/ext/luajit/src/jit/dis_x86.lua +838 -0
- data/lua-hooks/ext/luajit/src/jit/dump.lua +706 -0
- data/lua-hooks/ext/luajit/src/jit/p.lua +310 -0
- data/lua-hooks/ext/luajit/src/jit/v.lua +170 -0
- data/lua-hooks/ext/luajit/src/jit/vmdef.lua +362 -0
- data/lua-hooks/ext/luajit/src/jit/zone.lua +45 -0
- data/lua-hooks/ext/{lua → luajit/src}/lauxlib.h +10 -17
- data/lua-hooks/ext/luajit/src/lib_aux.c +356 -0
- data/lua-hooks/ext/luajit/src/lib_aux.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_aux_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_base.c +664 -0
- data/lua-hooks/ext/luajit/src/lib_base.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_base_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_bit.c +180 -0
- data/lua-hooks/ext/luajit/src/lib_bit.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_bit_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_debug.c +405 -0
- data/lua-hooks/ext/luajit/src/lib_debug.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_debug_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_ffi.c +872 -0
- data/lua-hooks/ext/luajit/src/lib_ffi.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_ffi_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_init.c +55 -0
- data/lua-hooks/ext/luajit/src/lib_init.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_init_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_io.c +541 -0
- data/lua-hooks/ext/luajit/src/lib_io.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_io_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_jit.c +767 -0
- data/lua-hooks/ext/luajit/src/lib_jit.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_jit_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_math.c +230 -0
- data/lua-hooks/ext/luajit/src/lib_math.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_math_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_os.c +292 -0
- data/lua-hooks/ext/luajit/src/lib_os.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_os_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_package.c +610 -0
- data/lua-hooks/ext/luajit/src/lib_package.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_package_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_string.c +752 -0
- data/lua-hooks/ext/luajit/src/lib_string.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_string_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_table.c +307 -0
- data/lua-hooks/ext/luajit/src/lib_table.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_table_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/libluajit.a +0 -0
- data/lua-hooks/ext/luajit/src/libluajit.so +0 -0
- data/lua-hooks/ext/luajit/src/lj.supp +26 -0
- data/lua-hooks/ext/luajit/src/lj_alloc.c +1398 -0
- data/lua-hooks/ext/luajit/src/lj_alloc.h +17 -0
- data/lua-hooks/ext/luajit/src/lj_alloc.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_alloc_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_api.c +1210 -0
- data/lua-hooks/ext/luajit/src/lj_api.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_api_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_arch.h +509 -0
- data/lua-hooks/ext/luajit/src/lj_asm.c +2278 -0
- data/lua-hooks/ext/luajit/src/lj_asm.h +17 -0
- data/lua-hooks/ext/luajit/src/lj_asm.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_asm_arm.h +2217 -0
- data/lua-hooks/ext/luajit/src/lj_asm_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_asm_mips.h +1833 -0
- data/lua-hooks/ext/luajit/src/lj_asm_ppc.h +2015 -0
- data/lua-hooks/ext/luajit/src/lj_asm_x86.h +2634 -0
- data/lua-hooks/ext/luajit/src/lj_bc.c +14 -0
- data/lua-hooks/ext/luajit/src/lj_bc.h +265 -0
- data/lua-hooks/ext/luajit/src/lj_bc.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_bc_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_bcdef.h +220 -0
- data/lua-hooks/ext/luajit/src/lj_bcdump.h +68 -0
- data/lua-hooks/ext/luajit/src/lj_bcread.c +457 -0
- data/lua-hooks/ext/luajit/src/lj_bcread.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_bcread_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_bcwrite.c +361 -0
- data/lua-hooks/ext/luajit/src/lj_bcwrite.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_bcwrite_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_buf.c +234 -0
- data/lua-hooks/ext/luajit/src/lj_buf.h +105 -0
- data/lua-hooks/ext/luajit/src/lj_buf.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_buf_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_carith.c +429 -0
- data/lua-hooks/ext/luajit/src/lj_carith.h +37 -0
- data/lua-hooks/ext/luajit/src/lj_carith.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_carith_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ccall.c +984 -0
- data/lua-hooks/ext/luajit/src/lj_ccall.h +178 -0
- data/lua-hooks/ext/luajit/src/lj_ccall.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ccall_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ccallback.c +712 -0
- data/lua-hooks/ext/luajit/src/lj_ccallback.h +25 -0
- data/lua-hooks/ext/luajit/src/lj_ccallback.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ccallback_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_cconv.c +752 -0
- data/lua-hooks/ext/luajit/src/lj_cconv.h +70 -0
- data/lua-hooks/ext/luajit/src/lj_cconv.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_cconv_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_cdata.c +288 -0
- data/lua-hooks/ext/luajit/src/lj_cdata.h +76 -0
- data/lua-hooks/ext/luajit/src/lj_cdata.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_cdata_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_char.c +43 -0
- data/lua-hooks/ext/luajit/src/lj_char.h +42 -0
- data/lua-hooks/ext/luajit/src/lj_char.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_char_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_clib.c +418 -0
- data/lua-hooks/ext/luajit/src/lj_clib.h +29 -0
- data/lua-hooks/ext/luajit/src/lj_clib.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_clib_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_cparse.c +1862 -0
- data/lua-hooks/ext/luajit/src/lj_cparse.h +65 -0
- data/lua-hooks/ext/luajit/src/lj_cparse.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_cparse_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_crecord.c +1834 -0
- data/lua-hooks/ext/luajit/src/lj_crecord.h +38 -0
- data/lua-hooks/ext/luajit/src/lj_crecord.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_crecord_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ctype.c +635 -0
- data/lua-hooks/ext/luajit/src/lj_ctype.h +461 -0
- data/lua-hooks/ext/luajit/src/lj_ctype.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ctype_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_debug.c +699 -0
- data/lua-hooks/ext/luajit/src/lj_debug.h +65 -0
- data/lua-hooks/ext/luajit/src/lj_debug.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_debug_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_def.h +365 -0
- data/lua-hooks/ext/luajit/src/lj_dispatch.c +557 -0
- data/lua-hooks/ext/luajit/src/lj_dispatch.h +138 -0
- data/lua-hooks/ext/luajit/src/lj_dispatch.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_dispatch_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_emit_arm.h +356 -0
- data/lua-hooks/ext/luajit/src/lj_emit_mips.h +211 -0
- data/lua-hooks/ext/luajit/src/lj_emit_ppc.h +238 -0
- data/lua-hooks/ext/luajit/src/lj_emit_x86.h +462 -0
- data/lua-hooks/ext/luajit/src/lj_err.c +794 -0
- data/lua-hooks/ext/luajit/src/lj_err.h +41 -0
- data/lua-hooks/ext/luajit/src/lj_err.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_err_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_errmsg.h +190 -0
- data/lua-hooks/ext/luajit/src/lj_ff.h +18 -0
- data/lua-hooks/ext/luajit/src/lj_ffdef.h +209 -0
- data/lua-hooks/ext/luajit/src/lj_ffrecord.c +1247 -0
- data/lua-hooks/ext/luajit/src/lj_ffrecord.h +24 -0
- data/lua-hooks/ext/luajit/src/lj_ffrecord.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ffrecord_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_folddef.h +1138 -0
- data/lua-hooks/ext/luajit/src/lj_frame.h +259 -0
- data/lua-hooks/ext/luajit/src/lj_func.c +185 -0
- data/lua-hooks/ext/luajit/src/lj_func.h +24 -0
- data/lua-hooks/ext/luajit/src/lj_func.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_func_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_gc.c +845 -0
- data/lua-hooks/ext/luajit/src/lj_gc.h +134 -0
- data/lua-hooks/ext/luajit/src/lj_gc.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_gc_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_gdbjit.c +787 -0
- data/lua-hooks/ext/luajit/src/lj_gdbjit.h +22 -0
- data/lua-hooks/ext/luajit/src/lj_gdbjit.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_gdbjit_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ir.c +505 -0
- data/lua-hooks/ext/luajit/src/lj_ir.h +577 -0
- data/lua-hooks/ext/luajit/src/lj_ir.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ir_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ircall.h +321 -0
- data/lua-hooks/ext/luajit/src/lj_iropt.h +161 -0
- data/lua-hooks/ext/luajit/src/lj_jit.h +440 -0
- data/lua-hooks/ext/luajit/src/lj_lex.c +482 -0
- data/lua-hooks/ext/luajit/src/lj_lex.h +86 -0
- data/lua-hooks/ext/luajit/src/lj_lex.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_lex_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_lib.c +303 -0
- data/lua-hooks/ext/luajit/src/lj_lib.h +115 -0
- data/lua-hooks/ext/luajit/src/lj_lib.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_lib_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_libdef.h +414 -0
- data/lua-hooks/ext/luajit/src/lj_load.c +168 -0
- data/lua-hooks/ext/luajit/src/lj_load.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_load_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_mcode.c +386 -0
- data/lua-hooks/ext/luajit/src/lj_mcode.h +30 -0
- data/lua-hooks/ext/luajit/src/lj_mcode.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_mcode_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_meta.c +477 -0
- data/lua-hooks/ext/luajit/src/lj_meta.h +38 -0
- data/lua-hooks/ext/luajit/src/lj_meta.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_meta_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_obj.c +50 -0
- data/lua-hooks/ext/luajit/src/lj_obj.h +976 -0
- data/lua-hooks/ext/luajit/src/lj_obj.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_obj_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_dce.c +78 -0
- data/lua-hooks/ext/luajit/src/lj_opt_dce.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_dce_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_fold.c +2488 -0
- data/lua-hooks/ext/luajit/src/lj_opt_fold.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_fold_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_loop.c +449 -0
- data/lua-hooks/ext/luajit/src/lj_opt_loop.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_loop_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_mem.c +935 -0
- data/lua-hooks/ext/luajit/src/lj_opt_mem.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_mem_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_narrow.c +652 -0
- data/lua-hooks/ext/luajit/src/lj_opt_narrow.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_narrow_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_sink.c +245 -0
- data/lua-hooks/ext/luajit/src/lj_opt_sink.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_sink_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_split.c +856 -0
- data/lua-hooks/ext/luajit/src/lj_opt_split.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_split_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_parse.c +2725 -0
- data/lua-hooks/ext/luajit/src/lj_parse.h +18 -0
- data/lua-hooks/ext/luajit/src/lj_parse.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_parse_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_profile.c +368 -0
- data/lua-hooks/ext/luajit/src/lj_profile.h +21 -0
- data/lua-hooks/ext/luajit/src/lj_profile.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_profile_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_recdef.h +270 -0
- data/lua-hooks/ext/luajit/src/lj_record.c +2554 -0
- data/lua-hooks/ext/luajit/src/lj_record.h +45 -0
- data/lua-hooks/ext/luajit/src/lj_record.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_record_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_snap.c +870 -0
- data/lua-hooks/ext/luajit/src/lj_snap.h +34 -0
- data/lua-hooks/ext/luajit/src/lj_snap.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_snap_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_state.c +300 -0
- data/lua-hooks/ext/luajit/src/lj_state.h +35 -0
- data/lua-hooks/ext/luajit/src/lj_state.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_state_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_str.c +197 -0
- data/lua-hooks/ext/luajit/src/lj_str.h +27 -0
- data/lua-hooks/ext/luajit/src/lj_str.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_str_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_strfmt.c +554 -0
- data/lua-hooks/ext/luajit/src/lj_strfmt.h +125 -0
- data/lua-hooks/ext/luajit/src/lj_strfmt.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_strfmt_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_strscan.c +547 -0
- data/lua-hooks/ext/luajit/src/lj_strscan.h +39 -0
- data/lua-hooks/ext/luajit/src/lj_strscan.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_strscan_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_tab.c +666 -0
- data/lua-hooks/ext/luajit/src/lj_tab.h +73 -0
- data/lua-hooks/ext/luajit/src/lj_tab.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_tab_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_target.h +164 -0
- data/lua-hooks/ext/luajit/src/lj_target_arm.h +270 -0
- data/lua-hooks/ext/luajit/src/lj_target_arm64.h +97 -0
- data/lua-hooks/ext/luajit/src/lj_target_mips.h +260 -0
- data/lua-hooks/ext/luajit/src/lj_target_ppc.h +280 -0
- data/lua-hooks/ext/luajit/src/lj_target_x86.h +345 -0
- data/lua-hooks/ext/luajit/src/lj_trace.c +859 -0
- data/lua-hooks/ext/luajit/src/lj_trace.h +54 -0
- data/lua-hooks/ext/luajit/src/lj_trace.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_trace_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_traceerr.h +63 -0
- data/lua-hooks/ext/luajit/src/lj_udata.c +34 -0
- data/lua-hooks/ext/luajit/src/lj_udata.h +14 -0
- data/lua-hooks/ext/luajit/src/lj_udata.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_udata_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_vm.S +2730 -0
- data/lua-hooks/ext/luajit/src/lj_vm.h +114 -0
- data/lua-hooks/ext/luajit/src/lj_vm.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_vm_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_vmevent.c +58 -0
- data/lua-hooks/ext/luajit/src/lj_vmevent.h +59 -0
- data/lua-hooks/ext/luajit/src/lj_vmevent.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_vmevent_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_vmmath.c +152 -0
- data/lua-hooks/ext/luajit/src/lj_vmmath.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_vmmath_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/ljamalg.c +96 -0
- data/lua-hooks/ext/{lua → luajit/src}/lua.h +12 -7
- data/lua-hooks/ext/luajit/src/lua.hpp +9 -0
- data/lua-hooks/ext/luajit/src/luaconf.h +156 -0
- data/lua-hooks/ext/luajit/src/luajit +0 -0
- data/lua-hooks/ext/luajit/src/luajit.c +570 -0
- data/lua-hooks/ext/luajit/src/luajit.h +79 -0
- data/lua-hooks/ext/luajit/src/luajit.o +0 -0
- data/lua-hooks/ext/luajit/src/lualib.h +43 -0
- data/lua-hooks/ext/luajit/src/msvcbuild.bat +114 -0
- data/lua-hooks/ext/luajit/src/ps4build.bat +103 -0
- data/lua-hooks/ext/luajit/src/psvitabuild.bat +93 -0
- data/lua-hooks/ext/luajit/src/vm_arm.dasc +4585 -0
- data/lua-hooks/ext/luajit/src/vm_arm64.dasc +3764 -0
- data/lua-hooks/ext/luajit/src/vm_mips.dasc +4355 -0
- data/lua-hooks/ext/luajit/src/vm_ppc.dasc +5252 -0
- data/lua-hooks/ext/luajit/src/vm_x64.dasc +4902 -0
- data/lua-hooks/ext/luajit/src/vm_x86.dasc +5710 -0
- data/lua-hooks/ext/luajit/src/xb1build.bat +101 -0
- data/lua-hooks/ext/luajit/src/xedkbuild.bat +92 -0
- data/lua-hooks/ext/luautf8/lutf8lib.c +3 -3
- data/lua-hooks/lib/boot.lua +37 -2
- metadata +372 -69
- data/lua-hooks/ext/bitop/README +0 -22
- data/lua-hooks/ext/bitop/bit.c +0 -189
- data/lua-hooks/ext/extconf.rb +0 -38
- data/lua-hooks/ext/lua/COPYRIGHT +0 -34
- data/lua-hooks/ext/lua/lapi.c +0 -1087
- data/lua-hooks/ext/lua/lapi.h +0 -16
- data/lua-hooks/ext/lua/lauxlib.c +0 -652
- data/lua-hooks/ext/lua/lbaselib.c +0 -659
- data/lua-hooks/ext/lua/lcode.c +0 -831
- data/lua-hooks/ext/lua/lcode.h +0 -76
- data/lua-hooks/ext/lua/ldblib.c +0 -398
- data/lua-hooks/ext/lua/ldebug.c +0 -638
- data/lua-hooks/ext/lua/ldebug.h +0 -33
- data/lua-hooks/ext/lua/ldo.c +0 -519
- data/lua-hooks/ext/lua/ldo.h +0 -57
- data/lua-hooks/ext/lua/ldump.c +0 -164
- data/lua-hooks/ext/lua/lfunc.c +0 -174
- data/lua-hooks/ext/lua/lfunc.h +0 -34
- data/lua-hooks/ext/lua/lgc.c +0 -710
- data/lua-hooks/ext/lua/lgc.h +0 -110
- data/lua-hooks/ext/lua/linit.c +0 -38
- data/lua-hooks/ext/lua/liolib.c +0 -556
- data/lua-hooks/ext/lua/llex.c +0 -463
- data/lua-hooks/ext/lua/llex.h +0 -81
- data/lua-hooks/ext/lua/llimits.h +0 -128
- data/lua-hooks/ext/lua/lmathlib.c +0 -263
- data/lua-hooks/ext/lua/lmem.c +0 -86
- data/lua-hooks/ext/lua/lmem.h +0 -49
- data/lua-hooks/ext/lua/loadlib.c +0 -705
- data/lua-hooks/ext/lua/loadlib_rel.c +0 -760
- data/lua-hooks/ext/lua/lobject.c +0 -214
- data/lua-hooks/ext/lua/lobject.h +0 -381
- data/lua-hooks/ext/lua/lopcodes.c +0 -102
- data/lua-hooks/ext/lua/lopcodes.h +0 -268
- data/lua-hooks/ext/lua/loslib.c +0 -243
- data/lua-hooks/ext/lua/lparser.c +0 -1339
- data/lua-hooks/ext/lua/lparser.h +0 -82
- data/lua-hooks/ext/lua/lstate.c +0 -214
- data/lua-hooks/ext/lua/lstate.h +0 -169
- data/lua-hooks/ext/lua/lstring.c +0 -111
- data/lua-hooks/ext/lua/lstring.h +0 -31
- data/lua-hooks/ext/lua/lstrlib.c +0 -871
- data/lua-hooks/ext/lua/ltable.c +0 -588
- data/lua-hooks/ext/lua/ltable.h +0 -40
- data/lua-hooks/ext/lua/ltablib.c +0 -287
- data/lua-hooks/ext/lua/ltm.c +0 -75
- data/lua-hooks/ext/lua/ltm.h +0 -54
- data/lua-hooks/ext/lua/lua.c +0 -392
- data/lua-hooks/ext/lua/lua.def +0 -131
- data/lua-hooks/ext/lua/lua.rc +0 -28
- data/lua-hooks/ext/lua/lua_dll.rc +0 -26
- data/lua-hooks/ext/lua/luac.c +0 -200
- data/lua-hooks/ext/lua/luac.rc +0 -1
- data/lua-hooks/ext/lua/luaconf.h +0 -763
- data/lua-hooks/ext/lua/luaconf.h.in +0 -724
- data/lua-hooks/ext/lua/luaconf.h.orig +0 -763
- data/lua-hooks/ext/lua/lualib.h +0 -53
- data/lua-hooks/ext/lua/lundump.c +0 -227
- data/lua-hooks/ext/lua/lundump.h +0 -36
- data/lua-hooks/ext/lua/lvm.c +0 -767
- data/lua-hooks/ext/lua/lvm.h +0 -36
- data/lua-hooks/ext/lua/lzio.c +0 -82
- data/lua-hooks/ext/lua/lzio.h +0 -67
- data/lua-hooks/ext/lua/print.c +0 -227
@@ -0,0 +1,38 @@
|
|
1
|
+
/*
|
2
|
+
** Metamethod handling.
|
3
|
+
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
|
4
|
+
*/
|
5
|
+
|
6
|
+
#ifndef _LJ_META_H
|
7
|
+
#define _LJ_META_H
|
8
|
+
|
9
|
+
#include "lj_obj.h"
|
10
|
+
|
11
|
+
/* Metamethod handling */
|
12
|
+
LJ_FUNC void lj_meta_init(lua_State *L);
|
13
|
+
LJ_FUNC cTValue *lj_meta_cache(GCtab *mt, MMS mm, GCstr *name);
|
14
|
+
LJ_FUNC cTValue *lj_meta_lookup(lua_State *L, cTValue *o, MMS mm);
|
15
|
+
#if LJ_HASFFI
|
16
|
+
LJ_FUNC int lj_meta_tailcall(lua_State *L, cTValue *tv);
|
17
|
+
#endif
|
18
|
+
|
19
|
+
#define lj_meta_fastg(g, mt, mm) \
|
20
|
+
((mt) == NULL ? NULL : ((mt)->nomm & (1u<<(mm))) ? NULL : \
|
21
|
+
lj_meta_cache(mt, mm, mmname_str(g, mm)))
|
22
|
+
#define lj_meta_fast(L, mt, mm) lj_meta_fastg(G(L), mt, mm)
|
23
|
+
|
24
|
+
/* C helpers for some instructions, called from assembler VM. */
|
25
|
+
LJ_FUNCA cTValue *lj_meta_tget(lua_State *L, cTValue *o, cTValue *k);
|
26
|
+
LJ_FUNCA TValue *lj_meta_tset(lua_State *L, cTValue *o, cTValue *k);
|
27
|
+
LJ_FUNCA TValue *lj_meta_arith(lua_State *L, TValue *ra, cTValue *rb,
|
28
|
+
cTValue *rc, BCReg op);
|
29
|
+
LJ_FUNCA TValue *lj_meta_cat(lua_State *L, TValue *top, int left);
|
30
|
+
LJ_FUNCA TValue * LJ_FASTCALL lj_meta_len(lua_State *L, cTValue *o);
|
31
|
+
LJ_FUNCA TValue *lj_meta_equal(lua_State *L, GCobj *o1, GCobj *o2, int ne);
|
32
|
+
LJ_FUNCA TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins);
|
33
|
+
LJ_FUNCA TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op);
|
34
|
+
LJ_FUNCA void lj_meta_istype(lua_State *L, BCReg ra, BCReg tp);
|
35
|
+
LJ_FUNCA void lj_meta_call(lua_State *L, TValue *func, TValue *top);
|
36
|
+
LJ_FUNCA void LJ_FASTCALL lj_meta_for(lua_State *L, TValue *o);
|
37
|
+
|
38
|
+
#endif
|
Binary file
|
Binary file
|
@@ -0,0 +1,50 @@
|
|
1
|
+
/*
|
2
|
+
** Miscellaneous object handling.
|
3
|
+
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
|
4
|
+
*/
|
5
|
+
|
6
|
+
#define lj_obj_c
|
7
|
+
#define LUA_CORE
|
8
|
+
|
9
|
+
#include "lj_obj.h"
|
10
|
+
|
11
|
+
/* Object type names. */
|
12
|
+
LJ_DATADEF const char *const lj_obj_typename[] = { /* ORDER LUA_T */
|
13
|
+
"no value", "nil", "boolean", "userdata", "number", "string",
|
14
|
+
"table", "function", "userdata", "thread", "proto", "cdata"
|
15
|
+
};
|
16
|
+
|
17
|
+
LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */
|
18
|
+
"nil", "boolean", "boolean", "userdata", "string", "upval", "thread",
|
19
|
+
"proto", "function", "trace", "cdata", "table", "userdata", "number"
|
20
|
+
};
|
21
|
+
|
22
|
+
/* Compare two objects without calling metamethods. */
|
23
|
+
int LJ_FASTCALL lj_obj_equal(cTValue *o1, cTValue *o2)
|
24
|
+
{
|
25
|
+
if (itype(o1) == itype(o2)) {
|
26
|
+
if (tvispri(o1))
|
27
|
+
return 1;
|
28
|
+
if (!tvisnum(o1))
|
29
|
+
return gcrefeq(o1->gcr, o2->gcr);
|
30
|
+
} else if (!tvisnumber(o1) || !tvisnumber(o2)) {
|
31
|
+
return 0;
|
32
|
+
}
|
33
|
+
return numberVnum(o1) == numberVnum(o2);
|
34
|
+
}
|
35
|
+
|
36
|
+
/* Return pointer to object or its object data. */
|
37
|
+
const void * LJ_FASTCALL lj_obj_ptr(cTValue *o)
|
38
|
+
{
|
39
|
+
if (tvisudata(o))
|
40
|
+
return uddata(udataV(o));
|
41
|
+
else if (tvislightud(o))
|
42
|
+
return lightudV(o);
|
43
|
+
else if (LJ_HASFFI && tviscdata(o))
|
44
|
+
return cdataptr(cdataV(o));
|
45
|
+
else if (tvisgcv(o))
|
46
|
+
return gcV(o);
|
47
|
+
else
|
48
|
+
return NULL;
|
49
|
+
}
|
50
|
+
|
@@ -0,0 +1,976 @@
|
|
1
|
+
/*
|
2
|
+
** LuaJIT VM tags, values and objects.
|
3
|
+
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
|
4
|
+
**
|
5
|
+
** Portions taken verbatim or adapted from the Lua interpreter.
|
6
|
+
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
7
|
+
*/
|
8
|
+
|
9
|
+
#ifndef _LJ_OBJ_H
|
10
|
+
#define _LJ_OBJ_H
|
11
|
+
|
12
|
+
#include "lua.h"
|
13
|
+
#include "lj_def.h"
|
14
|
+
#include "lj_arch.h"
|
15
|
+
|
16
|
+
/* -- Memory references (32 bit address space) ---------------------------- */
|
17
|
+
|
18
|
+
/* Memory and GC object sizes. */
|
19
|
+
typedef uint32_t MSize;
|
20
|
+
#if LJ_GC64
|
21
|
+
typedef uint64_t GCSize;
|
22
|
+
#else
|
23
|
+
typedef uint32_t GCSize;
|
24
|
+
#endif
|
25
|
+
|
26
|
+
/* Memory reference */
|
27
|
+
typedef struct MRef {
|
28
|
+
#if LJ_GC64
|
29
|
+
uint64_t ptr64; /* True 64 bit pointer. */
|
30
|
+
#else
|
31
|
+
uint32_t ptr32; /* Pseudo 32 bit pointer. */
|
32
|
+
#endif
|
33
|
+
} MRef;
|
34
|
+
|
35
|
+
#if LJ_GC64
|
36
|
+
#define mref(r, t) ((t *)(void *)(r).ptr64)
|
37
|
+
|
38
|
+
#define setmref(r, p) ((r).ptr64 = (uint64_t)(void *)(p))
|
39
|
+
#define setmrefr(r, v) ((r).ptr64 = (v).ptr64)
|
40
|
+
#else
|
41
|
+
#define mref(r, t) ((t *)(void *)(uintptr_t)(r).ptr32)
|
42
|
+
|
43
|
+
#define setmref(r, p) ((r).ptr32 = (uint32_t)(uintptr_t)(void *)(p))
|
44
|
+
#define setmrefr(r, v) ((r).ptr32 = (v).ptr32)
|
45
|
+
#endif
|
46
|
+
|
47
|
+
/* -- GC object references (32 bit address space) ------------------------- */
|
48
|
+
|
49
|
+
/* GCobj reference */
|
50
|
+
typedef struct GCRef {
|
51
|
+
#if LJ_GC64
|
52
|
+
uint64_t gcptr64; /* True 64 bit pointer. */
|
53
|
+
#else
|
54
|
+
uint32_t gcptr32; /* Pseudo 32 bit pointer. */
|
55
|
+
#endif
|
56
|
+
} GCRef;
|
57
|
+
|
58
|
+
/* Common GC header for all collectable objects. */
|
59
|
+
#define GCHeader GCRef nextgc; uint8_t marked; uint8_t gct
|
60
|
+
/* This occupies 6 bytes, so use the next 2 bytes for non-32 bit fields. */
|
61
|
+
|
62
|
+
#if LJ_GC64
|
63
|
+
#define gcref(r) ((GCobj *)(r).gcptr64)
|
64
|
+
#define gcrefp(r, t) ((t *)(void *)(r).gcptr64)
|
65
|
+
#define gcrefu(r) ((r).gcptr64)
|
66
|
+
#define gcrefeq(r1, r2) ((r1).gcptr64 == (r2).gcptr64)
|
67
|
+
|
68
|
+
#define setgcref(r, gc) ((r).gcptr64 = (uint64_t)&(gc)->gch)
|
69
|
+
#define setgcreft(r, gc, it) \
|
70
|
+
(r).gcptr64 = (uint64_t)&(gc)->gch | (((uint64_t)(it)) << 47)
|
71
|
+
#define setgcrefp(r, p) ((r).gcptr64 = (uint64_t)(p))
|
72
|
+
#define setgcrefnull(r) ((r).gcptr64 = 0)
|
73
|
+
#define setgcrefr(r, v) ((r).gcptr64 = (v).gcptr64)
|
74
|
+
#else
|
75
|
+
#define gcref(r) ((GCobj *)(uintptr_t)(r).gcptr32)
|
76
|
+
#define gcrefp(r, t) ((t *)(void *)(uintptr_t)(r).gcptr32)
|
77
|
+
#define gcrefu(r) ((r).gcptr32)
|
78
|
+
#define gcrefeq(r1, r2) ((r1).gcptr32 == (r2).gcptr32)
|
79
|
+
|
80
|
+
#define setgcref(r, gc) ((r).gcptr32 = (uint32_t)(uintptr_t)&(gc)->gch)
|
81
|
+
#define setgcrefp(r, p) ((r).gcptr32 = (uint32_t)(uintptr_t)(p))
|
82
|
+
#define setgcrefnull(r) ((r).gcptr32 = 0)
|
83
|
+
#define setgcrefr(r, v) ((r).gcptr32 = (v).gcptr32)
|
84
|
+
#endif
|
85
|
+
|
86
|
+
#define gcnext(gc) (gcref((gc)->gch.nextgc))
|
87
|
+
|
88
|
+
/* IMPORTANT NOTE:
|
89
|
+
**
|
90
|
+
** All uses of the setgcref* macros MUST be accompanied with a write barrier.
|
91
|
+
**
|
92
|
+
** This is to ensure the integrity of the incremental GC. The invariant
|
93
|
+
** to preserve is that a black object never points to a white object.
|
94
|
+
** I.e. never store a white object into a field of a black object.
|
95
|
+
**
|
96
|
+
** It's ok to LEAVE OUT the write barrier ONLY in the following cases:
|
97
|
+
** - The source is not a GC object (NULL).
|
98
|
+
** - The target is a GC root. I.e. everything in global_State.
|
99
|
+
** - The target is a lua_State field (threads are never black).
|
100
|
+
** - The target is a stack slot, see setgcV et al.
|
101
|
+
** - The target is an open upvalue, i.e. pointing to a stack slot.
|
102
|
+
** - The target is a newly created object (i.e. marked white). But make
|
103
|
+
** sure nothing invokes the GC inbetween.
|
104
|
+
** - The target and the source are the same object (self-reference).
|
105
|
+
** - The target already contains the object (e.g. moving elements around).
|
106
|
+
**
|
107
|
+
** The most common case is a store to a stack slot. All other cases where
|
108
|
+
** a barrier has been omitted are annotated with a NOBARRIER comment.
|
109
|
+
**
|
110
|
+
** The same logic applies for stores to table slots (array part or hash
|
111
|
+
** part). ALL uses of lj_tab_set* require a barrier for the stored value
|
112
|
+
** *and* the stored key, based on the above rules. In practice this means
|
113
|
+
** a barrier is needed if *either* of the key or value are a GC object.
|
114
|
+
**
|
115
|
+
** It's ok to LEAVE OUT the write barrier in the following special cases:
|
116
|
+
** - The stored value is nil. The key doesn't matter because it's either
|
117
|
+
** not resurrected or lj_tab_newkey() will take care of the key barrier.
|
118
|
+
** - The key doesn't matter if the *previously* stored value is guaranteed
|
119
|
+
** to be non-nil (because the key is kept alive in the table).
|
120
|
+
** - The key doesn't matter if it's guaranteed not to be part of the table,
|
121
|
+
** since lj_tab_newkey() takes care of the key barrier. This applies
|
122
|
+
** trivially to new tables, but watch out for resurrected keys. Storing
|
123
|
+
** a nil value leaves the key in the table!
|
124
|
+
**
|
125
|
+
** In case of doubt use lj_gc_anybarriert() as it's rather cheap. It's used
|
126
|
+
** by the interpreter for all table stores.
|
127
|
+
**
|
128
|
+
** Note: In contrast to Lua's GC, LuaJIT's GC does *not* specially mark
|
129
|
+
** dead keys in tables. The reference is left in, but it's guaranteed to
|
130
|
+
** be never dereferenced as long as the value is nil. It's ok if the key is
|
131
|
+
** freed or if any object subsequently gets the same address.
|
132
|
+
**
|
133
|
+
** Not destroying dead keys helps to keep key hash slots stable. This avoids
|
134
|
+
** specialization back-off for HREFK when a value flips between nil and
|
135
|
+
** non-nil and the GC gets in the way. It also allows safely hoisting
|
136
|
+
** HREF/HREFK across GC steps. Dead keys are only removed if a table is
|
137
|
+
** resized (i.e. by NEWREF) and xREF must not be CSEd across a resize.
|
138
|
+
**
|
139
|
+
** The trade-off is that a write barrier for tables must take the key into
|
140
|
+
** account, too. Implicitly resurrecting the key by storing a non-nil value
|
141
|
+
** may invalidate the incremental GC invariant.
|
142
|
+
*/
|
143
|
+
|
144
|
+
/* -- Common type definitions --------------------------------------------- */
|
145
|
+
|
146
|
+
/* Types for handling bytecodes. Need this here, details in lj_bc.h. */
|
147
|
+
typedef uint32_t BCIns; /* Bytecode instruction. */
|
148
|
+
typedef uint32_t BCPos; /* Bytecode position. */
|
149
|
+
typedef uint32_t BCReg; /* Bytecode register. */
|
150
|
+
typedef int32_t BCLine; /* Bytecode line number. */
|
151
|
+
|
152
|
+
/* Internal assembler functions. Never call these directly from C. */
|
153
|
+
typedef void (*ASMFunction)(void);
|
154
|
+
|
155
|
+
/* Resizable string buffer. Need this here, details in lj_buf.h. */
|
156
|
+
typedef struct SBuf {
|
157
|
+
MRef p; /* String buffer pointer. */
|
158
|
+
MRef e; /* String buffer end pointer. */
|
159
|
+
MRef b; /* String buffer base. */
|
160
|
+
MRef L; /* lua_State, used for buffer resizing. */
|
161
|
+
} SBuf;
|
162
|
+
|
163
|
+
/* -- Tags and values ----------------------------------------------------- */
|
164
|
+
|
165
|
+
/* Frame link. */
|
166
|
+
typedef union {
|
167
|
+
int32_t ftsz; /* Frame type and size of previous frame. */
|
168
|
+
MRef pcr; /* Or PC for Lua frames. */
|
169
|
+
} FrameLink;
|
170
|
+
|
171
|
+
/* Tagged value. */
|
172
|
+
typedef LJ_ALIGN(8) union TValue {
|
173
|
+
uint64_t u64; /* 64 bit pattern overlaps number. */
|
174
|
+
lua_Number n; /* Number object overlaps split tag/value object. */
|
175
|
+
#if LJ_GC64
|
176
|
+
GCRef gcr; /* GCobj reference with tag. */
|
177
|
+
int64_t it64;
|
178
|
+
struct {
|
179
|
+
LJ_ENDIAN_LOHI(
|
180
|
+
int32_t i; /* Integer value. */
|
181
|
+
, uint32_t it; /* Internal object tag. Must overlap MSW of number. */
|
182
|
+
)
|
183
|
+
};
|
184
|
+
#else
|
185
|
+
struct {
|
186
|
+
LJ_ENDIAN_LOHI(
|
187
|
+
union {
|
188
|
+
GCRef gcr; /* GCobj reference (if any). */
|
189
|
+
int32_t i; /* Integer value. */
|
190
|
+
};
|
191
|
+
, uint32_t it; /* Internal object tag. Must overlap MSW of number. */
|
192
|
+
)
|
193
|
+
};
|
194
|
+
#endif
|
195
|
+
#if LJ_FR2
|
196
|
+
int64_t ftsz; /* Frame type and size of previous frame, or PC. */
|
197
|
+
#else
|
198
|
+
struct {
|
199
|
+
LJ_ENDIAN_LOHI(
|
200
|
+
GCRef func; /* Function for next frame (or dummy L). */
|
201
|
+
, FrameLink tp; /* Link to previous frame. */
|
202
|
+
)
|
203
|
+
} fr;
|
204
|
+
#endif
|
205
|
+
struct {
|
206
|
+
LJ_ENDIAN_LOHI(
|
207
|
+
uint32_t lo; /* Lower 32 bits of number. */
|
208
|
+
, uint32_t hi; /* Upper 32 bits of number. */
|
209
|
+
)
|
210
|
+
} u32;
|
211
|
+
} TValue;
|
212
|
+
|
213
|
+
typedef const TValue cTValue;
|
214
|
+
|
215
|
+
#define tvref(r) (mref(r, TValue))
|
216
|
+
|
217
|
+
/* More external and GCobj tags for internal objects. */
|
218
|
+
#define LAST_TT LUA_TTHREAD
|
219
|
+
#define LUA_TPROTO (LAST_TT+1)
|
220
|
+
#define LUA_TCDATA (LAST_TT+2)
|
221
|
+
|
222
|
+
/* Internal object tags.
|
223
|
+
**
|
224
|
+
** Format for 32 bit GC references (!LJ_GC64):
|
225
|
+
**
|
226
|
+
** Internal tags overlap the MSW of a number object (must be a double).
|
227
|
+
** Interpreted as a double these are special NaNs. The FPU only generates
|
228
|
+
** one type of NaN (0xfff8_0000_0000_0000). So MSWs > 0xfff80000 are available
|
229
|
+
** for use as internal tags. Small negative numbers are used to shorten the
|
230
|
+
** encoding of type comparisons (reg/mem against sign-ext. 8 bit immediate).
|
231
|
+
**
|
232
|
+
** ---MSW---.---LSW---
|
233
|
+
** primitive types | itype | |
|
234
|
+
** lightuserdata | itype | void * | (32 bit platforms)
|
235
|
+
** lightuserdata |ffff| void * | (64 bit platforms, 47 bit pointers)
|
236
|
+
** GC objects | itype | GCRef |
|
237
|
+
** int (LJ_DUALNUM)| itype | int |
|
238
|
+
** number -------double------
|
239
|
+
**
|
240
|
+
** Format for 64 bit GC references (LJ_GC64):
|
241
|
+
**
|
242
|
+
** The upper 13 bits must be 1 (0xfff8...) for a special NaN. The next
|
243
|
+
** 4 bits hold the internal tag. The lowest 47 bits either hold a pointer,
|
244
|
+
** a zero-extended 32 bit integer or all bits set to 1 for primitive types.
|
245
|
+
**
|
246
|
+
** ------MSW------.------LSW------
|
247
|
+
** primitive types |1..1|itype|1..................1|
|
248
|
+
** GC objects/lightud |1..1|itype|-------GCRef--------|
|
249
|
+
** int (LJ_DUALNUM) |1..1|itype|0..0|-----int-------|
|
250
|
+
** number ------------double-------------
|
251
|
+
**
|
252
|
+
** ORDER LJ_T
|
253
|
+
** Primitive types nil/false/true must be first, lightuserdata next.
|
254
|
+
** GC objects are at the end, table/userdata must be lowest.
|
255
|
+
** Also check lj_ir.h for similar ordering constraints.
|
256
|
+
*/
|
257
|
+
#define LJ_TNIL (~0u)
|
258
|
+
#define LJ_TFALSE (~1u)
|
259
|
+
#define LJ_TTRUE (~2u)
|
260
|
+
#define LJ_TLIGHTUD (~3u)
|
261
|
+
#define LJ_TSTR (~4u)
|
262
|
+
#define LJ_TUPVAL (~5u)
|
263
|
+
#define LJ_TTHREAD (~6u)
|
264
|
+
#define LJ_TPROTO (~7u)
|
265
|
+
#define LJ_TFUNC (~8u)
|
266
|
+
#define LJ_TTRACE (~9u)
|
267
|
+
#define LJ_TCDATA (~10u)
|
268
|
+
#define LJ_TTAB (~11u)
|
269
|
+
#define LJ_TUDATA (~12u)
|
270
|
+
/* This is just the canonical number type used in some places. */
|
271
|
+
#define LJ_TNUMX (~13u)
|
272
|
+
|
273
|
+
/* Integers have itype == LJ_TISNUM doubles have itype < LJ_TISNUM */
|
274
|
+
#if LJ_64 && !LJ_GC64
|
275
|
+
#define LJ_TISNUM 0xfffeffffu
|
276
|
+
#else
|
277
|
+
#define LJ_TISNUM LJ_TNUMX
|
278
|
+
#endif
|
279
|
+
#define LJ_TISTRUECOND LJ_TFALSE
|
280
|
+
#define LJ_TISPRI LJ_TTRUE
|
281
|
+
#define LJ_TISGCV (LJ_TSTR+1)
|
282
|
+
#define LJ_TISTABUD LJ_TTAB
|
283
|
+
|
284
|
+
#if LJ_GC64
|
285
|
+
#define LJ_GCVMASK (((uint64_t)1 << 47) - 1)
|
286
|
+
#endif
|
287
|
+
|
288
|
+
/* -- String object ------------------------------------------------------- */
|
289
|
+
|
290
|
+
/* String object header. String payload follows. */
|
291
|
+
typedef struct GCstr {
|
292
|
+
GCHeader;
|
293
|
+
uint8_t reserved; /* Used by lexer for fast lookup of reserved words. */
|
294
|
+
uint8_t unused;
|
295
|
+
MSize hash; /* Hash of string. */
|
296
|
+
MSize len; /* Size of string. */
|
297
|
+
} GCstr;
|
298
|
+
|
299
|
+
#define strref(r) (&gcref((r))->str)
|
300
|
+
#define strdata(s) ((const char *)((s)+1))
|
301
|
+
#define strdatawr(s) ((char *)((s)+1))
|
302
|
+
#define strVdata(o) strdata(strV(o))
|
303
|
+
#define sizestring(s) (sizeof(struct GCstr)+(s)->len+1)
|
304
|
+
|
305
|
+
/* -- Userdata object ----------------------------------------------------- */
|
306
|
+
|
307
|
+
/* Userdata object. Payload follows. */
|
308
|
+
typedef struct GCudata {
|
309
|
+
GCHeader;
|
310
|
+
uint8_t udtype; /* Userdata type. */
|
311
|
+
uint8_t unused2;
|
312
|
+
GCRef env; /* Should be at same offset in GCfunc. */
|
313
|
+
MSize len; /* Size of payload. */
|
314
|
+
GCRef metatable; /* Must be at same offset in GCtab. */
|
315
|
+
uint32_t align1; /* To force 8 byte alignment of the payload. */
|
316
|
+
} GCudata;
|
317
|
+
|
318
|
+
/* Userdata types. */
|
319
|
+
enum {
|
320
|
+
UDTYPE_USERDATA, /* Regular userdata. */
|
321
|
+
UDTYPE_IO_FILE, /* I/O library FILE. */
|
322
|
+
UDTYPE_FFI_CLIB, /* FFI C library namespace. */
|
323
|
+
UDTYPE__MAX
|
324
|
+
};
|
325
|
+
|
326
|
+
#define uddata(u) ((void *)((u)+1))
|
327
|
+
#define sizeudata(u) (sizeof(struct GCudata)+(u)->len)
|
328
|
+
|
329
|
+
/* -- C data object ------------------------------------------------------- */
|
330
|
+
|
331
|
+
/* C data object. Payload follows. */
|
332
|
+
typedef struct GCcdata {
|
333
|
+
GCHeader;
|
334
|
+
uint16_t ctypeid; /* C type ID. */
|
335
|
+
} GCcdata;
|
336
|
+
|
337
|
+
/* Prepended to variable-sized or realigned C data objects. */
|
338
|
+
typedef struct GCcdataVar {
|
339
|
+
uint16_t offset; /* Offset to allocated memory (relative to GCcdata). */
|
340
|
+
uint16_t extra; /* Extra space allocated (incl. GCcdata + GCcdatav). */
|
341
|
+
MSize len; /* Size of payload. */
|
342
|
+
} GCcdataVar;
|
343
|
+
|
344
|
+
#define cdataptr(cd) ((void *)((cd)+1))
|
345
|
+
#define cdataisv(cd) ((cd)->marked & 0x80)
|
346
|
+
#define cdatav(cd) ((GCcdataVar *)((char *)(cd) - sizeof(GCcdataVar)))
|
347
|
+
#define cdatavlen(cd) check_exp(cdataisv(cd), cdatav(cd)->len)
|
348
|
+
#define sizecdatav(cd) (cdatavlen(cd) + cdatav(cd)->extra)
|
349
|
+
#define memcdatav(cd) ((void *)((char *)(cd) - cdatav(cd)->offset))
|
350
|
+
|
351
|
+
/* -- Prototype object ---------------------------------------------------- */
|
352
|
+
|
353
|
+
#define SCALE_NUM_GCO ((int32_t)sizeof(lua_Number)/sizeof(GCRef))
|
354
|
+
#define round_nkgc(n) (((n) + SCALE_NUM_GCO-1) & ~(SCALE_NUM_GCO-1))
|
355
|
+
|
356
|
+
typedef struct GCproto {
|
357
|
+
GCHeader;
|
358
|
+
uint8_t numparams; /* Number of parameters. */
|
359
|
+
uint8_t framesize; /* Fixed frame size. */
|
360
|
+
MSize sizebc; /* Number of bytecode instructions. */
|
361
|
+
#if LJ_GC64
|
362
|
+
uint32_t unused_gc64;
|
363
|
+
#endif
|
364
|
+
GCRef gclist;
|
365
|
+
MRef k; /* Split constant array (points to the middle). */
|
366
|
+
MRef uv; /* Upvalue list. local slot|0x8000 or parent uv idx. */
|
367
|
+
MSize sizekgc; /* Number of collectable constants. */
|
368
|
+
MSize sizekn; /* Number of lua_Number constants. */
|
369
|
+
MSize sizept; /* Total size including colocated arrays. */
|
370
|
+
uint8_t sizeuv; /* Number of upvalues. */
|
371
|
+
uint8_t flags; /* Miscellaneous flags (see below). */
|
372
|
+
uint16_t trace; /* Anchor for chain of root traces. */
|
373
|
+
/* ------ The following fields are for debugging/tracebacks only ------ */
|
374
|
+
GCRef chunkname; /* Name of the chunk this function was defined in. */
|
375
|
+
BCLine firstline; /* First line of the function definition. */
|
376
|
+
BCLine numline; /* Number of lines for the function definition. */
|
377
|
+
MRef lineinfo; /* Compressed map from bytecode ins. to source line. */
|
378
|
+
MRef uvinfo; /* Upvalue names. */
|
379
|
+
MRef varinfo; /* Names and compressed extents of local variables. */
|
380
|
+
} GCproto;
|
381
|
+
|
382
|
+
/* Flags for prototype. */
|
383
|
+
#define PROTO_CHILD 0x01 /* Has child prototypes. */
|
384
|
+
#define PROTO_VARARG 0x02 /* Vararg function. */
|
385
|
+
#define PROTO_FFI 0x04 /* Uses BC_KCDATA for FFI datatypes. */
|
386
|
+
#define PROTO_NOJIT 0x08 /* JIT disabled for this function. */
|
387
|
+
#define PROTO_ILOOP 0x10 /* Patched bytecode with ILOOP etc. */
|
388
|
+
/* Only used during parsing. */
|
389
|
+
#define PROTO_HAS_RETURN 0x20 /* Already emitted a return. */
|
390
|
+
#define PROTO_FIXUP_RETURN 0x40 /* Need to fixup emitted returns. */
|
391
|
+
/* Top bits used for counting created closures. */
|
392
|
+
#define PROTO_CLCOUNT 0x20 /* Base of saturating 3 bit counter. */
|
393
|
+
#define PROTO_CLC_BITS 3
|
394
|
+
#define PROTO_CLC_POLY (3*PROTO_CLCOUNT) /* Polymorphic threshold. */
|
395
|
+
|
396
|
+
#define PROTO_UV_LOCAL 0x8000 /* Upvalue for local slot. */
|
397
|
+
#define PROTO_UV_IMMUTABLE 0x4000 /* Immutable upvalue. */
|
398
|
+
|
399
|
+
#define proto_kgc(pt, idx) \
|
400
|
+
check_exp((uintptr_t)(intptr_t)(idx) >= (uintptr_t)-(intptr_t)(pt)->sizekgc, \
|
401
|
+
gcref(mref((pt)->k, GCRef)[(idx)]))
|
402
|
+
#define proto_knumtv(pt, idx) \
|
403
|
+
check_exp((uintptr_t)(idx) < (pt)->sizekn, &mref((pt)->k, TValue)[(idx)])
|
404
|
+
#define proto_bc(pt) ((BCIns *)((char *)(pt) + sizeof(GCproto)))
|
405
|
+
#define proto_bcpos(pt, pc) ((BCPos)((pc) - proto_bc(pt)))
|
406
|
+
#define proto_uv(pt) (mref((pt)->uv, uint16_t))
|
407
|
+
|
408
|
+
#define proto_chunkname(pt) (strref((pt)->chunkname))
|
409
|
+
#define proto_chunknamestr(pt) (strdata(proto_chunkname((pt))))
|
410
|
+
#define proto_lineinfo(pt) (mref((pt)->lineinfo, const void))
|
411
|
+
#define proto_uvinfo(pt) (mref((pt)->uvinfo, const uint8_t))
|
412
|
+
#define proto_varinfo(pt) (mref((pt)->varinfo, const uint8_t))
|
413
|
+
|
414
|
+
/* -- Upvalue object ------------------------------------------------------ */
|
415
|
+
|
416
|
+
typedef struct GCupval {
|
417
|
+
GCHeader;
|
418
|
+
uint8_t closed; /* Set if closed (i.e. uv->v == &uv->u.value). */
|
419
|
+
uint8_t immutable; /* Immutable value. */
|
420
|
+
union {
|
421
|
+
TValue tv; /* If closed: the value itself. */
|
422
|
+
struct { /* If open: double linked list, anchored at thread. */
|
423
|
+
GCRef prev;
|
424
|
+
GCRef next;
|
425
|
+
};
|
426
|
+
};
|
427
|
+
MRef v; /* Points to stack slot (open) or above (closed). */
|
428
|
+
uint32_t dhash; /* Disambiguation hash: dh1 != dh2 => cannot alias. */
|
429
|
+
} GCupval;
|
430
|
+
|
431
|
+
#define uvprev(uv_) (&gcref((uv_)->prev)->uv)
|
432
|
+
#define uvnext(uv_) (&gcref((uv_)->next)->uv)
|
433
|
+
#define uvval(uv_) (mref((uv_)->v, TValue))
|
434
|
+
|
435
|
+
/* -- Function object (closures) ------------------------------------------ */
|
436
|
+
|
437
|
+
/* Common header for functions. env should be at same offset in GCudata. */
|
438
|
+
#define GCfuncHeader \
|
439
|
+
GCHeader; uint8_t ffid; uint8_t nupvalues; \
|
440
|
+
GCRef env; GCRef gclist; MRef pc
|
441
|
+
|
442
|
+
typedef struct GCfuncC {
|
443
|
+
GCfuncHeader;
|
444
|
+
lua_CFunction f; /* C function to be called. */
|
445
|
+
TValue upvalue[1]; /* Array of upvalues (TValue). */
|
446
|
+
} GCfuncC;
|
447
|
+
|
448
|
+
typedef struct GCfuncL {
|
449
|
+
GCfuncHeader;
|
450
|
+
GCRef uvptr[1]; /* Array of _pointers_ to upvalue objects (GCupval). */
|
451
|
+
} GCfuncL;
|
452
|
+
|
453
|
+
typedef union GCfunc {
|
454
|
+
GCfuncC c;
|
455
|
+
GCfuncL l;
|
456
|
+
} GCfunc;
|
457
|
+
|
458
|
+
#define FF_LUA 0
|
459
|
+
#define FF_C 1
|
460
|
+
#define isluafunc(fn) ((fn)->c.ffid == FF_LUA)
|
461
|
+
#define iscfunc(fn) ((fn)->c.ffid == FF_C)
|
462
|
+
#define isffunc(fn) ((fn)->c.ffid > FF_C)
|
463
|
+
#define funcproto(fn) \
|
464
|
+
check_exp(isluafunc(fn), (GCproto *)(mref((fn)->l.pc, char)-sizeof(GCproto)))
|
465
|
+
#define sizeCfunc(n) (sizeof(GCfuncC)-sizeof(TValue)+sizeof(TValue)*(n))
|
466
|
+
#define sizeLfunc(n) (sizeof(GCfuncL)-sizeof(GCRef)+sizeof(GCRef)*(n))
|
467
|
+
|
468
|
+
/* -- Table object -------------------------------------------------------- */
|
469
|
+
|
470
|
+
/* Hash node. */
|
471
|
+
typedef struct Node {
|
472
|
+
TValue val; /* Value object. Must be first field. */
|
473
|
+
TValue key; /* Key object. */
|
474
|
+
MRef next; /* Hash chain. */
|
475
|
+
#if !LJ_GC64
|
476
|
+
MRef freetop; /* Top of free elements (stored in t->node[0]). */
|
477
|
+
#endif
|
478
|
+
} Node;
|
479
|
+
|
480
|
+
LJ_STATIC_ASSERT(offsetof(Node, val) == 0);
|
481
|
+
|
482
|
+
typedef struct GCtab {
|
483
|
+
GCHeader;
|
484
|
+
uint8_t nomm; /* Negative cache for fast metamethods. */
|
485
|
+
int8_t colo; /* Array colocation. */
|
486
|
+
MRef array; /* Array part. */
|
487
|
+
GCRef gclist;
|
488
|
+
GCRef metatable; /* Must be at same offset in GCudata. */
|
489
|
+
MRef node; /* Hash part. */
|
490
|
+
uint32_t asize; /* Size of array part (keys [0, asize-1]). */
|
491
|
+
uint32_t hmask; /* Hash part mask (size of hash part - 1). */
|
492
|
+
#if LJ_GC64
|
493
|
+
MRef freetop; /* Top of free elements. */
|
494
|
+
#endif
|
495
|
+
} GCtab;
|
496
|
+
|
497
|
+
#define sizetabcolo(n) ((n)*sizeof(TValue) + sizeof(GCtab))
|
498
|
+
#define tabref(r) (&gcref((r))->tab)
|
499
|
+
#define noderef(r) (mref((r), Node))
|
500
|
+
#define nextnode(n) (mref((n)->next, Node))
|
501
|
+
#if LJ_GC64
|
502
|
+
#define getfreetop(t, n) (noderef((t)->freetop))
|
503
|
+
#define setfreetop(t, n, v) (setmref((t)->freetop, (v)))
|
504
|
+
#else
|
505
|
+
#define getfreetop(t, n) (noderef((n)->freetop))
|
506
|
+
#define setfreetop(t, n, v) (setmref((n)->freetop, (v)))
|
507
|
+
#endif
|
508
|
+
|
509
|
+
/* -- State objects ------------------------------------------------------- */
|
510
|
+
|
511
|
+
/* VM states. */
|
512
|
+
enum {
|
513
|
+
LJ_VMST_INTERP, /* Interpreter. */
|
514
|
+
LJ_VMST_C, /* C function. */
|
515
|
+
LJ_VMST_GC, /* Garbage collector. */
|
516
|
+
LJ_VMST_EXIT, /* Trace exit handler. */
|
517
|
+
LJ_VMST_RECORD, /* Trace recorder. */
|
518
|
+
LJ_VMST_OPT, /* Optimizer. */
|
519
|
+
LJ_VMST_ASM, /* Assembler. */
|
520
|
+
LJ_VMST__MAX
|
521
|
+
};
|
522
|
+
|
523
|
+
#define setvmstate(g, st) ((g)->vmstate = ~LJ_VMST_##st)
|
524
|
+
|
525
|
+
/* Metamethods. ORDER MM */
|
526
|
+
#ifdef LJ_HASFFI
|
527
|
+
#define MMDEF_FFI(_) _(new)
|
528
|
+
#else
|
529
|
+
#define MMDEF_FFI(_)
|
530
|
+
#endif
|
531
|
+
|
532
|
+
#if LJ_52 || LJ_HASFFI
|
533
|
+
#define MMDEF_PAIRS(_) _(pairs) _(ipairs)
|
534
|
+
#else
|
535
|
+
#define MMDEF_PAIRS(_)
|
536
|
+
#define MM_pairs 255
|
537
|
+
#define MM_ipairs 255
|
538
|
+
#endif
|
539
|
+
|
540
|
+
#define MMDEF(_) \
|
541
|
+
_(index) _(newindex) _(gc) _(mode) _(eq) _(len) \
|
542
|
+
/* Only the above (fast) metamethods are negative cached (max. 8). */ \
|
543
|
+
_(lt) _(le) _(concat) _(call) \
|
544
|
+
/* The following must be in ORDER ARITH. */ \
|
545
|
+
_(add) _(sub) _(mul) _(div) _(mod) _(pow) _(unm) \
|
546
|
+
/* The following are used in the standard libraries. */ \
|
547
|
+
_(metatable) _(tostring) MMDEF_FFI(_) MMDEF_PAIRS(_)
|
548
|
+
|
549
|
+
typedef enum {
|
550
|
+
#define MMENUM(name) MM_##name,
|
551
|
+
MMDEF(MMENUM)
|
552
|
+
#undef MMENUM
|
553
|
+
MM__MAX,
|
554
|
+
MM____ = MM__MAX,
|
555
|
+
MM_FAST = MM_len
|
556
|
+
} MMS;
|
557
|
+
|
558
|
+
/* GC root IDs. */
|
559
|
+
typedef enum {
|
560
|
+
GCROOT_MMNAME, /* Metamethod names. */
|
561
|
+
GCROOT_MMNAME_LAST = GCROOT_MMNAME + MM__MAX-1,
|
562
|
+
GCROOT_BASEMT, /* Metatables for base types. */
|
563
|
+
GCROOT_BASEMT_NUM = GCROOT_BASEMT + ~LJ_TNUMX,
|
564
|
+
GCROOT_IO_INPUT, /* Userdata for default I/O input file. */
|
565
|
+
GCROOT_IO_OUTPUT, /* Userdata for default I/O output file. */
|
566
|
+
GCROOT_MAX
|
567
|
+
} GCRootID;
|
568
|
+
|
569
|
+
#define basemt_it(g, it) ((g)->gcroot[GCROOT_BASEMT+~(it)])
|
570
|
+
#define basemt_obj(g, o) ((g)->gcroot[GCROOT_BASEMT+itypemap(o)])
|
571
|
+
#define mmname_str(g, mm) (strref((g)->gcroot[GCROOT_MMNAME+(mm)]))
|
572
|
+
|
573
|
+
typedef struct GCState {
|
574
|
+
GCSize total; /* Memory currently allocated. */
|
575
|
+
GCSize threshold; /* Memory threshold. */
|
576
|
+
uint8_t currentwhite; /* Current white color. */
|
577
|
+
uint8_t state; /* GC state. */
|
578
|
+
uint8_t nocdatafin; /* No cdata finalizer called. */
|
579
|
+
uint8_t unused2;
|
580
|
+
MSize sweepstr; /* Sweep position in string table. */
|
581
|
+
GCRef root; /* List of all collectable objects. */
|
582
|
+
MRef sweep; /* Sweep position in root list. */
|
583
|
+
GCRef gray; /* List of gray objects. */
|
584
|
+
GCRef grayagain; /* List of objects for atomic traversal. */
|
585
|
+
GCRef weak; /* List of weak tables (to be cleared). */
|
586
|
+
GCRef mmudata; /* List of userdata (to be finalized). */
|
587
|
+
GCSize debt; /* Debt (how much GC is behind schedule). */
|
588
|
+
GCSize estimate; /* Estimate of memory actually in use. */
|
589
|
+
MSize stepmul; /* Incremental GC step granularity. */
|
590
|
+
MSize pause; /* Pause between successive GC cycles. */
|
591
|
+
} GCState;
|
592
|
+
|
593
|
+
/* Global state, shared by all threads of a Lua universe. */
|
594
|
+
typedef struct global_State {
|
595
|
+
GCRef *strhash; /* String hash table (hash chain anchors). */
|
596
|
+
MSize strmask; /* String hash mask (size of hash table - 1). */
|
597
|
+
MSize strnum; /* Number of strings in hash table. */
|
598
|
+
lua_Alloc allocf; /* Memory allocator. */
|
599
|
+
void *allocd; /* Memory allocator data. */
|
600
|
+
GCState gc; /* Garbage collector. */
|
601
|
+
volatile int32_t vmstate; /* VM state or current JIT code trace number. */
|
602
|
+
SBuf tmpbuf; /* Temporary string buffer. */
|
603
|
+
GCstr strempty; /* Empty string. */
|
604
|
+
uint8_t stremptyz; /* Zero terminator of empty string. */
|
605
|
+
uint8_t hookmask; /* Hook mask. */
|
606
|
+
uint8_t dispatchmode; /* Dispatch mode. */
|
607
|
+
uint8_t vmevmask; /* VM event mask. */
|
608
|
+
GCRef mainthref; /* Link to main thread. */
|
609
|
+
TValue registrytv; /* Anchor for registry. */
|
610
|
+
TValue tmptv, tmptv2; /* Temporary TValues. */
|
611
|
+
Node nilnode; /* Fallback 1-element hash part (nil key and value). */
|
612
|
+
GCupval uvhead; /* Head of double-linked list of all open upvalues. */
|
613
|
+
int32_t hookcount; /* Instruction hook countdown. */
|
614
|
+
int32_t hookcstart; /* Start count for instruction hook counter. */
|
615
|
+
lua_Hook hookf; /* Hook function. */
|
616
|
+
lua_CFunction wrapf; /* Wrapper for C function calls. */
|
617
|
+
lua_CFunction panic; /* Called as a last resort for errors. */
|
618
|
+
BCIns bc_cfunc_int; /* Bytecode for internal C function calls. */
|
619
|
+
BCIns bc_cfunc_ext; /* Bytecode for external C function calls. */
|
620
|
+
GCRef cur_L; /* Currently executing lua_State. */
|
621
|
+
MRef jit_base; /* Current JIT code L->base or NULL. */
|
622
|
+
MRef ctype_state; /* Pointer to C type state. */
|
623
|
+
GCRef gcroot[GCROOT_MAX]; /* GC roots. */
|
624
|
+
} global_State;
|
625
|
+
|
626
|
+
#define mainthread(g) (&gcref(g->mainthref)->th)
|
627
|
+
#define niltv(L) \
|
628
|
+
check_exp(tvisnil(&G(L)->nilnode.val), &G(L)->nilnode.val)
|
629
|
+
#define niltvg(g) \
|
630
|
+
check_exp(tvisnil(&(g)->nilnode.val), &(g)->nilnode.val)
|
631
|
+
|
632
|
+
/* Hook management. Hook event masks are defined in lua.h. */
|
633
|
+
#define HOOK_EVENTMASK 0x0f
|
634
|
+
#define HOOK_ACTIVE 0x10
|
635
|
+
#define HOOK_ACTIVE_SHIFT 4
|
636
|
+
#define HOOK_VMEVENT 0x20
|
637
|
+
#define HOOK_GC 0x40
|
638
|
+
#define HOOK_PROFILE 0x80
|
639
|
+
#define hook_active(g) ((g)->hookmask & HOOK_ACTIVE)
|
640
|
+
#define hook_enter(g) ((g)->hookmask |= HOOK_ACTIVE)
|
641
|
+
#define hook_entergc(g) ((g)->hookmask |= (HOOK_ACTIVE|HOOK_GC))
|
642
|
+
#define hook_vmevent(g) ((g)->hookmask |= (HOOK_ACTIVE|HOOK_VMEVENT))
|
643
|
+
#define hook_leave(g) ((g)->hookmask &= ~HOOK_ACTIVE)
|
644
|
+
#define hook_save(g) ((g)->hookmask & ~HOOK_EVENTMASK)
|
645
|
+
#define hook_restore(g, h) \
|
646
|
+
((g)->hookmask = ((g)->hookmask & HOOK_EVENTMASK) | (h))
|
647
|
+
|
648
|
+
/* Per-thread state object. */
|
649
|
+
struct lua_State {
|
650
|
+
GCHeader;
|
651
|
+
uint8_t dummy_ffid; /* Fake FF_C for curr_funcisL() on dummy frames. */
|
652
|
+
uint8_t status; /* Thread status. */
|
653
|
+
MRef glref; /* Link to global state. */
|
654
|
+
GCRef gclist; /* GC chain. */
|
655
|
+
TValue *base; /* Base of currently executing function. */
|
656
|
+
TValue *top; /* First free slot in the stack. */
|
657
|
+
MRef maxstack; /* Last free slot in the stack. */
|
658
|
+
MRef stack; /* Stack base. */
|
659
|
+
GCRef openupval; /* List of open upvalues in the stack. */
|
660
|
+
GCRef env; /* Thread environment (table of globals). */
|
661
|
+
void *cframe; /* End of C stack frame chain. */
|
662
|
+
MSize stacksize; /* True stack size (incl. LJ_STACK_EXTRA). */
|
663
|
+
};
|
664
|
+
|
665
|
+
#define G(L) (mref(L->glref, global_State))
|
666
|
+
#define registry(L) (&G(L)->registrytv)
|
667
|
+
|
668
|
+
/* Macros to access the currently executing (Lua) function. */
|
669
|
+
#if LJ_GC64
|
670
|
+
#define curr_func(L) (&gcval(L->base-2)->fn)
|
671
|
+
#elif LJ_FR2
|
672
|
+
#define curr_func(L) (&gcref((L->base-2)->gcr)->fn)
|
673
|
+
#else
|
674
|
+
#define curr_func(L) (&gcref((L->base-1)->fr.func)->fn)
|
675
|
+
#endif
|
676
|
+
#define curr_funcisL(L) (isluafunc(curr_func(L)))
|
677
|
+
#define curr_proto(L) (funcproto(curr_func(L)))
|
678
|
+
#define curr_topL(L) (L->base + curr_proto(L)->framesize)
|
679
|
+
#define curr_top(L) (curr_funcisL(L) ? curr_topL(L) : L->top)
|
680
|
+
|
681
|
+
/* -- GC object definition and conversions -------------------------------- */
|
682
|
+
|
683
|
+
/* GC header for generic access to common fields of GC objects. */
|
684
|
+
typedef struct GChead {
|
685
|
+
GCHeader;
|
686
|
+
uint8_t unused1;
|
687
|
+
uint8_t unused2;
|
688
|
+
GCRef env;
|
689
|
+
GCRef gclist;
|
690
|
+
GCRef metatable;
|
691
|
+
} GChead;
|
692
|
+
|
693
|
+
/* The env field SHOULD be at the same offset for all GC objects. */
|
694
|
+
LJ_STATIC_ASSERT(offsetof(GChead, env) == offsetof(GCfuncL, env));
|
695
|
+
LJ_STATIC_ASSERT(offsetof(GChead, env) == offsetof(GCudata, env));
|
696
|
+
|
697
|
+
/* The metatable field MUST be at the same offset for all GC objects. */
|
698
|
+
LJ_STATIC_ASSERT(offsetof(GChead, metatable) == offsetof(GCtab, metatable));
|
699
|
+
LJ_STATIC_ASSERT(offsetof(GChead, metatable) == offsetof(GCudata, metatable));
|
700
|
+
|
701
|
+
/* The gclist field MUST be at the same offset for all GC objects. */
|
702
|
+
LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(lua_State, gclist));
|
703
|
+
LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCproto, gclist));
|
704
|
+
LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCfuncL, gclist));
|
705
|
+
LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCtab, gclist));
|
706
|
+
|
707
|
+
typedef union GCobj {
|
708
|
+
GChead gch;
|
709
|
+
GCstr str;
|
710
|
+
GCupval uv;
|
711
|
+
lua_State th;
|
712
|
+
GCproto pt;
|
713
|
+
GCfunc fn;
|
714
|
+
GCcdata cd;
|
715
|
+
GCtab tab;
|
716
|
+
GCudata ud;
|
717
|
+
} GCobj;
|
718
|
+
|
719
|
+
/* Macros to convert a GCobj pointer into a specific value. */
|
720
|
+
#define gco2str(o) check_exp((o)->gch.gct == ~LJ_TSTR, &(o)->str)
|
721
|
+
#define gco2uv(o) check_exp((o)->gch.gct == ~LJ_TUPVAL, &(o)->uv)
|
722
|
+
#define gco2th(o) check_exp((o)->gch.gct == ~LJ_TTHREAD, &(o)->th)
|
723
|
+
#define gco2pt(o) check_exp((o)->gch.gct == ~LJ_TPROTO, &(o)->pt)
|
724
|
+
#define gco2func(o) check_exp((o)->gch.gct == ~LJ_TFUNC, &(o)->fn)
|
725
|
+
#define gco2cd(o) check_exp((o)->gch.gct == ~LJ_TCDATA, &(o)->cd)
|
726
|
+
#define gco2tab(o) check_exp((o)->gch.gct == ~LJ_TTAB, &(o)->tab)
|
727
|
+
#define gco2ud(o) check_exp((o)->gch.gct == ~LJ_TUDATA, &(o)->ud)
|
728
|
+
|
729
|
+
/* Macro to convert any collectable object into a GCobj pointer. */
|
730
|
+
#define obj2gco(v) ((GCobj *)(v))
|
731
|
+
|
732
|
+
/* -- TValue getters/setters ---------------------------------------------- */
|
733
|
+
|
734
|
+
#ifdef LUA_USE_ASSERT
|
735
|
+
#include "lj_gc.h"
|
736
|
+
#endif
|
737
|
+
|
738
|
+
/* Macros to test types. */
|
739
|
+
#if LJ_GC64
|
740
|
+
#define itype(o) ((uint32_t)((o)->it64 >> 47))
|
741
|
+
#define tvisnil(o) ((o)->it64 == -1)
|
742
|
+
#else
|
743
|
+
#define itype(o) ((o)->it)
|
744
|
+
#define tvisnil(o) (itype(o) == LJ_TNIL)
|
745
|
+
#endif
|
746
|
+
#define tvisfalse(o) (itype(o) == LJ_TFALSE)
|
747
|
+
#define tvistrue(o) (itype(o) == LJ_TTRUE)
|
748
|
+
#define tvisbool(o) (tvisfalse(o) || tvistrue(o))
|
749
|
+
#if LJ_64 && !LJ_GC64
|
750
|
+
#define tvislightud(o) (((int32_t)itype(o) >> 15) == -2)
|
751
|
+
#else
|
752
|
+
#define tvislightud(o) (itype(o) == LJ_TLIGHTUD)
|
753
|
+
#endif
|
754
|
+
#define tvisstr(o) (itype(o) == LJ_TSTR)
|
755
|
+
#define tvisfunc(o) (itype(o) == LJ_TFUNC)
|
756
|
+
#define tvisthread(o) (itype(o) == LJ_TTHREAD)
|
757
|
+
#define tvisproto(o) (itype(o) == LJ_TPROTO)
|
758
|
+
#define tviscdata(o) (itype(o) == LJ_TCDATA)
|
759
|
+
#define tvistab(o) (itype(o) == LJ_TTAB)
|
760
|
+
#define tvisudata(o) (itype(o) == LJ_TUDATA)
|
761
|
+
#define tvisnumber(o) (itype(o) <= LJ_TISNUM)
|
762
|
+
#define tvisint(o) (LJ_DUALNUM && itype(o) == LJ_TISNUM)
|
763
|
+
#define tvisnum(o) (itype(o) < LJ_TISNUM)
|
764
|
+
|
765
|
+
#define tvistruecond(o) (itype(o) < LJ_TISTRUECOND)
|
766
|
+
#define tvispri(o) (itype(o) >= LJ_TISPRI)
|
767
|
+
#define tvistabud(o) (itype(o) <= LJ_TISTABUD) /* && !tvisnum() */
|
768
|
+
#define tvisgcv(o) ((itype(o) - LJ_TISGCV) > (LJ_TNUMX - LJ_TISGCV))
|
769
|
+
|
770
|
+
/* Special macros to test numbers for NaN, +0, -0, +1 and raw equality. */
|
771
|
+
#define tvisnan(o) ((o)->n != (o)->n)
|
772
|
+
#if LJ_64
|
773
|
+
#define tviszero(o) (((o)->u64 << 1) == 0)
|
774
|
+
#else
|
775
|
+
#define tviszero(o) (((o)->u32.lo | ((o)->u32.hi << 1)) == 0)
|
776
|
+
#endif
|
777
|
+
#define tvispzero(o) ((o)->u64 == 0)
|
778
|
+
#define tvismzero(o) ((o)->u64 == U64x(80000000,00000000))
|
779
|
+
#define tvispone(o) ((o)->u64 == U64x(3ff00000,00000000))
|
780
|
+
#define rawnumequal(o1, o2) ((o1)->u64 == (o2)->u64)
|
781
|
+
|
782
|
+
/* Macros to convert type ids. */
|
783
|
+
#if LJ_64 && !LJ_GC64
|
784
|
+
#define itypemap(o) \
|
785
|
+
(tvisnumber(o) ? ~LJ_TNUMX : tvislightud(o) ? ~LJ_TLIGHTUD : ~itype(o))
|
786
|
+
#else
|
787
|
+
#define itypemap(o) (tvisnumber(o) ? ~LJ_TNUMX : ~itype(o))
|
788
|
+
#endif
|
789
|
+
|
790
|
+
/* Macros to get tagged values. */
|
791
|
+
#if LJ_GC64
|
792
|
+
#define gcval(o) ((GCobj *)(gcrefu((o)->gcr) & LJ_GCVMASK))
|
793
|
+
#else
|
794
|
+
#define gcval(o) (gcref((o)->gcr))
|
795
|
+
#endif
|
796
|
+
#define boolV(o) check_exp(tvisbool(o), (LJ_TFALSE - itype(o)))
|
797
|
+
#if LJ_64
|
798
|
+
#define lightudV(o) \
|
799
|
+
check_exp(tvislightud(o), (void *)((o)->u64 & U64x(00007fff,ffffffff)))
|
800
|
+
#else
|
801
|
+
#define lightudV(o) check_exp(tvislightud(o), gcrefp((o)->gcr, void))
|
802
|
+
#endif
|
803
|
+
#define gcV(o) check_exp(tvisgcv(o), gcval(o))
|
804
|
+
#define strV(o) check_exp(tvisstr(o), &gcval(o)->str)
|
805
|
+
#define funcV(o) check_exp(tvisfunc(o), &gcval(o)->fn)
|
806
|
+
#define threadV(o) check_exp(tvisthread(o), &gcval(o)->th)
|
807
|
+
#define protoV(o) check_exp(tvisproto(o), &gcval(o)->pt)
|
808
|
+
#define cdataV(o) check_exp(tviscdata(o), &gcval(o)->cd)
|
809
|
+
#define tabV(o) check_exp(tvistab(o), &gcval(o)->tab)
|
810
|
+
#define udataV(o) check_exp(tvisudata(o), &gcval(o)->ud)
|
811
|
+
#define numV(o) check_exp(tvisnum(o), (o)->n)
|
812
|
+
#define intV(o) check_exp(tvisint(o), (int32_t)(o)->i)
|
813
|
+
|
814
|
+
/* Macros to set tagged values. */
|
815
|
+
#if LJ_GC64
|
816
|
+
#define setitype(o, i) ((o)->it = ((i) << 15))
|
817
|
+
#define setnilV(o) ((o)->it64 = -1)
|
818
|
+
#define setpriV(o, x) ((o)->it64 = (int64_t)~((uint64_t)~(x)<<47))
|
819
|
+
#define setboolV(o, x) ((o)->it64 = (int64_t)~((uint64_t)((x)+1)<<47))
|
820
|
+
#else
|
821
|
+
#define setitype(o, i) ((o)->it = (i))
|
822
|
+
#define setnilV(o) ((o)->it = LJ_TNIL)
|
823
|
+
#define setboolV(o, x) ((o)->it = LJ_TFALSE-(uint32_t)(x))
|
824
|
+
#define setpriV(o, i) (setitype((o), (i)))
|
825
|
+
#endif
|
826
|
+
|
827
|
+
static LJ_AINLINE void setlightudV(TValue *o, void *p)
|
828
|
+
{
|
829
|
+
#if LJ_GC64
|
830
|
+
o->u64 = (uint64_t)p | (((uint64_t)LJ_TLIGHTUD) << 47);
|
831
|
+
#elif LJ_64
|
832
|
+
o->u64 = (uint64_t)p | (((uint64_t)0xffff) << 48);
|
833
|
+
#else
|
834
|
+
setgcrefp(o->gcr, p); setitype(o, LJ_TLIGHTUD);
|
835
|
+
#endif
|
836
|
+
}
|
837
|
+
|
838
|
+
#if LJ_64
|
839
|
+
#define checklightudptr(L, p) \
|
840
|
+
(((uint64_t)(p) >> 47) ? (lj_err_msg(L, LJ_ERR_BADLU), NULL) : (p))
|
841
|
+
#else
|
842
|
+
#define checklightudptr(L, p) (p)
|
843
|
+
#endif
|
844
|
+
|
845
|
+
#if LJ_FR2
|
846
|
+
#define setcont(o, f) ((o)->u64 = (uint64_t)(uintptr_t)(void *)(f))
|
847
|
+
#elif LJ_64
|
848
|
+
#define setcont(o, f) \
|
849
|
+
((o)->u64 = (uint64_t)(void *)(f) - (uint64_t)lj_vm_asm_begin)
|
850
|
+
#else
|
851
|
+
#define setcont(o, f) setlightudV((o), (void *)(f))
|
852
|
+
#endif
|
853
|
+
|
854
|
+
#define tvchecklive(L, o) \
|
855
|
+
UNUSED(L), lua_assert(!tvisgcv(o) || \
|
856
|
+
((~itype(o) == gcval(o)->gch.gct) && !isdead(G(L), gcval(o))))
|
857
|
+
|
858
|
+
static LJ_AINLINE void setgcVraw(TValue *o, GCobj *v, uint32_t itype)
|
859
|
+
{
|
860
|
+
#if LJ_GC64
|
861
|
+
setgcreft(o->gcr, v, itype);
|
862
|
+
#else
|
863
|
+
setgcref(o->gcr, v); setitype(o, itype);
|
864
|
+
#endif
|
865
|
+
}
|
866
|
+
|
867
|
+
static LJ_AINLINE void setgcV(lua_State *L, TValue *o, GCobj *v, uint32_t it)
|
868
|
+
{
|
869
|
+
setgcVraw(o, v, it); tvchecklive(L, o);
|
870
|
+
}
|
871
|
+
|
872
|
+
#define define_setV(name, type, tag) \
|
873
|
+
static LJ_AINLINE void name(lua_State *L, TValue *o, type *v) \
|
874
|
+
{ \
|
875
|
+
setgcV(L, o, obj2gco(v), tag); \
|
876
|
+
}
|
877
|
+
define_setV(setstrV, GCstr, LJ_TSTR)
|
878
|
+
define_setV(setthreadV, lua_State, LJ_TTHREAD)
|
879
|
+
define_setV(setprotoV, GCproto, LJ_TPROTO)
|
880
|
+
define_setV(setfuncV, GCfunc, LJ_TFUNC)
|
881
|
+
define_setV(setcdataV, GCcdata, LJ_TCDATA)
|
882
|
+
define_setV(settabV, GCtab, LJ_TTAB)
|
883
|
+
define_setV(setudataV, GCudata, LJ_TUDATA)
|
884
|
+
|
885
|
+
#define setnumV(o, x) ((o)->n = (x))
|
886
|
+
#define setnanV(o) ((o)->u64 = U64x(fff80000,00000000))
|
887
|
+
#define setpinfV(o) ((o)->u64 = U64x(7ff00000,00000000))
|
888
|
+
#define setminfV(o) ((o)->u64 = U64x(fff00000,00000000))
|
889
|
+
|
890
|
+
static LJ_AINLINE void setintV(TValue *o, int32_t i)
|
891
|
+
{
|
892
|
+
#if LJ_DUALNUM
|
893
|
+
o->i = (uint32_t)i; setitype(o, LJ_TISNUM);
|
894
|
+
#else
|
895
|
+
o->n = (lua_Number)i;
|
896
|
+
#endif
|
897
|
+
}
|
898
|
+
|
899
|
+
static LJ_AINLINE void setint64V(TValue *o, int64_t i)
|
900
|
+
{
|
901
|
+
if (LJ_DUALNUM && LJ_LIKELY(i == (int64_t)(int32_t)i))
|
902
|
+
setintV(o, (int32_t)i);
|
903
|
+
else
|
904
|
+
setnumV(o, (lua_Number)i);
|
905
|
+
}
|
906
|
+
|
907
|
+
#if LJ_64
|
908
|
+
#define setintptrV(o, i) setint64V((o), (i))
|
909
|
+
#else
|
910
|
+
#define setintptrV(o, i) setintV((o), (i))
|
911
|
+
#endif
|
912
|
+
|
913
|
+
/* Copy tagged values. */
|
914
|
+
static LJ_AINLINE void copyTV(lua_State *L, TValue *o1, const TValue *o2)
|
915
|
+
{
|
916
|
+
*o1 = *o2; tvchecklive(L, o1);
|
917
|
+
}
|
918
|
+
|
919
|
+
/* -- Number to integer conversion ---------------------------------------- */
|
920
|
+
|
921
|
+
#if LJ_SOFTFP
|
922
|
+
LJ_ASMF int32_t lj_vm_tobit(double x);
|
923
|
+
#endif
|
924
|
+
|
925
|
+
static LJ_AINLINE int32_t lj_num2bit(lua_Number n)
|
926
|
+
{
|
927
|
+
#if LJ_SOFTFP
|
928
|
+
return lj_vm_tobit(n);
|
929
|
+
#else
|
930
|
+
TValue o;
|
931
|
+
o.n = n + 6755399441055744.0; /* 2^52 + 2^51 */
|
932
|
+
return (int32_t)o.u32.lo;
|
933
|
+
#endif
|
934
|
+
}
|
935
|
+
|
936
|
+
#define lj_num2int(n) ((int32_t)(n))
|
937
|
+
|
938
|
+
static LJ_AINLINE uint64_t lj_num2u64(lua_Number n)
|
939
|
+
{
|
940
|
+
#ifdef _MSC_VER
|
941
|
+
if (n >= 9223372036854775808.0) /* They think it's a feature. */
|
942
|
+
return (uint64_t)(int64_t)(n - 18446744073709551616.0);
|
943
|
+
else
|
944
|
+
#endif
|
945
|
+
return (uint64_t)n;
|
946
|
+
}
|
947
|
+
|
948
|
+
static LJ_AINLINE int32_t numberVint(cTValue *o)
|
949
|
+
{
|
950
|
+
if (LJ_LIKELY(tvisint(o)))
|
951
|
+
return intV(o);
|
952
|
+
else
|
953
|
+
return lj_num2int(numV(o));
|
954
|
+
}
|
955
|
+
|
956
|
+
static LJ_AINLINE lua_Number numberVnum(cTValue *o)
|
957
|
+
{
|
958
|
+
if (LJ_UNLIKELY(tvisint(o)))
|
959
|
+
return (lua_Number)intV(o);
|
960
|
+
else
|
961
|
+
return numV(o);
|
962
|
+
}
|
963
|
+
|
964
|
+
/* -- Miscellaneous object handling --------------------------------------- */
|
965
|
+
|
966
|
+
/* Names and maps for internal and external object tags. */
|
967
|
+
LJ_DATA const char *const lj_obj_typename[1+LUA_TCDATA+1];
|
968
|
+
LJ_DATA const char *const lj_obj_itypename[~LJ_TNUMX+1];
|
969
|
+
|
970
|
+
#define lj_typename(o) (lj_obj_itypename[itypemap(o)])
|
971
|
+
|
972
|
+
/* Compare two objects without calling metamethods. */
|
973
|
+
LJ_FUNC int LJ_FASTCALL lj_obj_equal(cTValue *o1, cTValue *o2);
|
974
|
+
LJ_FUNC const void * LJ_FASTCALL lj_obj_ptr(cTValue *o);
|
975
|
+
|
976
|
+
#endif
|