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,211 @@
|
|
1
|
+
/*
|
2
|
+
** MIPS instruction emitter.
|
3
|
+
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
|
4
|
+
*/
|
5
|
+
|
6
|
+
/* -- Emit basic instructions --------------------------------------------- */
|
7
|
+
|
8
|
+
static void emit_dst(ASMState *as, MIPSIns mi, Reg rd, Reg rs, Reg rt)
|
9
|
+
{
|
10
|
+
*--as->mcp = mi | MIPSF_D(rd) | MIPSF_S(rs) | MIPSF_T(rt);
|
11
|
+
}
|
12
|
+
|
13
|
+
static void emit_dta(ASMState *as, MIPSIns mi, Reg rd, Reg rt, uint32_t a)
|
14
|
+
{
|
15
|
+
*--as->mcp = mi | MIPSF_D(rd) | MIPSF_T(rt) | MIPSF_A(a);
|
16
|
+
}
|
17
|
+
|
18
|
+
#define emit_ds(as, mi, rd, rs) emit_dst(as, (mi), (rd), (rs), 0)
|
19
|
+
#define emit_tg(as, mi, rt, rg) emit_dst(as, (mi), (rg)&31, 0, (rt))
|
20
|
+
|
21
|
+
static void emit_tsi(ASMState *as, MIPSIns mi, Reg rt, Reg rs, int32_t i)
|
22
|
+
{
|
23
|
+
*--as->mcp = mi | MIPSF_T(rt) | MIPSF_S(rs) | (i & 0xffff);
|
24
|
+
}
|
25
|
+
|
26
|
+
#define emit_ti(as, mi, rt, i) emit_tsi(as, (mi), (rt), 0, (i))
|
27
|
+
#define emit_hsi(as, mi, rh, rs, i) emit_tsi(as, (mi), (rh) & 31, (rs), (i))
|
28
|
+
|
29
|
+
static void emit_fgh(ASMState *as, MIPSIns mi, Reg rf, Reg rg, Reg rh)
|
30
|
+
{
|
31
|
+
*--as->mcp = mi | MIPSF_F(rf&31) | MIPSF_G(rg&31) | MIPSF_H(rh&31);
|
32
|
+
}
|
33
|
+
|
34
|
+
#define emit_fg(as, mi, rf, rg) emit_fgh(as, (mi), (rf), (rg), 0)
|
35
|
+
|
36
|
+
static void emit_rotr(ASMState *as, Reg dest, Reg src, Reg tmp, uint32_t shift)
|
37
|
+
{
|
38
|
+
if ((as->flags & JIT_F_MIPS32R2)) {
|
39
|
+
emit_dta(as, MIPSI_ROTR, dest, src, shift);
|
40
|
+
} else {
|
41
|
+
emit_dst(as, MIPSI_OR, dest, dest, tmp);
|
42
|
+
emit_dta(as, MIPSI_SLL, dest, src, (-shift)&31);
|
43
|
+
emit_dta(as, MIPSI_SRL, tmp, src, shift);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
/* -- Emit loads/stores --------------------------------------------------- */
|
48
|
+
|
49
|
+
/* Prefer rematerialization of BASE/L from global_State over spills. */
|
50
|
+
#define emit_canremat(ref) ((ref) <= REF_BASE)
|
51
|
+
|
52
|
+
/* Try to find a one step delta relative to another constant. */
|
53
|
+
static int emit_kdelta1(ASMState *as, Reg t, int32_t i)
|
54
|
+
{
|
55
|
+
RegSet work = ~as->freeset & RSET_GPR;
|
56
|
+
while (work) {
|
57
|
+
Reg r = rset_picktop(work);
|
58
|
+
IRRef ref = regcost_ref(as->cost[r]);
|
59
|
+
lua_assert(r != t);
|
60
|
+
if (ref < ASMREF_L) {
|
61
|
+
int32_t delta = i - (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i);
|
62
|
+
if (checki16(delta)) {
|
63
|
+
emit_tsi(as, MIPSI_ADDIU, t, r, delta);
|
64
|
+
return 1;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
rset_clear(work, r);
|
68
|
+
}
|
69
|
+
return 0; /* Failed. */
|
70
|
+
}
|
71
|
+
|
72
|
+
/* Load a 32 bit constant into a GPR. */
|
73
|
+
static void emit_loadi(ASMState *as, Reg r, int32_t i)
|
74
|
+
{
|
75
|
+
if (checki16(i)) {
|
76
|
+
emit_ti(as, MIPSI_LI, r, i);
|
77
|
+
} else {
|
78
|
+
if ((i & 0xffff)) {
|
79
|
+
int32_t jgl = i32ptr(J2G(as->J));
|
80
|
+
if ((uint32_t)(i-jgl) < 65536) {
|
81
|
+
emit_tsi(as, MIPSI_ADDIU, r, RID_JGL, i-jgl-32768);
|
82
|
+
return;
|
83
|
+
} else if (emit_kdelta1(as, r, i)) {
|
84
|
+
return;
|
85
|
+
} else if ((i >> 16) == 0) {
|
86
|
+
emit_tsi(as, MIPSI_ORI, r, RID_ZERO, i);
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
emit_tsi(as, MIPSI_ORI, r, r, i);
|
90
|
+
}
|
91
|
+
emit_ti(as, MIPSI_LUI, r, (i >> 16));
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr)))
|
96
|
+
|
97
|
+
static Reg ra_allock(ASMState *as, int32_t k, RegSet allow);
|
98
|
+
static void ra_allockreg(ASMState *as, int32_t k, Reg r);
|
99
|
+
|
100
|
+
/* Get/set from constant pointer. */
|
101
|
+
static void emit_lsptr(ASMState *as, MIPSIns mi, Reg r, void *p, RegSet allow)
|
102
|
+
{
|
103
|
+
int32_t jgl = i32ptr(J2G(as->J));
|
104
|
+
int32_t i = i32ptr(p);
|
105
|
+
Reg base;
|
106
|
+
if ((uint32_t)(i-jgl) < 65536) {
|
107
|
+
i = i-jgl-32768;
|
108
|
+
base = RID_JGL;
|
109
|
+
} else {
|
110
|
+
base = ra_allock(as, i-(int16_t)i, allow);
|
111
|
+
}
|
112
|
+
emit_tsi(as, mi, r, base, i);
|
113
|
+
}
|
114
|
+
|
115
|
+
#define emit_loadn(as, r, tv) \
|
116
|
+
emit_lsptr(as, MIPSI_LDC1, ((r) & 31), (void *)(tv), RSET_GPR)
|
117
|
+
|
118
|
+
/* Get/set global_State fields. */
|
119
|
+
static void emit_lsglptr(ASMState *as, MIPSIns mi, Reg r, int32_t ofs)
|
120
|
+
{
|
121
|
+
emit_tsi(as, mi, r, RID_JGL, ofs-32768);
|
122
|
+
}
|
123
|
+
|
124
|
+
#define emit_getgl(as, r, field) \
|
125
|
+
emit_lsglptr(as, MIPSI_LW, (r), (int32_t)offsetof(global_State, field))
|
126
|
+
#define emit_setgl(as, r, field) \
|
127
|
+
emit_lsglptr(as, MIPSI_SW, (r), (int32_t)offsetof(global_State, field))
|
128
|
+
|
129
|
+
/* Trace number is determined from per-trace exit stubs. */
|
130
|
+
#define emit_setvmstate(as, i) UNUSED(i)
|
131
|
+
|
132
|
+
/* -- Emit control-flow instructions -------------------------------------- */
|
133
|
+
|
134
|
+
/* Label for internal jumps. */
|
135
|
+
typedef MCode *MCLabel;
|
136
|
+
|
137
|
+
/* Return label pointing to current PC. */
|
138
|
+
#define emit_label(as) ((as)->mcp)
|
139
|
+
|
140
|
+
static void emit_branch(ASMState *as, MIPSIns mi, Reg rs, Reg rt, MCode *target)
|
141
|
+
{
|
142
|
+
MCode *p = as->mcp;
|
143
|
+
ptrdiff_t delta = target - p;
|
144
|
+
lua_assert(((delta + 0x8000) >> 16) == 0);
|
145
|
+
*--p = mi | MIPSF_S(rs) | MIPSF_T(rt) | ((uint32_t)delta & 0xffffu);
|
146
|
+
as->mcp = p;
|
147
|
+
}
|
148
|
+
|
149
|
+
static void emit_jmp(ASMState *as, MCode *target)
|
150
|
+
{
|
151
|
+
*--as->mcp = MIPSI_NOP;
|
152
|
+
emit_branch(as, MIPSI_B, RID_ZERO, RID_ZERO, (target));
|
153
|
+
}
|
154
|
+
|
155
|
+
static void emit_call(ASMState *as, void *target)
|
156
|
+
{
|
157
|
+
MCode *p = as->mcp;
|
158
|
+
*--p = MIPSI_NOP;
|
159
|
+
if ((((uintptr_t)target ^ (uintptr_t)p) >> 28) == 0)
|
160
|
+
*--p = MIPSI_JAL | (((uintptr_t)target >>2) & 0x03ffffffu);
|
161
|
+
else /* Target out of range: need indirect call. */
|
162
|
+
*--p = MIPSI_JALR | MIPSF_S(RID_CFUNCADDR);
|
163
|
+
as->mcp = p;
|
164
|
+
ra_allockreg(as, i32ptr(target), RID_CFUNCADDR);
|
165
|
+
}
|
166
|
+
|
167
|
+
/* -- Emit generic operations --------------------------------------------- */
|
168
|
+
|
169
|
+
#define emit_move(as, dst, src) \
|
170
|
+
emit_ds(as, MIPSI_MOVE, (dst), (src))
|
171
|
+
|
172
|
+
/* Generic move between two regs. */
|
173
|
+
static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src)
|
174
|
+
{
|
175
|
+
if (dst < RID_MAX_GPR)
|
176
|
+
emit_move(as, dst, src);
|
177
|
+
else
|
178
|
+
emit_fg(as, irt_isnum(ir->t) ? MIPSI_MOV_D : MIPSI_MOV_S, dst, src);
|
179
|
+
}
|
180
|
+
|
181
|
+
/* Generic load of register with base and (small) offset address. */
|
182
|
+
static void emit_loadofs(ASMState *as, IRIns *ir, Reg r, Reg base, int32_t ofs)
|
183
|
+
{
|
184
|
+
if (r < RID_MAX_GPR)
|
185
|
+
emit_tsi(as, MIPSI_LW, r, base, ofs);
|
186
|
+
else
|
187
|
+
emit_tsi(as, irt_isnum(ir->t) ? MIPSI_LDC1 : MIPSI_LWC1,
|
188
|
+
(r & 31), base, ofs);
|
189
|
+
}
|
190
|
+
|
191
|
+
/* Generic store of register with base and (small) offset address. */
|
192
|
+
static void emit_storeofs(ASMState *as, IRIns *ir, Reg r, Reg base, int32_t ofs)
|
193
|
+
{
|
194
|
+
if (r < RID_MAX_GPR)
|
195
|
+
emit_tsi(as, MIPSI_SW, r, base, ofs);
|
196
|
+
else
|
197
|
+
emit_tsi(as, irt_isnum(ir->t) ? MIPSI_SDC1 : MIPSI_SWC1,
|
198
|
+
(r&31), base, ofs);
|
199
|
+
}
|
200
|
+
|
201
|
+
/* Add offset to pointer. */
|
202
|
+
static void emit_addptr(ASMState *as, Reg r, int32_t ofs)
|
203
|
+
{
|
204
|
+
if (ofs) {
|
205
|
+
lua_assert(checki16(ofs));
|
206
|
+
emit_tsi(as, MIPSI_ADDIU, r, r, ofs);
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
#define emit_spsub(as, ofs) emit_addptr(as, RID_SP, -(ofs))
|
211
|
+
|
@@ -0,0 +1,238 @@
|
|
1
|
+
/*
|
2
|
+
** PPC instruction emitter.
|
3
|
+
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
|
4
|
+
*/
|
5
|
+
|
6
|
+
/* -- Emit basic instructions --------------------------------------------- */
|
7
|
+
|
8
|
+
static void emit_tab(ASMState *as, PPCIns pi, Reg rt, Reg ra, Reg rb)
|
9
|
+
{
|
10
|
+
*--as->mcp = pi | PPCF_T(rt) | PPCF_A(ra) | PPCF_B(rb);
|
11
|
+
}
|
12
|
+
|
13
|
+
#define emit_asb(as, pi, ra, rs, rb) emit_tab(as, (pi), (rs), (ra), (rb))
|
14
|
+
#define emit_as(as, pi, ra, rs) emit_tab(as, (pi), (rs), (ra), 0)
|
15
|
+
#define emit_ab(as, pi, ra, rb) emit_tab(as, (pi), 0, (ra), (rb))
|
16
|
+
|
17
|
+
static void emit_tai(ASMState *as, PPCIns pi, Reg rt, Reg ra, int32_t i)
|
18
|
+
{
|
19
|
+
*--as->mcp = pi | PPCF_T(rt) | PPCF_A(ra) | (i & 0xffff);
|
20
|
+
}
|
21
|
+
|
22
|
+
#define emit_ti(as, pi, rt, i) emit_tai(as, (pi), (rt), 0, (i))
|
23
|
+
#define emit_ai(as, pi, ra, i) emit_tai(as, (pi), 0, (ra), (i))
|
24
|
+
#define emit_asi(as, pi, ra, rs, i) emit_tai(as, (pi), (rs), (ra), (i))
|
25
|
+
|
26
|
+
#define emit_fab(as, pi, rf, ra, rb) \
|
27
|
+
emit_tab(as, (pi), (rf)&31, (ra)&31, (rb)&31)
|
28
|
+
#define emit_fb(as, pi, rf, rb) emit_tab(as, (pi), (rf)&31, 0, (rb)&31)
|
29
|
+
#define emit_fac(as, pi, rf, ra, rc) \
|
30
|
+
emit_tab(as, (pi) | PPCF_C((rc) & 31), (rf)&31, (ra)&31, 0)
|
31
|
+
#define emit_facb(as, pi, rf, ra, rc, rb) \
|
32
|
+
emit_tab(as, (pi) | PPCF_C((rc) & 31), (rf)&31, (ra)&31, (rb)&31)
|
33
|
+
#define emit_fai(as, pi, rf, ra, i) emit_tai(as, (pi), (rf)&31, (ra), (i))
|
34
|
+
|
35
|
+
static void emit_rot(ASMState *as, PPCIns pi, Reg ra, Reg rs,
|
36
|
+
int32_t n, int32_t b, int32_t e)
|
37
|
+
{
|
38
|
+
*--as->mcp = pi | PPCF_T(rs) | PPCF_A(ra) | PPCF_B(n) |
|
39
|
+
PPCF_MB(b) | PPCF_ME(e);
|
40
|
+
}
|
41
|
+
|
42
|
+
static void emit_slwi(ASMState *as, Reg ra, Reg rs, int32_t n)
|
43
|
+
{
|
44
|
+
lua_assert(n >= 0 && n < 32);
|
45
|
+
emit_rot(as, PPCI_RLWINM, ra, rs, n, 0, 31-n);
|
46
|
+
}
|
47
|
+
|
48
|
+
static void emit_rotlwi(ASMState *as, Reg ra, Reg rs, int32_t n)
|
49
|
+
{
|
50
|
+
lua_assert(n >= 0 && n < 32);
|
51
|
+
emit_rot(as, PPCI_RLWINM, ra, rs, n, 0, 31);
|
52
|
+
}
|
53
|
+
|
54
|
+
/* -- Emit loads/stores --------------------------------------------------- */
|
55
|
+
|
56
|
+
/* Prefer rematerialization of BASE/L from global_State over spills. */
|
57
|
+
#define emit_canremat(ref) ((ref) <= REF_BASE)
|
58
|
+
|
59
|
+
/* Try to find a one step delta relative to another constant. */
|
60
|
+
static int emit_kdelta1(ASMState *as, Reg t, int32_t i)
|
61
|
+
{
|
62
|
+
RegSet work = ~as->freeset & RSET_GPR;
|
63
|
+
while (work) {
|
64
|
+
Reg r = rset_picktop(work);
|
65
|
+
IRRef ref = regcost_ref(as->cost[r]);
|
66
|
+
lua_assert(r != t);
|
67
|
+
if (ref < ASMREF_L) {
|
68
|
+
int32_t delta = i - (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i);
|
69
|
+
if (checki16(delta)) {
|
70
|
+
emit_tai(as, PPCI_ADDI, t, r, delta);
|
71
|
+
return 1;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
rset_clear(work, r);
|
75
|
+
}
|
76
|
+
return 0; /* Failed. */
|
77
|
+
}
|
78
|
+
|
79
|
+
/* Load a 32 bit constant into a GPR. */
|
80
|
+
static void emit_loadi(ASMState *as, Reg r, int32_t i)
|
81
|
+
{
|
82
|
+
if (checki16(i)) {
|
83
|
+
emit_ti(as, PPCI_LI, r, i);
|
84
|
+
} else {
|
85
|
+
if ((i & 0xffff)) {
|
86
|
+
int32_t jgl = i32ptr(J2G(as->J));
|
87
|
+
if ((uint32_t)(i-jgl) < 65536) {
|
88
|
+
emit_tai(as, PPCI_ADDI, r, RID_JGL, i-jgl-32768);
|
89
|
+
return;
|
90
|
+
} else if (emit_kdelta1(as, r, i)) {
|
91
|
+
return;
|
92
|
+
}
|
93
|
+
emit_asi(as, PPCI_ORI, r, r, i);
|
94
|
+
}
|
95
|
+
emit_ti(as, PPCI_LIS, r, (i >> 16));
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr)))
|
100
|
+
|
101
|
+
static Reg ra_allock(ASMState *as, int32_t k, RegSet allow);
|
102
|
+
|
103
|
+
/* Get/set from constant pointer. */
|
104
|
+
static void emit_lsptr(ASMState *as, PPCIns pi, Reg r, void *p, RegSet allow)
|
105
|
+
{
|
106
|
+
int32_t jgl = i32ptr(J2G(as->J));
|
107
|
+
int32_t i = i32ptr(p);
|
108
|
+
Reg base;
|
109
|
+
if ((uint32_t)(i-jgl) < 65536) {
|
110
|
+
i = i-jgl-32768;
|
111
|
+
base = RID_JGL;
|
112
|
+
} else {
|
113
|
+
base = ra_allock(as, i-(int16_t)i, allow);
|
114
|
+
}
|
115
|
+
emit_tai(as, pi, r, base, i);
|
116
|
+
}
|
117
|
+
|
118
|
+
#define emit_loadn(as, r, tv) \
|
119
|
+
emit_lsptr(as, PPCI_LFD, ((r) & 31), (void *)(tv), RSET_GPR)
|
120
|
+
|
121
|
+
/* Get/set global_State fields. */
|
122
|
+
static void emit_lsglptr(ASMState *as, PPCIns pi, Reg r, int32_t ofs)
|
123
|
+
{
|
124
|
+
emit_tai(as, pi, r, RID_JGL, ofs-32768);
|
125
|
+
}
|
126
|
+
|
127
|
+
#define emit_getgl(as, r, field) \
|
128
|
+
emit_lsglptr(as, PPCI_LWZ, (r), (int32_t)offsetof(global_State, field))
|
129
|
+
#define emit_setgl(as, r, field) \
|
130
|
+
emit_lsglptr(as, PPCI_STW, (r), (int32_t)offsetof(global_State, field))
|
131
|
+
|
132
|
+
/* Trace number is determined from per-trace exit stubs. */
|
133
|
+
#define emit_setvmstate(as, i) UNUSED(i)
|
134
|
+
|
135
|
+
/* -- Emit control-flow instructions -------------------------------------- */
|
136
|
+
|
137
|
+
/* Label for internal jumps. */
|
138
|
+
typedef MCode *MCLabel;
|
139
|
+
|
140
|
+
/* Return label pointing to current PC. */
|
141
|
+
#define emit_label(as) ((as)->mcp)
|
142
|
+
|
143
|
+
static void emit_condbranch(ASMState *as, PPCIns pi, PPCCC cc, MCode *target)
|
144
|
+
{
|
145
|
+
MCode *p = --as->mcp;
|
146
|
+
ptrdiff_t delta = (char *)target - (char *)p;
|
147
|
+
lua_assert(((delta + 0x8000) >> 16) == 0);
|
148
|
+
pi ^= (delta & 0x8000) * (PPCF_Y/0x8000);
|
149
|
+
*p = pi | PPCF_CC(cc) | ((uint32_t)delta & 0xffffu);
|
150
|
+
}
|
151
|
+
|
152
|
+
static void emit_jmp(ASMState *as, MCode *target)
|
153
|
+
{
|
154
|
+
MCode *p = --as->mcp;
|
155
|
+
ptrdiff_t delta = (char *)target - (char *)p;
|
156
|
+
*p = PPCI_B | (delta & 0x03fffffcu);
|
157
|
+
}
|
158
|
+
|
159
|
+
static void emit_call(ASMState *as, void *target)
|
160
|
+
{
|
161
|
+
MCode *p = --as->mcp;
|
162
|
+
ptrdiff_t delta = (char *)target - (char *)p;
|
163
|
+
if ((((delta>>2) + 0x00800000) >> 24) == 0) {
|
164
|
+
*p = PPCI_BL | (delta & 0x03fffffcu);
|
165
|
+
} else { /* Target out of range: need indirect call. Don't use arg reg. */
|
166
|
+
RegSet allow = RSET_GPR & ~RSET_RANGE(RID_R0, REGARG_LASTGPR+1);
|
167
|
+
Reg r = ra_allock(as, i32ptr(target), allow);
|
168
|
+
*p = PPCI_BCTRL;
|
169
|
+
p[-1] = PPCI_MTCTR | PPCF_T(r);
|
170
|
+
as->mcp = p-1;
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
/* -- Emit generic operations --------------------------------------------- */
|
175
|
+
|
176
|
+
#define emit_mr(as, dst, src) \
|
177
|
+
emit_asb(as, PPCI_MR, (dst), (src), (src))
|
178
|
+
|
179
|
+
/* Generic move between two regs. */
|
180
|
+
static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src)
|
181
|
+
{
|
182
|
+
UNUSED(ir);
|
183
|
+
if (dst < RID_MAX_GPR)
|
184
|
+
emit_mr(as, dst, src);
|
185
|
+
else
|
186
|
+
emit_fb(as, PPCI_FMR, dst, src);
|
187
|
+
}
|
188
|
+
|
189
|
+
/* Generic load of register with base and (small) offset address. */
|
190
|
+
static void emit_loadofs(ASMState *as, IRIns *ir, Reg r, Reg base, int32_t ofs)
|
191
|
+
{
|
192
|
+
if (r < RID_MAX_GPR)
|
193
|
+
emit_tai(as, PPCI_LWZ, r, base, ofs);
|
194
|
+
else
|
195
|
+
emit_fai(as, irt_isnum(ir->t) ? PPCI_LFD : PPCI_LFS, r, base, ofs);
|
196
|
+
}
|
197
|
+
|
198
|
+
/* Generic store of register with base and (small) offset address. */
|
199
|
+
static void emit_storeofs(ASMState *as, IRIns *ir, Reg r, Reg base, int32_t ofs)
|
200
|
+
{
|
201
|
+
if (r < RID_MAX_GPR)
|
202
|
+
emit_tai(as, PPCI_STW, r, base, ofs);
|
203
|
+
else
|
204
|
+
emit_fai(as, irt_isnum(ir->t) ? PPCI_STFD : PPCI_STFS, r, base, ofs);
|
205
|
+
}
|
206
|
+
|
207
|
+
/* Emit a compare (for equality) with a constant operand. */
|
208
|
+
static void emit_cmpi(ASMState *as, Reg r, int32_t k)
|
209
|
+
{
|
210
|
+
if (checki16(k)) {
|
211
|
+
emit_ai(as, PPCI_CMPWI, r, k);
|
212
|
+
} else if (checku16(k)) {
|
213
|
+
emit_ai(as, PPCI_CMPLWI, r, k);
|
214
|
+
} else {
|
215
|
+
emit_ai(as, PPCI_CMPLWI, RID_TMP, k);
|
216
|
+
emit_asi(as, PPCI_XORIS, RID_TMP, r, (k >> 16));
|
217
|
+
}
|
218
|
+
}
|
219
|
+
|
220
|
+
/* Add offset to pointer. */
|
221
|
+
static void emit_addptr(ASMState *as, Reg r, int32_t ofs)
|
222
|
+
{
|
223
|
+
if (ofs) {
|
224
|
+
emit_tai(as, PPCI_ADDI, r, r, ofs);
|
225
|
+
if (!checki16(ofs))
|
226
|
+
emit_tai(as, PPCI_ADDIS, r, r, (ofs + 32768) >> 16);
|
227
|
+
}
|
228
|
+
}
|
229
|
+
|
230
|
+
static void emit_spsub(ASMState *as, int32_t ofs)
|
231
|
+
{
|
232
|
+
if (ofs) {
|
233
|
+
emit_tai(as, PPCI_STWU, RID_TMP, RID_SP, -ofs);
|
234
|
+
emit_tai(as, PPCI_ADDI, RID_TMP, RID_SP,
|
235
|
+
CFRAME_SIZE + (as->parent ? as->parent->spadjust : 0));
|
236
|
+
}
|
237
|
+
}
|
238
|
+
|
@@ -0,0 +1,462 @@
|
|
1
|
+
/*
|
2
|
+
** x86/x64 instruction emitter.
|
3
|
+
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
|
4
|
+
*/
|
5
|
+
|
6
|
+
/* -- Emit basic instructions --------------------------------------------- */
|
7
|
+
|
8
|
+
#define MODRM(mode, r1, r2) ((MCode)((mode)+(((r1)&7)<<3)+((r2)&7)))
|
9
|
+
|
10
|
+
#if LJ_64
|
11
|
+
#define REXRB(p, rr, rb) \
|
12
|
+
{ MCode rex = 0x40 + (((rr)>>1)&4) + (((rb)>>3)&1); \
|
13
|
+
if (rex != 0x40) *--(p) = rex; }
|
14
|
+
#define FORCE_REX 0x200
|
15
|
+
#define REX_64 (FORCE_REX|0x080000)
|
16
|
+
#else
|
17
|
+
#define REXRB(p, rr, rb) ((void)0)
|
18
|
+
#define FORCE_REX 0
|
19
|
+
#define REX_64 0
|
20
|
+
#endif
|
21
|
+
|
22
|
+
#define emit_i8(as, i) (*--as->mcp = (MCode)(i))
|
23
|
+
#define emit_i32(as, i) (*(int32_t *)(as->mcp-4) = (i), as->mcp -= 4)
|
24
|
+
#define emit_u32(as, u) (*(uint32_t *)(as->mcp-4) = (u), as->mcp -= 4)
|
25
|
+
|
26
|
+
#define emit_x87op(as, xo) \
|
27
|
+
(*(uint16_t *)(as->mcp-2) = (uint16_t)(xo), as->mcp -= 2)
|
28
|
+
|
29
|
+
/* op */
|
30
|
+
static LJ_AINLINE MCode *emit_op(x86Op xo, Reg rr, Reg rb, Reg rx,
|
31
|
+
MCode *p, int delta)
|
32
|
+
{
|
33
|
+
int n = (int8_t)xo;
|
34
|
+
#if defined(__GNUC__)
|
35
|
+
if (__builtin_constant_p(xo) && n == -2)
|
36
|
+
p[delta-2] = (MCode)(xo >> 24);
|
37
|
+
else if (__builtin_constant_p(xo) && n == -3)
|
38
|
+
*(uint16_t *)(p+delta-3) = (uint16_t)(xo >> 16);
|
39
|
+
else
|
40
|
+
#endif
|
41
|
+
*(uint32_t *)(p+delta-5) = (uint32_t)xo;
|
42
|
+
p += n + delta;
|
43
|
+
#if LJ_64
|
44
|
+
{
|
45
|
+
uint32_t rex = 0x40 + ((rr>>1)&(4+(FORCE_REX>>1)))+((rx>>2)&2)+((rb>>3)&1);
|
46
|
+
if (rex != 0x40) {
|
47
|
+
rex |= (rr >> 16);
|
48
|
+
if (n == -4) { *p = (MCode)rex; rex = (MCode)(xo >> 8); }
|
49
|
+
else if ((xo & 0xffffff) == 0x6600fd) { *p = (MCode)rex; rex = 0x66; }
|
50
|
+
*--p = (MCode)rex;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
#else
|
54
|
+
UNUSED(rr); UNUSED(rb); UNUSED(rx);
|
55
|
+
#endif
|
56
|
+
return p;
|
57
|
+
}
|
58
|
+
|
59
|
+
/* op + modrm */
|
60
|
+
#define emit_opm(xo, mode, rr, rb, p, delta) \
|
61
|
+
(p[(delta)-1] = MODRM((mode), (rr), (rb)), \
|
62
|
+
emit_op((xo), (rr), (rb), 0, (p), (delta)))
|
63
|
+
|
64
|
+
/* op + modrm + sib */
|
65
|
+
#define emit_opmx(xo, mode, scale, rr, rb, rx, p) \
|
66
|
+
(p[-1] = MODRM((scale), (rx), (rb)), \
|
67
|
+
p[-2] = MODRM((mode), (rr), RID_ESP), \
|
68
|
+
emit_op((xo), (rr), (rb), (rx), (p), -1))
|
69
|
+
|
70
|
+
/* op r1, r2 */
|
71
|
+
static void emit_rr(ASMState *as, x86Op xo, Reg r1, Reg r2)
|
72
|
+
{
|
73
|
+
MCode *p = as->mcp;
|
74
|
+
as->mcp = emit_opm(xo, XM_REG, r1, r2, p, 0);
|
75
|
+
}
|
76
|
+
|
77
|
+
#if LJ_64 && defined(LUA_USE_ASSERT)
|
78
|
+
/* [addr] is sign-extended in x64 and must be in lower 2G (not 4G). */
|
79
|
+
static int32_t ptr2addr(const void *p)
|
80
|
+
{
|
81
|
+
lua_assert((uintptr_t)p < (uintptr_t)0x80000000);
|
82
|
+
return i32ptr(p);
|
83
|
+
}
|
84
|
+
#else
|
85
|
+
#define ptr2addr(p) (i32ptr((p)))
|
86
|
+
#endif
|
87
|
+
|
88
|
+
/* op r, [addr] */
|
89
|
+
static void emit_rma(ASMState *as, x86Op xo, Reg rr, const void *addr)
|
90
|
+
{
|
91
|
+
MCode *p = as->mcp;
|
92
|
+
*(int32_t *)(p-4) = ptr2addr(addr);
|
93
|
+
#if LJ_64
|
94
|
+
p[-5] = MODRM(XM_SCALE1, RID_ESP, RID_EBP);
|
95
|
+
as->mcp = emit_opm(xo, XM_OFS0, rr, RID_ESP, p, -5);
|
96
|
+
#else
|
97
|
+
as->mcp = emit_opm(xo, XM_OFS0, rr, RID_EBP, p, -4);
|
98
|
+
#endif
|
99
|
+
}
|
100
|
+
|
101
|
+
/* op r, [base+ofs] */
|
102
|
+
static void emit_rmro(ASMState *as, x86Op xo, Reg rr, Reg rb, int32_t ofs)
|
103
|
+
{
|
104
|
+
MCode *p = as->mcp;
|
105
|
+
x86Mode mode;
|
106
|
+
if (ra_hasreg(rb)) {
|
107
|
+
if (ofs == 0 && (rb&7) != RID_EBP) {
|
108
|
+
mode = XM_OFS0;
|
109
|
+
} else if (checki8(ofs)) {
|
110
|
+
*--p = (MCode)ofs;
|
111
|
+
mode = XM_OFS8;
|
112
|
+
} else {
|
113
|
+
p -= 4;
|
114
|
+
*(int32_t *)p = ofs;
|
115
|
+
mode = XM_OFS32;
|
116
|
+
}
|
117
|
+
if ((rb&7) == RID_ESP)
|
118
|
+
*--p = MODRM(XM_SCALE1, RID_ESP, RID_ESP);
|
119
|
+
} else {
|
120
|
+
*(int32_t *)(p-4) = ofs;
|
121
|
+
#if LJ_64
|
122
|
+
p[-5] = MODRM(XM_SCALE1, RID_ESP, RID_EBP);
|
123
|
+
p -= 5;
|
124
|
+
rb = RID_ESP;
|
125
|
+
#else
|
126
|
+
p -= 4;
|
127
|
+
rb = RID_EBP;
|
128
|
+
#endif
|
129
|
+
mode = XM_OFS0;
|
130
|
+
}
|
131
|
+
as->mcp = emit_opm(xo, mode, rr, rb, p, 0);
|
132
|
+
}
|
133
|
+
|
134
|
+
/* op r, [base+idx*scale+ofs] */
|
135
|
+
static void emit_rmrxo(ASMState *as, x86Op xo, Reg rr, Reg rb, Reg rx,
|
136
|
+
x86Mode scale, int32_t ofs)
|
137
|
+
{
|
138
|
+
MCode *p = as->mcp;
|
139
|
+
x86Mode mode;
|
140
|
+
if (ofs == 0 && (rb&7) != RID_EBP) {
|
141
|
+
mode = XM_OFS0;
|
142
|
+
} else if (checki8(ofs)) {
|
143
|
+
mode = XM_OFS8;
|
144
|
+
*--p = (MCode)ofs;
|
145
|
+
} else {
|
146
|
+
mode = XM_OFS32;
|
147
|
+
p -= 4;
|
148
|
+
*(int32_t *)p = ofs;
|
149
|
+
}
|
150
|
+
as->mcp = emit_opmx(xo, mode, scale, rr, rb, rx, p);
|
151
|
+
}
|
152
|
+
|
153
|
+
/* op r, i */
|
154
|
+
static void emit_gri(ASMState *as, x86Group xg, Reg rb, int32_t i)
|
155
|
+
{
|
156
|
+
MCode *p = as->mcp;
|
157
|
+
x86Op xo;
|
158
|
+
if (checki8(i)) {
|
159
|
+
*--p = (MCode)i;
|
160
|
+
xo = XG_TOXOi8(xg);
|
161
|
+
} else {
|
162
|
+
p -= 4;
|
163
|
+
*(int32_t *)p = i;
|
164
|
+
xo = XG_TOXOi(xg);
|
165
|
+
}
|
166
|
+
as->mcp = emit_opm(xo, XM_REG, (Reg)(xg & 7) | (rb & REX_64), rb, p, 0);
|
167
|
+
}
|
168
|
+
|
169
|
+
/* op [base+ofs], i */
|
170
|
+
static void emit_gmroi(ASMState *as, x86Group xg, Reg rb, int32_t ofs,
|
171
|
+
int32_t i)
|
172
|
+
{
|
173
|
+
x86Op xo;
|
174
|
+
if (checki8(i)) {
|
175
|
+
emit_i8(as, i);
|
176
|
+
xo = XG_TOXOi8(xg);
|
177
|
+
} else {
|
178
|
+
emit_i32(as, i);
|
179
|
+
xo = XG_TOXOi(xg);
|
180
|
+
}
|
181
|
+
emit_rmro(as, xo, (Reg)(xg & 7), rb, ofs);
|
182
|
+
}
|
183
|
+
|
184
|
+
#define emit_shifti(as, xg, r, i) \
|
185
|
+
(emit_i8(as, (i)), emit_rr(as, XO_SHIFTi, (Reg)(xg), (r)))
|
186
|
+
|
187
|
+
/* op r, rm/mrm */
|
188
|
+
static void emit_mrm(ASMState *as, x86Op xo, Reg rr, Reg rb)
|
189
|
+
{
|
190
|
+
MCode *p = as->mcp;
|
191
|
+
x86Mode mode = XM_REG;
|
192
|
+
if (rb == RID_MRM) {
|
193
|
+
rb = as->mrm.base;
|
194
|
+
if (rb == RID_NONE) {
|
195
|
+
rb = RID_EBP;
|
196
|
+
mode = XM_OFS0;
|
197
|
+
p -= 4;
|
198
|
+
*(int32_t *)p = as->mrm.ofs;
|
199
|
+
if (as->mrm.idx != RID_NONE)
|
200
|
+
goto mrmidx;
|
201
|
+
#if LJ_64
|
202
|
+
*--p = MODRM(XM_SCALE1, RID_ESP, RID_EBP);
|
203
|
+
rb = RID_ESP;
|
204
|
+
#endif
|
205
|
+
} else {
|
206
|
+
if (as->mrm.ofs == 0 && (rb&7) != RID_EBP) {
|
207
|
+
mode = XM_OFS0;
|
208
|
+
} else if (checki8(as->mrm.ofs)) {
|
209
|
+
*--p = (MCode)as->mrm.ofs;
|
210
|
+
mode = XM_OFS8;
|
211
|
+
} else {
|
212
|
+
p -= 4;
|
213
|
+
*(int32_t *)p = as->mrm.ofs;
|
214
|
+
mode = XM_OFS32;
|
215
|
+
}
|
216
|
+
if (as->mrm.idx != RID_NONE) {
|
217
|
+
mrmidx:
|
218
|
+
as->mcp = emit_opmx(xo, mode, as->mrm.scale, rr, rb, as->mrm.idx, p);
|
219
|
+
return;
|
220
|
+
}
|
221
|
+
if ((rb&7) == RID_ESP)
|
222
|
+
*--p = MODRM(XM_SCALE1, RID_ESP, RID_ESP);
|
223
|
+
}
|
224
|
+
}
|
225
|
+
as->mcp = emit_opm(xo, mode, rr, rb, p, 0);
|
226
|
+
}
|
227
|
+
|
228
|
+
/* op rm/mrm, i */
|
229
|
+
static void emit_gmrmi(ASMState *as, x86Group xg, Reg rb, int32_t i)
|
230
|
+
{
|
231
|
+
x86Op xo;
|
232
|
+
if (checki8(i)) {
|
233
|
+
emit_i8(as, i);
|
234
|
+
xo = XG_TOXOi8(xg);
|
235
|
+
} else {
|
236
|
+
emit_i32(as, i);
|
237
|
+
xo = XG_TOXOi(xg);
|
238
|
+
}
|
239
|
+
emit_mrm(as, xo, (Reg)(xg & 7) | (rb & REX_64), (rb & ~REX_64));
|
240
|
+
}
|
241
|
+
|
242
|
+
/* -- Emit loads/stores --------------------------------------------------- */
|
243
|
+
|
244
|
+
/* mov [base+ofs], i */
|
245
|
+
static void emit_movmroi(ASMState *as, Reg base, int32_t ofs, int32_t i)
|
246
|
+
{
|
247
|
+
emit_i32(as, i);
|
248
|
+
emit_rmro(as, XO_MOVmi, 0, base, ofs);
|
249
|
+
}
|
250
|
+
|
251
|
+
/* mov [base+ofs], r */
|
252
|
+
#define emit_movtomro(as, r, base, ofs) \
|
253
|
+
emit_rmro(as, XO_MOVto, (r), (base), (ofs))
|
254
|
+
|
255
|
+
/* Get/set global_State fields. */
|
256
|
+
#define emit_opgl(as, xo, r, field) \
|
257
|
+
emit_rma(as, (xo), (r), (void *)&J2G(as->J)->field)
|
258
|
+
#define emit_getgl(as, r, field) emit_opgl(as, XO_MOV, (r), field)
|
259
|
+
#define emit_setgl(as, r, field) emit_opgl(as, XO_MOVto, (r), field)
|
260
|
+
|
261
|
+
#define emit_setvmstate(as, i) \
|
262
|
+
(emit_i32(as, i), emit_opgl(as, XO_MOVmi, 0, vmstate))
|
263
|
+
|
264
|
+
/* mov r, i / xor r, r */
|
265
|
+
static void emit_loadi(ASMState *as, Reg r, int32_t i)
|
266
|
+
{
|
267
|
+
/* XOR r,r is shorter, but modifies the flags. This is bad for HIOP. */
|
268
|
+
if (i == 0 && !(LJ_32 && (IR(as->curins)->o == IR_HIOP ||
|
269
|
+
(as->curins+1 < as->T->nins &&
|
270
|
+
IR(as->curins+1)->o == IR_HIOP)))) {
|
271
|
+
emit_rr(as, XO_ARITH(XOg_XOR), r, r);
|
272
|
+
} else {
|
273
|
+
MCode *p = as->mcp;
|
274
|
+
*(int32_t *)(p-4) = i;
|
275
|
+
p[-5] = (MCode)(XI_MOVri+(r&7));
|
276
|
+
p -= 5;
|
277
|
+
REXRB(p, 0, r);
|
278
|
+
as->mcp = p;
|
279
|
+
}
|
280
|
+
}
|
281
|
+
|
282
|
+
/* mov r, addr */
|
283
|
+
#define emit_loada(as, r, addr) \
|
284
|
+
emit_loadi(as, (r), ptr2addr((addr)))
|
285
|
+
|
286
|
+
#if LJ_64
|
287
|
+
/* mov r, imm64 or shorter 32 bit extended load. */
|
288
|
+
static void emit_loadu64(ASMState *as, Reg r, uint64_t u64)
|
289
|
+
{
|
290
|
+
if (checku32(u64)) { /* 32 bit load clears upper 32 bits. */
|
291
|
+
emit_loadi(as, r, (int32_t)u64);
|
292
|
+
} else if (checki32((int64_t)u64)) { /* Sign-extended 32 bit load. */
|
293
|
+
MCode *p = as->mcp;
|
294
|
+
*(int32_t *)(p-4) = (int32_t)u64;
|
295
|
+
as->mcp = emit_opm(XO_MOVmi, XM_REG, REX_64, r, p, -4);
|
296
|
+
} else { /* Full-size 64 bit load. */
|
297
|
+
MCode *p = as->mcp;
|
298
|
+
*(uint64_t *)(p-8) = u64;
|
299
|
+
p[-9] = (MCode)(XI_MOVri+(r&7));
|
300
|
+
p[-10] = 0x48 + ((r>>3)&1);
|
301
|
+
p -= 10;
|
302
|
+
as->mcp = p;
|
303
|
+
}
|
304
|
+
}
|
305
|
+
#endif
|
306
|
+
|
307
|
+
/* movsd r, [&tv->n] / xorps r, r */
|
308
|
+
static void emit_loadn(ASMState *as, Reg r, cTValue *tv)
|
309
|
+
{
|
310
|
+
if (tvispzero(tv)) /* Use xor only for +0. */
|
311
|
+
emit_rr(as, XO_XORPS, r, r);
|
312
|
+
else
|
313
|
+
emit_rma(as, XO_MOVSD, r, &tv->n);
|
314
|
+
}
|
315
|
+
|
316
|
+
/* -- Emit control-flow instructions -------------------------------------- */
|
317
|
+
|
318
|
+
/* Label for short jumps. */
|
319
|
+
typedef MCode *MCLabel;
|
320
|
+
|
321
|
+
#if LJ_32 && LJ_HASFFI
|
322
|
+
/* jmp short target */
|
323
|
+
static void emit_sjmp(ASMState *as, MCLabel target)
|
324
|
+
{
|
325
|
+
MCode *p = as->mcp;
|
326
|
+
ptrdiff_t delta = target - p;
|
327
|
+
lua_assert(delta == (int8_t)delta);
|
328
|
+
p[-1] = (MCode)(int8_t)delta;
|
329
|
+
p[-2] = XI_JMPs;
|
330
|
+
as->mcp = p - 2;
|
331
|
+
}
|
332
|
+
#endif
|
333
|
+
|
334
|
+
/* jcc short target */
|
335
|
+
static void emit_sjcc(ASMState *as, int cc, MCLabel target)
|
336
|
+
{
|
337
|
+
MCode *p = as->mcp;
|
338
|
+
ptrdiff_t delta = target - p;
|
339
|
+
lua_assert(delta == (int8_t)delta);
|
340
|
+
p[-1] = (MCode)(int8_t)delta;
|
341
|
+
p[-2] = (MCode)(XI_JCCs+(cc&15));
|
342
|
+
as->mcp = p - 2;
|
343
|
+
}
|
344
|
+
|
345
|
+
/* jcc short (pending target) */
|
346
|
+
static MCLabel emit_sjcc_label(ASMState *as, int cc)
|
347
|
+
{
|
348
|
+
MCode *p = as->mcp;
|
349
|
+
p[-1] = 0;
|
350
|
+
p[-2] = (MCode)(XI_JCCs+(cc&15));
|
351
|
+
as->mcp = p - 2;
|
352
|
+
return p;
|
353
|
+
}
|
354
|
+
|
355
|
+
/* Fixup jcc short target. */
|
356
|
+
static void emit_sfixup(ASMState *as, MCLabel source)
|
357
|
+
{
|
358
|
+
source[-1] = (MCode)(as->mcp-source);
|
359
|
+
}
|
360
|
+
|
361
|
+
/* Return label pointing to current PC. */
|
362
|
+
#define emit_label(as) ((as)->mcp)
|
363
|
+
|
364
|
+
/* Compute relative 32 bit offset for jump and call instructions. */
|
365
|
+
static LJ_AINLINE int32_t jmprel(MCode *p, MCode *target)
|
366
|
+
{
|
367
|
+
ptrdiff_t delta = target - p;
|
368
|
+
lua_assert(delta == (int32_t)delta);
|
369
|
+
return (int32_t)delta;
|
370
|
+
}
|
371
|
+
|
372
|
+
/* jcc target */
|
373
|
+
static void emit_jcc(ASMState *as, int cc, MCode *target)
|
374
|
+
{
|
375
|
+
MCode *p = as->mcp;
|
376
|
+
*(int32_t *)(p-4) = jmprel(p, target);
|
377
|
+
p[-5] = (MCode)(XI_JCCn+(cc&15));
|
378
|
+
p[-6] = 0x0f;
|
379
|
+
as->mcp = p - 6;
|
380
|
+
}
|
381
|
+
|
382
|
+
/* jmp target */
|
383
|
+
static void emit_jmp(ASMState *as, MCode *target)
|
384
|
+
{
|
385
|
+
MCode *p = as->mcp;
|
386
|
+
*(int32_t *)(p-4) = jmprel(p, target);
|
387
|
+
p[-5] = XI_JMP;
|
388
|
+
as->mcp = p - 5;
|
389
|
+
}
|
390
|
+
|
391
|
+
/* call target */
|
392
|
+
static void emit_call_(ASMState *as, MCode *target)
|
393
|
+
{
|
394
|
+
MCode *p = as->mcp;
|
395
|
+
#if LJ_64
|
396
|
+
if (target-p != (int32_t)(target-p)) {
|
397
|
+
/* Assumes RID_RET is never an argument to calls and always clobbered. */
|
398
|
+
emit_rr(as, XO_GROUP5, XOg_CALL, RID_RET);
|
399
|
+
emit_loadu64(as, RID_RET, (uint64_t)target);
|
400
|
+
return;
|
401
|
+
}
|
402
|
+
#endif
|
403
|
+
*(int32_t *)(p-4) = jmprel(p, target);
|
404
|
+
p[-5] = XI_CALL;
|
405
|
+
as->mcp = p - 5;
|
406
|
+
}
|
407
|
+
|
408
|
+
#define emit_call(as, f) emit_call_(as, (MCode *)(void *)(f))
|
409
|
+
|
410
|
+
/* -- Emit generic operations --------------------------------------------- */
|
411
|
+
|
412
|
+
/* Use 64 bit operations to handle 64 bit IR types. */
|
413
|
+
#if LJ_64
|
414
|
+
#define REX_64IR(ir, r) ((r) + (irt_is64((ir)->t) ? REX_64 : 0))
|
415
|
+
#else
|
416
|
+
#define REX_64IR(ir, r) (r)
|
417
|
+
#endif
|
418
|
+
|
419
|
+
/* Generic move between two regs. */
|
420
|
+
static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src)
|
421
|
+
{
|
422
|
+
UNUSED(ir);
|
423
|
+
if (dst < RID_MAX_GPR)
|
424
|
+
emit_rr(as, XO_MOV, REX_64IR(ir, dst), src);
|
425
|
+
else
|
426
|
+
emit_rr(as, XO_MOVAPS, dst, src);
|
427
|
+
}
|
428
|
+
|
429
|
+
/* Generic load of register with base and (small) offset address. */
|
430
|
+
static void emit_loadofs(ASMState *as, IRIns *ir, Reg r, Reg base, int32_t ofs)
|
431
|
+
{
|
432
|
+
if (r < RID_MAX_GPR)
|
433
|
+
emit_rmro(as, XO_MOV, REX_64IR(ir, r), base, ofs);
|
434
|
+
else
|
435
|
+
emit_rmro(as, irt_isnum(ir->t) ? XO_MOVSD : XO_MOVSS, r, base, ofs);
|
436
|
+
}
|
437
|
+
|
438
|
+
/* Generic store of register with base and (small) offset address. */
|
439
|
+
static void emit_storeofs(ASMState *as, IRIns *ir, Reg r, Reg base, int32_t ofs)
|
440
|
+
{
|
441
|
+
if (r < RID_MAX_GPR)
|
442
|
+
emit_rmro(as, XO_MOVto, REX_64IR(ir, r), base, ofs);
|
443
|
+
else
|
444
|
+
emit_rmro(as, irt_isnum(ir->t) ? XO_MOVSDto : XO_MOVSSto, r, base, ofs);
|
445
|
+
}
|
446
|
+
|
447
|
+
/* Add offset to pointer. */
|
448
|
+
static void emit_addptr(ASMState *as, Reg r, int32_t ofs)
|
449
|
+
{
|
450
|
+
if (ofs) {
|
451
|
+
if ((as->flags & JIT_F_LEA_AGU))
|
452
|
+
emit_rmro(as, XO_LEA, r, r, ofs);
|
453
|
+
else
|
454
|
+
emit_gri(as, XG_ARITHi(XOg_ADD), r, ofs);
|
455
|
+
}
|
456
|
+
}
|
457
|
+
|
458
|
+
#define emit_spsub(as, ofs) emit_addptr(as, RID_ESP|REX_64, -(ofs))
|
459
|
+
|
460
|
+
/* Prefer rematerialization of BASE/L from global_State over spills. */
|
461
|
+
#define emit_canremat(ref) ((ref) <= REF_BASE)
|
462
|
+
|