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,39 @@
|
|
1
|
+
/*
|
2
|
+
** String scanning.
|
3
|
+
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
|
4
|
+
*/
|
5
|
+
|
6
|
+
#ifndef _LJ_STRSCAN_H
|
7
|
+
#define _LJ_STRSCAN_H
|
8
|
+
|
9
|
+
#include "lj_obj.h"
|
10
|
+
|
11
|
+
/* Options for accepted/returned formats. */
|
12
|
+
#define STRSCAN_OPT_TOINT 0x01 /* Convert to int32_t, if possible. */
|
13
|
+
#define STRSCAN_OPT_TONUM 0x02 /* Always convert to double. */
|
14
|
+
#define STRSCAN_OPT_IMAG 0x04
|
15
|
+
#define STRSCAN_OPT_LL 0x08
|
16
|
+
#define STRSCAN_OPT_C 0x10
|
17
|
+
|
18
|
+
/* Returned format. */
|
19
|
+
typedef enum {
|
20
|
+
STRSCAN_ERROR,
|
21
|
+
STRSCAN_NUM, STRSCAN_IMAG,
|
22
|
+
STRSCAN_INT, STRSCAN_U32, STRSCAN_I64, STRSCAN_U64,
|
23
|
+
} StrScanFmt;
|
24
|
+
|
25
|
+
LJ_FUNC StrScanFmt lj_strscan_scan(const uint8_t *p, TValue *o, uint32_t opt);
|
26
|
+
LJ_FUNC int LJ_FASTCALL lj_strscan_num(GCstr *str, TValue *o);
|
27
|
+
#if LJ_DUALNUM
|
28
|
+
LJ_FUNC int LJ_FASTCALL lj_strscan_number(GCstr *str, TValue *o);
|
29
|
+
#else
|
30
|
+
#define lj_strscan_number(s, o) lj_strscan_num((s), (o))
|
31
|
+
#endif
|
32
|
+
|
33
|
+
/* Check for number or convert string to number/int in-place (!). */
|
34
|
+
static LJ_AINLINE int lj_strscan_numberobj(TValue *o)
|
35
|
+
{
|
36
|
+
return tvisnumber(o) || (tvisstr(o) && lj_strscan_number(strV(o), o));
|
37
|
+
}
|
38
|
+
|
39
|
+
#endif
|
Binary file
|
Binary file
|
@@ -0,0 +1,666 @@
|
|
1
|
+
/*
|
2
|
+
** Table handling.
|
3
|
+
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
|
4
|
+
**
|
5
|
+
** Major 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
|
+
#define lj_tab_c
|
10
|
+
#define LUA_CORE
|
11
|
+
|
12
|
+
#include "lj_obj.h"
|
13
|
+
#include "lj_gc.h"
|
14
|
+
#include "lj_err.h"
|
15
|
+
#include "lj_tab.h"
|
16
|
+
|
17
|
+
/* -- Object hashing ------------------------------------------------------ */
|
18
|
+
|
19
|
+
/* Hash values are masked with the table hash mask and used as an index. */
|
20
|
+
static LJ_AINLINE Node *hashmask(const GCtab *t, uint32_t hash)
|
21
|
+
{
|
22
|
+
Node *n = noderef(t->node);
|
23
|
+
return &n[hash & t->hmask];
|
24
|
+
}
|
25
|
+
|
26
|
+
/* String hashes are precomputed when they are interned. */
|
27
|
+
#define hashstr(t, s) hashmask(t, (s)->hash)
|
28
|
+
|
29
|
+
#define hashlohi(t, lo, hi) hashmask((t), hashrot((lo), (hi)))
|
30
|
+
#define hashnum(t, o) hashlohi((t), (o)->u32.lo, ((o)->u32.hi << 1))
|
31
|
+
#define hashptr(t, p) hashlohi((t), u32ptr(p), u32ptr(p) + HASH_BIAS)
|
32
|
+
#if LJ_GC64
|
33
|
+
#define hashgcref(t, r) \
|
34
|
+
hashlohi((t), (uint32_t)gcrefu(r), (uint32_t)(gcrefu(r) >> 32))
|
35
|
+
#else
|
36
|
+
#define hashgcref(t, r) hashlohi((t), gcrefu(r), gcrefu(r) + HASH_BIAS)
|
37
|
+
#endif
|
38
|
+
|
39
|
+
/* Hash an arbitrary key and return its anchor position in the hash table. */
|
40
|
+
static Node *hashkey(const GCtab *t, cTValue *key)
|
41
|
+
{
|
42
|
+
lua_assert(!tvisint(key));
|
43
|
+
if (tvisstr(key))
|
44
|
+
return hashstr(t, strV(key));
|
45
|
+
else if (tvisnum(key))
|
46
|
+
return hashnum(t, key);
|
47
|
+
else if (tvisbool(key))
|
48
|
+
return hashmask(t, boolV(key));
|
49
|
+
else
|
50
|
+
return hashgcref(t, key->gcr);
|
51
|
+
/* Only hash 32 bits of lightuserdata on a 64 bit CPU. Good enough? */
|
52
|
+
}
|
53
|
+
|
54
|
+
/* -- Table creation and destruction -------------------------------------- */
|
55
|
+
|
56
|
+
/* Create new hash part for table. */
|
57
|
+
static LJ_AINLINE void newhpart(lua_State *L, GCtab *t, uint32_t hbits)
|
58
|
+
{
|
59
|
+
uint32_t hsize;
|
60
|
+
Node *node;
|
61
|
+
lua_assert(hbits != 0);
|
62
|
+
if (hbits > LJ_MAX_HBITS)
|
63
|
+
lj_err_msg(L, LJ_ERR_TABOV);
|
64
|
+
hsize = 1u << hbits;
|
65
|
+
node = lj_mem_newvec(L, hsize, Node);
|
66
|
+
setmref(t->node, node);
|
67
|
+
setfreetop(t, node, &node[hsize]);
|
68
|
+
t->hmask = hsize-1;
|
69
|
+
}
|
70
|
+
|
71
|
+
/*
|
72
|
+
** Q: Why all of these copies of t->hmask, t->node etc. to local variables?
|
73
|
+
** A: Because alias analysis for C is _really_ tough.
|
74
|
+
** Even state-of-the-art C compilers won't produce good code without this.
|
75
|
+
*/
|
76
|
+
|
77
|
+
/* Clear hash part of table. */
|
78
|
+
static LJ_AINLINE void clearhpart(GCtab *t)
|
79
|
+
{
|
80
|
+
uint32_t i, hmask = t->hmask;
|
81
|
+
Node *node = noderef(t->node);
|
82
|
+
lua_assert(t->hmask != 0);
|
83
|
+
for (i = 0; i <= hmask; i++) {
|
84
|
+
Node *n = &node[i];
|
85
|
+
setmref(n->next, NULL);
|
86
|
+
setnilV(&n->key);
|
87
|
+
setnilV(&n->val);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
/* Clear array part of table. */
|
92
|
+
static LJ_AINLINE void clearapart(GCtab *t)
|
93
|
+
{
|
94
|
+
uint32_t i, asize = t->asize;
|
95
|
+
TValue *array = tvref(t->array);
|
96
|
+
for (i = 0; i < asize; i++)
|
97
|
+
setnilV(&array[i]);
|
98
|
+
}
|
99
|
+
|
100
|
+
/* Create a new table. Note: the slots are not initialized (yet). */
|
101
|
+
static GCtab *newtab(lua_State *L, uint32_t asize, uint32_t hbits)
|
102
|
+
{
|
103
|
+
GCtab *t;
|
104
|
+
/* First try to colocate the array part. */
|
105
|
+
if (LJ_MAX_COLOSIZE != 0 && asize > 0 && asize <= LJ_MAX_COLOSIZE) {
|
106
|
+
Node *nilnode;
|
107
|
+
lua_assert((sizeof(GCtab) & 7) == 0);
|
108
|
+
t = (GCtab *)lj_mem_newgco(L, sizetabcolo(asize));
|
109
|
+
t->gct = ~LJ_TTAB;
|
110
|
+
t->nomm = (uint8_t)~0;
|
111
|
+
t->colo = (int8_t)asize;
|
112
|
+
setmref(t->array, (TValue *)((char *)t + sizeof(GCtab)));
|
113
|
+
setgcrefnull(t->metatable);
|
114
|
+
t->asize = asize;
|
115
|
+
t->hmask = 0;
|
116
|
+
nilnode = &G(L)->nilnode;
|
117
|
+
setmref(t->node, nilnode);
|
118
|
+
#if LJ_GC64
|
119
|
+
setmref(t->freetop, nilnode);
|
120
|
+
#endif
|
121
|
+
} else { /* Otherwise separately allocate the array part. */
|
122
|
+
Node *nilnode;
|
123
|
+
t = lj_mem_newobj(L, GCtab);
|
124
|
+
t->gct = ~LJ_TTAB;
|
125
|
+
t->nomm = (uint8_t)~0;
|
126
|
+
t->colo = 0;
|
127
|
+
setmref(t->array, NULL);
|
128
|
+
setgcrefnull(t->metatable);
|
129
|
+
t->asize = 0; /* In case the array allocation fails. */
|
130
|
+
t->hmask = 0;
|
131
|
+
nilnode = &G(L)->nilnode;
|
132
|
+
setmref(t->node, nilnode);
|
133
|
+
#if LJ_GC64
|
134
|
+
setmref(t->freetop, nilnode);
|
135
|
+
#endif
|
136
|
+
if (asize > 0) {
|
137
|
+
if (asize > LJ_MAX_ASIZE)
|
138
|
+
lj_err_msg(L, LJ_ERR_TABOV);
|
139
|
+
setmref(t->array, lj_mem_newvec(L, asize, TValue));
|
140
|
+
t->asize = asize;
|
141
|
+
}
|
142
|
+
}
|
143
|
+
if (hbits)
|
144
|
+
newhpart(L, t, hbits);
|
145
|
+
return t;
|
146
|
+
}
|
147
|
+
|
148
|
+
/* Create a new table.
|
149
|
+
**
|
150
|
+
** IMPORTANT NOTE: The API differs from lua_createtable()!
|
151
|
+
**
|
152
|
+
** The array size is non-inclusive. E.g. asize=128 creates array slots
|
153
|
+
** for 0..127, but not for 128. If you need slots 1..128, pass asize=129
|
154
|
+
** (slot 0 is wasted in this case).
|
155
|
+
**
|
156
|
+
** The hash size is given in hash bits. hbits=0 means no hash part.
|
157
|
+
** hbits=1 creates 2 hash slots, hbits=2 creates 4 hash slots and so on.
|
158
|
+
*/
|
159
|
+
GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits)
|
160
|
+
{
|
161
|
+
GCtab *t = newtab(L, asize, hbits);
|
162
|
+
clearapart(t);
|
163
|
+
if (t->hmask > 0) clearhpart(t);
|
164
|
+
return t;
|
165
|
+
}
|
166
|
+
|
167
|
+
/* The API of this function conforms to lua_createtable(). */
|
168
|
+
GCtab *lj_tab_new_ah(lua_State *L, int32_t a, int32_t h)
|
169
|
+
{
|
170
|
+
return lj_tab_new(L, (uint32_t)(a > 0 ? a+1 : 0), hsize2hbits(h));
|
171
|
+
}
|
172
|
+
|
173
|
+
#if LJ_HASJIT
|
174
|
+
GCtab * LJ_FASTCALL lj_tab_new1(lua_State *L, uint32_t ahsize)
|
175
|
+
{
|
176
|
+
GCtab *t = newtab(L, ahsize & 0xffffff, ahsize >> 24);
|
177
|
+
clearapart(t);
|
178
|
+
if (t->hmask > 0) clearhpart(t);
|
179
|
+
return t;
|
180
|
+
}
|
181
|
+
#endif
|
182
|
+
|
183
|
+
/* Duplicate a table. */
|
184
|
+
GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt)
|
185
|
+
{
|
186
|
+
GCtab *t;
|
187
|
+
uint32_t asize, hmask;
|
188
|
+
t = newtab(L, kt->asize, kt->hmask > 0 ? lj_fls(kt->hmask)+1 : 0);
|
189
|
+
lua_assert(kt->asize == t->asize && kt->hmask == t->hmask);
|
190
|
+
t->nomm = 0; /* Keys with metamethod names may be present. */
|
191
|
+
asize = kt->asize;
|
192
|
+
if (asize > 0) {
|
193
|
+
TValue *array = tvref(t->array);
|
194
|
+
TValue *karray = tvref(kt->array);
|
195
|
+
if (asize < 64) { /* An inlined loop beats memcpy for < 512 bytes. */
|
196
|
+
uint32_t i;
|
197
|
+
for (i = 0; i < asize; i++)
|
198
|
+
copyTV(L, &array[i], &karray[i]);
|
199
|
+
} else {
|
200
|
+
memcpy(array, karray, asize*sizeof(TValue));
|
201
|
+
}
|
202
|
+
}
|
203
|
+
hmask = kt->hmask;
|
204
|
+
if (hmask > 0) {
|
205
|
+
uint32_t i;
|
206
|
+
Node *node = noderef(t->node);
|
207
|
+
Node *knode = noderef(kt->node);
|
208
|
+
ptrdiff_t d = (char *)node - (char *)knode;
|
209
|
+
setfreetop(t, node, (Node *)((char *)getfreetop(kt, knode) + d));
|
210
|
+
for (i = 0; i <= hmask; i++) {
|
211
|
+
Node *kn = &knode[i];
|
212
|
+
Node *n = &node[i];
|
213
|
+
Node *next = nextnode(kn);
|
214
|
+
/* Don't use copyTV here, since it asserts on a copy of a dead key. */
|
215
|
+
n->val = kn->val; n->key = kn->key;
|
216
|
+
setmref(n->next, next == NULL? next : (Node *)((char *)next + d));
|
217
|
+
}
|
218
|
+
}
|
219
|
+
return t;
|
220
|
+
}
|
221
|
+
|
222
|
+
/* Clear a table. */
|
223
|
+
void LJ_FASTCALL lj_tab_clear(GCtab *t)
|
224
|
+
{
|
225
|
+
clearapart(t);
|
226
|
+
if (t->hmask > 0) {
|
227
|
+
Node *node = noderef(t->node);
|
228
|
+
setfreetop(t, node, &node[t->hmask+1]);
|
229
|
+
clearhpart(t);
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
233
|
+
/* Free a table. */
|
234
|
+
void LJ_FASTCALL lj_tab_free(global_State *g, GCtab *t)
|
235
|
+
{
|
236
|
+
if (t->hmask > 0)
|
237
|
+
lj_mem_freevec(g, noderef(t->node), t->hmask+1, Node);
|
238
|
+
if (t->asize > 0 && LJ_MAX_COLOSIZE != 0 && t->colo <= 0)
|
239
|
+
lj_mem_freevec(g, tvref(t->array), t->asize, TValue);
|
240
|
+
if (LJ_MAX_COLOSIZE != 0 && t->colo)
|
241
|
+
lj_mem_free(g, t, sizetabcolo((uint32_t)t->colo & 0x7f));
|
242
|
+
else
|
243
|
+
lj_mem_freet(g, t);
|
244
|
+
}
|
245
|
+
|
246
|
+
/* -- Table resizing ------------------------------------------------------ */
|
247
|
+
|
248
|
+
/* Resize a table to fit the new array/hash part sizes. */
|
249
|
+
void lj_tab_resize(lua_State *L, GCtab *t, uint32_t asize, uint32_t hbits)
|
250
|
+
{
|
251
|
+
Node *oldnode = noderef(t->node);
|
252
|
+
uint32_t oldasize = t->asize;
|
253
|
+
uint32_t oldhmask = t->hmask;
|
254
|
+
if (asize > oldasize) { /* Array part grows? */
|
255
|
+
TValue *array;
|
256
|
+
uint32_t i;
|
257
|
+
if (asize > LJ_MAX_ASIZE)
|
258
|
+
lj_err_msg(L, LJ_ERR_TABOV);
|
259
|
+
if (LJ_MAX_COLOSIZE != 0 && t->colo > 0) {
|
260
|
+
/* A colocated array must be separated and copied. */
|
261
|
+
TValue *oarray = tvref(t->array);
|
262
|
+
array = lj_mem_newvec(L, asize, TValue);
|
263
|
+
t->colo = (int8_t)(t->colo | 0x80); /* Mark as separated (colo < 0). */
|
264
|
+
for (i = 0; i < oldasize; i++)
|
265
|
+
copyTV(L, &array[i], &oarray[i]);
|
266
|
+
} else {
|
267
|
+
array = (TValue *)lj_mem_realloc(L, tvref(t->array),
|
268
|
+
oldasize*sizeof(TValue), asize*sizeof(TValue));
|
269
|
+
}
|
270
|
+
setmref(t->array, array);
|
271
|
+
t->asize = asize;
|
272
|
+
for (i = oldasize; i < asize; i++) /* Clear newly allocated slots. */
|
273
|
+
setnilV(&array[i]);
|
274
|
+
}
|
275
|
+
/* Create new (empty) hash part. */
|
276
|
+
if (hbits) {
|
277
|
+
newhpart(L, t, hbits);
|
278
|
+
clearhpart(t);
|
279
|
+
} else {
|
280
|
+
global_State *g = G(L);
|
281
|
+
setmref(t->node, &g->nilnode);
|
282
|
+
#if LJ_GC64
|
283
|
+
setmref(t->freetop, &g->nilnode);
|
284
|
+
#endif
|
285
|
+
t->hmask = 0;
|
286
|
+
}
|
287
|
+
if (asize < oldasize) { /* Array part shrinks? */
|
288
|
+
TValue *array = tvref(t->array);
|
289
|
+
uint32_t i;
|
290
|
+
t->asize = asize; /* Note: This 'shrinks' even colocated arrays. */
|
291
|
+
for (i = asize; i < oldasize; i++) /* Reinsert old array values. */
|
292
|
+
if (!tvisnil(&array[i]))
|
293
|
+
copyTV(L, lj_tab_setinth(L, t, (int32_t)i), &array[i]);
|
294
|
+
/* Physically shrink only separated arrays. */
|
295
|
+
if (LJ_MAX_COLOSIZE != 0 && t->colo <= 0)
|
296
|
+
setmref(t->array, lj_mem_realloc(L, array,
|
297
|
+
oldasize*sizeof(TValue), asize*sizeof(TValue)));
|
298
|
+
}
|
299
|
+
if (oldhmask > 0) { /* Reinsert pairs from old hash part. */
|
300
|
+
global_State *g;
|
301
|
+
uint32_t i;
|
302
|
+
for (i = 0; i <= oldhmask; i++) {
|
303
|
+
Node *n = &oldnode[i];
|
304
|
+
if (!tvisnil(&n->val))
|
305
|
+
copyTV(L, lj_tab_set(L, t, &n->key), &n->val);
|
306
|
+
}
|
307
|
+
g = G(L);
|
308
|
+
lj_mem_freevec(g, oldnode, oldhmask+1, Node);
|
309
|
+
}
|
310
|
+
}
|
311
|
+
|
312
|
+
static uint32_t countint(cTValue *key, uint32_t *bins)
|
313
|
+
{
|
314
|
+
lua_assert(!tvisint(key));
|
315
|
+
if (tvisnum(key)) {
|
316
|
+
lua_Number nk = numV(key);
|
317
|
+
int32_t k = lj_num2int(nk);
|
318
|
+
if ((uint32_t)k < LJ_MAX_ASIZE && nk == (lua_Number)k) {
|
319
|
+
bins[(k > 2 ? lj_fls((uint32_t)(k-1)) : 0)]++;
|
320
|
+
return 1;
|
321
|
+
}
|
322
|
+
}
|
323
|
+
return 0;
|
324
|
+
}
|
325
|
+
|
326
|
+
static uint32_t countarray(const GCtab *t, uint32_t *bins)
|
327
|
+
{
|
328
|
+
uint32_t na, b, i;
|
329
|
+
if (t->asize == 0) return 0;
|
330
|
+
for (na = i = b = 0; b < LJ_MAX_ABITS; b++) {
|
331
|
+
uint32_t n, top = 2u << b;
|
332
|
+
TValue *array;
|
333
|
+
if (top >= t->asize) {
|
334
|
+
top = t->asize-1;
|
335
|
+
if (i > top)
|
336
|
+
break;
|
337
|
+
}
|
338
|
+
array = tvref(t->array);
|
339
|
+
for (n = 0; i <= top; i++)
|
340
|
+
if (!tvisnil(&array[i]))
|
341
|
+
n++;
|
342
|
+
bins[b] += n;
|
343
|
+
na += n;
|
344
|
+
}
|
345
|
+
return na;
|
346
|
+
}
|
347
|
+
|
348
|
+
static uint32_t counthash(const GCtab *t, uint32_t *bins, uint32_t *narray)
|
349
|
+
{
|
350
|
+
uint32_t total, na, i, hmask = t->hmask;
|
351
|
+
Node *node = noderef(t->node);
|
352
|
+
for (total = na = 0, i = 0; i <= hmask; i++) {
|
353
|
+
Node *n = &node[i];
|
354
|
+
if (!tvisnil(&n->val)) {
|
355
|
+
na += countint(&n->key, bins);
|
356
|
+
total++;
|
357
|
+
}
|
358
|
+
}
|
359
|
+
*narray += na;
|
360
|
+
return total;
|
361
|
+
}
|
362
|
+
|
363
|
+
static uint32_t bestasize(uint32_t bins[], uint32_t *narray)
|
364
|
+
{
|
365
|
+
uint32_t b, sum, na = 0, sz = 0, nn = *narray;
|
366
|
+
for (b = 0, sum = 0; 2*nn > (1u<<b) && sum != nn; b++)
|
367
|
+
if (bins[b] > 0 && 2*(sum += bins[b]) > (1u<<b)) {
|
368
|
+
sz = (2u<<b)+1;
|
369
|
+
na = sum;
|
370
|
+
}
|
371
|
+
*narray = sz;
|
372
|
+
return na;
|
373
|
+
}
|
374
|
+
|
375
|
+
static void rehashtab(lua_State *L, GCtab *t, cTValue *ek)
|
376
|
+
{
|
377
|
+
uint32_t bins[LJ_MAX_ABITS];
|
378
|
+
uint32_t total, asize, na, i;
|
379
|
+
for (i = 0; i < LJ_MAX_ABITS; i++) bins[i] = 0;
|
380
|
+
asize = countarray(t, bins);
|
381
|
+
total = 1 + asize;
|
382
|
+
total += counthash(t, bins, &asize);
|
383
|
+
asize += countint(ek, bins);
|
384
|
+
na = bestasize(bins, &asize);
|
385
|
+
total -= na;
|
386
|
+
lj_tab_resize(L, t, asize, hsize2hbits(total));
|
387
|
+
}
|
388
|
+
|
389
|
+
#if LJ_HASFFI
|
390
|
+
void lj_tab_rehash(lua_State *L, GCtab *t)
|
391
|
+
{
|
392
|
+
rehashtab(L, t, niltv(L));
|
393
|
+
}
|
394
|
+
#endif
|
395
|
+
|
396
|
+
void lj_tab_reasize(lua_State *L, GCtab *t, uint32_t nasize)
|
397
|
+
{
|
398
|
+
lj_tab_resize(L, t, nasize+1, t->hmask > 0 ? lj_fls(t->hmask)+1 : 0);
|
399
|
+
}
|
400
|
+
|
401
|
+
/* -- Table getters ------------------------------------------------------- */
|
402
|
+
|
403
|
+
cTValue * LJ_FASTCALL lj_tab_getinth(GCtab *t, int32_t key)
|
404
|
+
{
|
405
|
+
TValue k;
|
406
|
+
Node *n;
|
407
|
+
k.n = (lua_Number)key;
|
408
|
+
n = hashnum(t, &k);
|
409
|
+
do {
|
410
|
+
if (tvisnum(&n->key) && n->key.n == k.n)
|
411
|
+
return &n->val;
|
412
|
+
} while ((n = nextnode(n)));
|
413
|
+
return NULL;
|
414
|
+
}
|
415
|
+
|
416
|
+
cTValue *lj_tab_getstr(GCtab *t, GCstr *key)
|
417
|
+
{
|
418
|
+
Node *n = hashstr(t, key);
|
419
|
+
do {
|
420
|
+
if (tvisstr(&n->key) && strV(&n->key) == key)
|
421
|
+
return &n->val;
|
422
|
+
} while ((n = nextnode(n)));
|
423
|
+
return NULL;
|
424
|
+
}
|
425
|
+
|
426
|
+
cTValue *lj_tab_get(lua_State *L, GCtab *t, cTValue *key)
|
427
|
+
{
|
428
|
+
if (tvisstr(key)) {
|
429
|
+
cTValue *tv = lj_tab_getstr(t, strV(key));
|
430
|
+
if (tv)
|
431
|
+
return tv;
|
432
|
+
} else if (tvisint(key)) {
|
433
|
+
cTValue *tv = lj_tab_getint(t, intV(key));
|
434
|
+
if (tv)
|
435
|
+
return tv;
|
436
|
+
} else if (tvisnum(key)) {
|
437
|
+
lua_Number nk = numV(key);
|
438
|
+
int32_t k = lj_num2int(nk);
|
439
|
+
if (nk == (lua_Number)k) {
|
440
|
+
cTValue *tv = lj_tab_getint(t, k);
|
441
|
+
if (tv)
|
442
|
+
return tv;
|
443
|
+
} else {
|
444
|
+
goto genlookup; /* Else use the generic lookup. */
|
445
|
+
}
|
446
|
+
} else if (!tvisnil(key)) {
|
447
|
+
Node *n;
|
448
|
+
genlookup:
|
449
|
+
n = hashkey(t, key);
|
450
|
+
do {
|
451
|
+
if (lj_obj_equal(&n->key, key))
|
452
|
+
return &n->val;
|
453
|
+
} while ((n = nextnode(n)));
|
454
|
+
}
|
455
|
+
return niltv(L);
|
456
|
+
}
|
457
|
+
|
458
|
+
/* -- Table setters ------------------------------------------------------- */
|
459
|
+
|
460
|
+
/* Insert new key. Use Brent's variation to optimize the chain length. */
|
461
|
+
TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key)
|
462
|
+
{
|
463
|
+
Node *n = hashkey(t, key);
|
464
|
+
if (!tvisnil(&n->val) || t->hmask == 0) {
|
465
|
+
Node *nodebase = noderef(t->node);
|
466
|
+
Node *collide, *freenode = getfreetop(t, nodebase);
|
467
|
+
lua_assert(freenode >= nodebase && freenode <= nodebase+t->hmask+1);
|
468
|
+
do {
|
469
|
+
if (freenode == nodebase) { /* No free node found? */
|
470
|
+
rehashtab(L, t, key); /* Rehash table. */
|
471
|
+
return lj_tab_set(L, t, key); /* Retry key insertion. */
|
472
|
+
}
|
473
|
+
} while (!tvisnil(&(--freenode)->key));
|
474
|
+
setfreetop(t, nodebase, freenode);
|
475
|
+
lua_assert(freenode != &G(L)->nilnode);
|
476
|
+
collide = hashkey(t, &n->key);
|
477
|
+
if (collide != n) { /* Colliding node not the main node? */
|
478
|
+
while (noderef(collide->next) != n) /* Find predecessor. */
|
479
|
+
collide = nextnode(collide);
|
480
|
+
setmref(collide->next, freenode); /* Relink chain. */
|
481
|
+
/* Copy colliding node into free node and free main node. */
|
482
|
+
freenode->val = n->val;
|
483
|
+
freenode->key = n->key;
|
484
|
+
freenode->next = n->next;
|
485
|
+
setmref(n->next, NULL);
|
486
|
+
setnilV(&n->val);
|
487
|
+
/* Rechain pseudo-resurrected string keys with colliding hashes. */
|
488
|
+
while (nextnode(freenode)) {
|
489
|
+
Node *nn = nextnode(freenode);
|
490
|
+
if (tvisstr(&nn->key) && !tvisnil(&nn->val) &&
|
491
|
+
hashstr(t, strV(&nn->key)) == n) {
|
492
|
+
freenode->next = nn->next;
|
493
|
+
nn->next = n->next;
|
494
|
+
setmref(n->next, nn);
|
495
|
+
} else {
|
496
|
+
freenode = nn;
|
497
|
+
}
|
498
|
+
}
|
499
|
+
} else { /* Otherwise use free node. */
|
500
|
+
setmrefr(freenode->next, n->next); /* Insert into chain. */
|
501
|
+
setmref(n->next, freenode);
|
502
|
+
n = freenode;
|
503
|
+
}
|
504
|
+
}
|
505
|
+
n->key.u64 = key->u64;
|
506
|
+
if (LJ_UNLIKELY(tvismzero(&n->key)))
|
507
|
+
n->key.u64 = 0;
|
508
|
+
lj_gc_anybarriert(L, t);
|
509
|
+
lua_assert(tvisnil(&n->val));
|
510
|
+
return &n->val;
|
511
|
+
}
|
512
|
+
|
513
|
+
TValue *lj_tab_setinth(lua_State *L, GCtab *t, int32_t key)
|
514
|
+
{
|
515
|
+
TValue k;
|
516
|
+
Node *n;
|
517
|
+
k.n = (lua_Number)key;
|
518
|
+
n = hashnum(t, &k);
|
519
|
+
do {
|
520
|
+
if (tvisnum(&n->key) && n->key.n == k.n)
|
521
|
+
return &n->val;
|
522
|
+
} while ((n = nextnode(n)));
|
523
|
+
return lj_tab_newkey(L, t, &k);
|
524
|
+
}
|
525
|
+
|
526
|
+
TValue *lj_tab_setstr(lua_State *L, GCtab *t, GCstr *key)
|
527
|
+
{
|
528
|
+
TValue k;
|
529
|
+
Node *n = hashstr(t, key);
|
530
|
+
do {
|
531
|
+
if (tvisstr(&n->key) && strV(&n->key) == key)
|
532
|
+
return &n->val;
|
533
|
+
} while ((n = nextnode(n)));
|
534
|
+
setstrV(L, &k, key);
|
535
|
+
return lj_tab_newkey(L, t, &k);
|
536
|
+
}
|
537
|
+
|
538
|
+
TValue *lj_tab_set(lua_State *L, GCtab *t, cTValue *key)
|
539
|
+
{
|
540
|
+
Node *n;
|
541
|
+
t->nomm = 0; /* Invalidate negative metamethod cache. */
|
542
|
+
if (tvisstr(key)) {
|
543
|
+
return lj_tab_setstr(L, t, strV(key));
|
544
|
+
} else if (tvisint(key)) {
|
545
|
+
return lj_tab_setint(L, t, intV(key));
|
546
|
+
} else if (tvisnum(key)) {
|
547
|
+
lua_Number nk = numV(key);
|
548
|
+
int32_t k = lj_num2int(nk);
|
549
|
+
if (nk == (lua_Number)k)
|
550
|
+
return lj_tab_setint(L, t, k);
|
551
|
+
if (tvisnan(key))
|
552
|
+
lj_err_msg(L, LJ_ERR_NANIDX);
|
553
|
+
/* Else use the generic lookup. */
|
554
|
+
} else if (tvisnil(key)) {
|
555
|
+
lj_err_msg(L, LJ_ERR_NILIDX);
|
556
|
+
}
|
557
|
+
n = hashkey(t, key);
|
558
|
+
do {
|
559
|
+
if (lj_obj_equal(&n->key, key))
|
560
|
+
return &n->val;
|
561
|
+
} while ((n = nextnode(n)));
|
562
|
+
return lj_tab_newkey(L, t, key);
|
563
|
+
}
|
564
|
+
|
565
|
+
/* -- Table traversal ----------------------------------------------------- */
|
566
|
+
|
567
|
+
/* Get the traversal index of a key. */
|
568
|
+
static uint32_t keyindex(lua_State *L, GCtab *t, cTValue *key)
|
569
|
+
{
|
570
|
+
TValue tmp;
|
571
|
+
if (tvisint(key)) {
|
572
|
+
int32_t k = intV(key);
|
573
|
+
if ((uint32_t)k < t->asize)
|
574
|
+
return (uint32_t)k; /* Array key indexes: [0..t->asize-1] */
|
575
|
+
setnumV(&tmp, (lua_Number)k);
|
576
|
+
key = &tmp;
|
577
|
+
} else if (tvisnum(key)) {
|
578
|
+
lua_Number nk = numV(key);
|
579
|
+
int32_t k = lj_num2int(nk);
|
580
|
+
if ((uint32_t)k < t->asize && nk == (lua_Number)k)
|
581
|
+
return (uint32_t)k; /* Array key indexes: [0..t->asize-1] */
|
582
|
+
}
|
583
|
+
if (!tvisnil(key)) {
|
584
|
+
Node *n = hashkey(t, key);
|
585
|
+
do {
|
586
|
+
if (lj_obj_equal(&n->key, key))
|
587
|
+
return t->asize + (uint32_t)(n - noderef(t->node));
|
588
|
+
/* Hash key indexes: [t->asize..t->asize+t->nmask] */
|
589
|
+
} while ((n = nextnode(n)));
|
590
|
+
if (key->u32.hi == 0xfffe7fff) /* ITERN was despecialized while running. */
|
591
|
+
return key->u32.lo - 1;
|
592
|
+
lj_err_msg(L, LJ_ERR_NEXTIDX);
|
593
|
+
return 0; /* unreachable */
|
594
|
+
}
|
595
|
+
return ~0u; /* A nil key starts the traversal. */
|
596
|
+
}
|
597
|
+
|
598
|
+
/* Advance to the next step in a table traversal. */
|
599
|
+
int lj_tab_next(lua_State *L, GCtab *t, TValue *key)
|
600
|
+
{
|
601
|
+
uint32_t i = keyindex(L, t, key); /* Find predecessor key index. */
|
602
|
+
for (i++; i < t->asize; i++) /* First traverse the array keys. */
|
603
|
+
if (!tvisnil(arrayslot(t, i))) {
|
604
|
+
setintV(key, i);
|
605
|
+
copyTV(L, key+1, arrayslot(t, i));
|
606
|
+
return 1;
|
607
|
+
}
|
608
|
+
for (i -= t->asize; i <= t->hmask; i++) { /* Then traverse the hash keys. */
|
609
|
+
Node *n = &noderef(t->node)[i];
|
610
|
+
if (!tvisnil(&n->val)) {
|
611
|
+
copyTV(L, key, &n->key);
|
612
|
+
copyTV(L, key+1, &n->val);
|
613
|
+
return 1;
|
614
|
+
}
|
615
|
+
}
|
616
|
+
return 0; /* End of traversal. */
|
617
|
+
}
|
618
|
+
|
619
|
+
/* -- Table length calculation -------------------------------------------- */
|
620
|
+
|
621
|
+
static MSize unbound_search(GCtab *t, MSize j)
|
622
|
+
{
|
623
|
+
cTValue *tv;
|
624
|
+
MSize i = j; /* i is zero or a present index */
|
625
|
+
j++;
|
626
|
+
/* find `i' and `j' such that i is present and j is not */
|
627
|
+
while ((tv = lj_tab_getint(t, (int32_t)j)) && !tvisnil(tv)) {
|
628
|
+
i = j;
|
629
|
+
j *= 2;
|
630
|
+
if (j > (MSize)(INT_MAX-2)) { /* overflow? */
|
631
|
+
/* table was built with bad purposes: resort to linear search */
|
632
|
+
i = 1;
|
633
|
+
while ((tv = lj_tab_getint(t, (int32_t)i)) && !tvisnil(tv)) i++;
|
634
|
+
return i - 1;
|
635
|
+
}
|
636
|
+
}
|
637
|
+
/* now do a binary search between them */
|
638
|
+
while (j - i > 1) {
|
639
|
+
MSize m = (i+j)/2;
|
640
|
+
cTValue *tvb = lj_tab_getint(t, (int32_t)m);
|
641
|
+
if (tvb && !tvisnil(tvb)) i = m; else j = m;
|
642
|
+
}
|
643
|
+
return i;
|
644
|
+
}
|
645
|
+
|
646
|
+
/*
|
647
|
+
** Try to find a boundary in table `t'. A `boundary' is an integer index
|
648
|
+
** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
|
649
|
+
*/
|
650
|
+
MSize LJ_FASTCALL lj_tab_len(GCtab *t)
|
651
|
+
{
|
652
|
+
MSize j = (MSize)t->asize;
|
653
|
+
if (j > 1 && tvisnil(arrayslot(t, j-1))) {
|
654
|
+
MSize i = 1;
|
655
|
+
while (j - i > 1) {
|
656
|
+
MSize m = (i+j)/2;
|
657
|
+
if (tvisnil(arrayslot(t, m-1))) j = m; else i = m;
|
658
|
+
}
|
659
|
+
return i-1;
|
660
|
+
}
|
661
|
+
if (j) j--;
|
662
|
+
if (t->hmask <= 0)
|
663
|
+
return j;
|
664
|
+
return unbound_search(t, j);
|
665
|
+
}
|
666
|
+
|