immunio 1.2.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -5
- data/ext/immunio/Rakefile +14 -6
- data/lib/immunio/context.rb +2 -0
- data/lib/immunio/plugins/action_view.rb +7 -668
- data/lib/immunio/plugins/action_view/action_view.rb +22 -0
- data/lib/immunio/plugins/action_view/active_support_hash.rb +29 -0
- data/lib/immunio/plugins/action_view/cache_store.rb +24 -0
- data/lib/immunio/plugins/action_view/erubi.rb +38 -0
- data/lib/immunio/plugins/action_view/erubis.rb +39 -0
- data/lib/immunio/plugins/action_view/fragment_caching.rb +29 -0
- data/lib/immunio/plugins/action_view/haml.rb +46 -0
- data/lib/immunio/plugins/action_view/slim.rb +42 -0
- data/lib/immunio/plugins/action_view/template.rb +431 -0
- data/lib/immunio/plugins/action_view/template_rendering.rb +45 -0
- data/lib/immunio/plugins/http_tracker.rb +2 -0
- data/lib/immunio/plugins/io.rb +34 -0
- data/lib/immunio/version.rb +1 -1
- data/lua-hooks/Makefile +36 -9
- data/lua-hooks/ext/luajit/COPYRIGHT +1 -1
- data/lua-hooks/ext/luajit/Makefile +22 -15
- data/lua-hooks/ext/luajit/README +2 -2
- data/lua-hooks/ext/luajit/doc/bluequad-print.css +1 -1
- data/lua-hooks/ext/luajit/doc/bluequad.css +1 -1
- data/lua-hooks/ext/luajit/doc/changes.html +69 -3
- data/lua-hooks/ext/luajit/doc/contact.html +10 -3
- data/lua-hooks/ext/luajit/doc/ext_c_api.html +2 -2
- data/lua-hooks/ext/luajit/doc/ext_ffi.html +2 -2
- data/lua-hooks/ext/luajit/doc/ext_ffi_api.html +2 -2
- data/lua-hooks/ext/luajit/doc/ext_ffi_semantics.html +3 -4
- data/lua-hooks/ext/luajit/doc/ext_ffi_tutorial.html +2 -2
- data/lua-hooks/ext/luajit/doc/ext_jit.html +3 -3
- data/lua-hooks/ext/luajit/doc/ext_profiler.html +2 -2
- data/lua-hooks/ext/luajit/doc/extensions.html +47 -20
- data/lua-hooks/ext/luajit/doc/faq.html +2 -2
- data/lua-hooks/ext/luajit/doc/install.html +74 -45
- data/lua-hooks/ext/luajit/doc/luajit.html +5 -5
- data/lua-hooks/ext/luajit/doc/running.html +3 -3
- data/lua-hooks/ext/luajit/doc/status.html +13 -8
- data/lua-hooks/ext/luajit/dynasm/dasm_arm.h +1 -1
- data/lua-hooks/ext/luajit/dynasm/dasm_arm.lua +1 -1
- data/lua-hooks/ext/luajit/dynasm/dasm_arm64.h +1 -1
- data/lua-hooks/ext/luajit/dynasm/dasm_arm64.lua +1 -1
- data/lua-hooks/ext/luajit/dynasm/dasm_mips.h +8 -5
- data/lua-hooks/ext/luajit/dynasm/dasm_mips.lua +66 -11
- data/lua-hooks/ext/luajit/dynasm/dasm_mips64.lua +12 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_ppc.h +1 -1
- data/lua-hooks/ext/luajit/dynasm/dasm_ppc.lua +1 -1
- data/lua-hooks/ext/luajit/dynasm/dasm_proto.h +1 -1
- data/lua-hooks/ext/luajit/dynasm/dasm_x64.lua +1 -1
- data/lua-hooks/ext/luajit/dynasm/dasm_x86.h +1 -1
- data/lua-hooks/ext/luajit/dynasm/dasm_x86.lua +5 -1
- data/lua-hooks/ext/luajit/dynasm/dynasm.lua +2 -2
- data/lua-hooks/ext/luajit/etc/luajit.1 +1 -1
- data/lua-hooks/ext/luajit/etc/luajit.pc +1 -1
- data/lua-hooks/ext/luajit/src/Makefile +15 -11
- data/lua-hooks/ext/luajit/src/Makefile.dep +16 -16
- data/lua-hooks/ext/luajit/src/host/buildvm.c +2 -2
- data/lua-hooks/ext/luajit/src/host/buildvm.h +1 -1
- data/lua-hooks/ext/luajit/src/host/buildvm_asm.c +9 -4
- data/lua-hooks/ext/luajit/src/host/buildvm_fold.c +2 -2
- data/lua-hooks/ext/luajit/src/host/buildvm_lib.c +1 -1
- data/lua-hooks/ext/luajit/src/host/buildvm_libbc.h +14 -3
- data/lua-hooks/ext/luajit/src/host/buildvm_peobj.c +27 -3
- data/lua-hooks/ext/luajit/src/host/genlibbc.lua +1 -1
- data/lua-hooks/ext/luajit/src/host/genminilua.lua +6 -5
- data/lua-hooks/ext/luajit/src/host/minilua.c +1 -1
- data/lua-hooks/ext/luajit/src/jit/bc.lua +1 -1
- data/lua-hooks/ext/luajit/src/jit/bcsave.lua +8 -8
- data/lua-hooks/ext/luajit/src/jit/dis_arm.lua +2 -2
- data/lua-hooks/ext/luajit/src/jit/dis_arm64.lua +1216 -0
- data/lua-hooks/ext/luajit/src/jit/dis_arm64be.lua +12 -0
- data/lua-hooks/ext/luajit/src/jit/dis_mips.lua +35 -20
- data/lua-hooks/ext/luajit/src/jit/dis_mips64.lua +17 -0
- data/lua-hooks/ext/luajit/src/jit/dis_mips64el.lua +17 -0
- data/lua-hooks/ext/luajit/src/jit/dis_mipsel.lua +1 -1
- data/lua-hooks/ext/luajit/src/jit/dis_ppc.lua +2 -2
- data/lua-hooks/ext/luajit/src/jit/dis_x64.lua +1 -1
- data/lua-hooks/ext/luajit/src/jit/dis_x86.lua +7 -4
- data/lua-hooks/ext/luajit/src/jit/dump.lua +17 -12
- data/lua-hooks/ext/luajit/src/jit/p.lua +3 -2
- data/lua-hooks/ext/luajit/src/jit/v.lua +2 -2
- data/lua-hooks/ext/luajit/src/jit/zone.lua +1 -1
- data/lua-hooks/ext/luajit/src/lauxlib.h +14 -20
- data/lua-hooks/ext/luajit/src/lib_aux.c +38 -27
- data/lua-hooks/ext/luajit/src/lib_base.c +12 -5
- data/lua-hooks/ext/luajit/src/lib_bit.c +1 -1
- data/lua-hooks/ext/luajit/src/lib_debug.c +5 -5
- data/lua-hooks/ext/luajit/src/lib_ffi.c +2 -2
- data/lua-hooks/ext/luajit/src/lib_init.c +16 -16
- data/lua-hooks/ext/luajit/src/lib_io.c +6 -7
- data/lua-hooks/ext/luajit/src/lib_jit.c +14 -4
- data/lua-hooks/ext/luajit/src/lib_math.c +1 -5
- data/lua-hooks/ext/luajit/src/lib_os.c +1 -1
- data/lua-hooks/ext/luajit/src/lib_package.c +14 -23
- data/lua-hooks/ext/luajit/src/lib_string.c +1 -5
- data/lua-hooks/ext/luajit/src/lib_table.c +21 -1
- data/lua-hooks/ext/luajit/src/lj.supp +3 -3
- data/lua-hooks/ext/luajit/src/lj_alloc.c +174 -83
- data/lua-hooks/ext/luajit/src/lj_api.c +97 -18
- data/lua-hooks/ext/luajit/src/lj_arch.h +54 -22
- data/lua-hooks/ext/luajit/src/lj_asm.c +172 -53
- data/lua-hooks/ext/luajit/src/lj_asm.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_asm_arm.h +19 -16
- data/lua-hooks/ext/luajit/src/lj_asm_arm64.h +2022 -0
- data/lua-hooks/ext/luajit/src/lj_asm_mips.h +564 -158
- data/lua-hooks/ext/luajit/src/lj_asm_ppc.h +19 -18
- data/lua-hooks/ext/luajit/src/lj_asm_x86.h +578 -92
- data/lua-hooks/ext/luajit/src/lj_bc.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_bc.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_bcdump.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_bcread.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_bcwrite.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_buf.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_buf.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_carith.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_carith.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_ccall.c +172 -7
- data/lua-hooks/ext/luajit/src/lj_ccall.h +21 -5
- data/lua-hooks/ext/luajit/src/lj_ccallback.c +71 -17
- data/lua-hooks/ext/luajit/src/lj_ccallback.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_cconv.c +4 -2
- data/lua-hooks/ext/luajit/src/lj_cconv.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_cdata.c +7 -5
- data/lua-hooks/ext/luajit/src/lj_cdata.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_clib.c +5 -5
- data/lua-hooks/ext/luajit/src/lj_clib.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_cparse.c +11 -6
- data/lua-hooks/ext/luajit/src/lj_cparse.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_crecord.c +70 -14
- data/lua-hooks/ext/luajit/src/lj_crecord.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_ctype.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_ctype.h +8 -8
- data/lua-hooks/ext/luajit/src/lj_debug.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_debug.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_def.h +6 -9
- data/lua-hooks/ext/luajit/src/lj_dispatch.c +3 -3
- data/lua-hooks/ext/luajit/src/lj_dispatch.h +2 -1
- data/lua-hooks/ext/luajit/src/lj_emit_arm.h +5 -4
- data/lua-hooks/ext/luajit/src/lj_emit_arm64.h +419 -0
- data/lua-hooks/ext/luajit/src/lj_emit_mips.h +100 -20
- data/lua-hooks/ext/luajit/src/lj_emit_ppc.h +4 -4
- data/lua-hooks/ext/luajit/src/lj_emit_x86.h +116 -25
- data/lua-hooks/ext/luajit/src/lj_err.c +34 -13
- data/lua-hooks/ext/luajit/src/lj_err.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_errmsg.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_ff.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_ffrecord.c +58 -49
- data/lua-hooks/ext/luajit/src/lj_ffrecord.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_frame.h +33 -6
- data/lua-hooks/ext/luajit/src/lj_func.c +4 -2
- data/lua-hooks/ext/luajit/src/lj_func.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_gc.c +16 -7
- data/lua-hooks/ext/luajit/src/lj_gc.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_gdbjit.c +31 -1
- data/lua-hooks/ext/luajit/src/lj_gdbjit.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_ir.c +69 -96
- data/lua-hooks/ext/luajit/src/lj_ir.h +29 -18
- data/lua-hooks/ext/luajit/src/lj_ircall.h +24 -30
- data/lua-hooks/ext/luajit/src/lj_iropt.h +9 -9
- data/lua-hooks/ext/luajit/src/lj_jit.h +67 -9
- data/lua-hooks/ext/luajit/src/lj_lex.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_lex.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_lib.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_lib.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_load.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_mcode.c +11 -10
- data/lua-hooks/ext/luajit/src/lj_mcode.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_meta.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_meta.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_obj.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_obj.h +7 -3
- data/lua-hooks/ext/luajit/src/lj_opt_dce.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_opt_fold.c +84 -17
- data/lua-hooks/ext/luajit/src/lj_opt_loop.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_opt_mem.c +3 -3
- data/lua-hooks/ext/luajit/src/lj_opt_narrow.c +24 -22
- data/lua-hooks/ext/luajit/src/lj_opt_sink.c +11 -6
- data/lua-hooks/ext/luajit/src/lj_opt_split.c +11 -2
- data/lua-hooks/ext/luajit/src/lj_parse.c +9 -7
- data/lua-hooks/ext/luajit/src/lj_parse.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_profile.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_profile.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_record.c +201 -117
- data/lua-hooks/ext/luajit/src/lj_record.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_snap.c +72 -26
- data/lua-hooks/ext/luajit/src/lj_snap.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_state.c +6 -6
- data/lua-hooks/ext/luajit/src/lj_state.h +2 -2
- data/lua-hooks/ext/luajit/src/lj_str.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_str.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_strfmt.c +7 -3
- data/lua-hooks/ext/luajit/src/lj_strfmt.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_strfmt_num.c +4 -3
- data/lua-hooks/ext/luajit/src/lj_strscan.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_strscan.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_tab.c +1 -2
- data/lua-hooks/ext/luajit/src/lj_tab.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_target.h +3 -3
- data/lua-hooks/ext/luajit/src/lj_target_arm.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_target_arm64.h +239 -7
- data/lua-hooks/ext/luajit/src/lj_target_mips.h +111 -22
- data/lua-hooks/ext/luajit/src/lj_target_ppc.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_target_x86.h +21 -4
- data/lua-hooks/ext/luajit/src/lj_trace.c +63 -18
- data/lua-hooks/ext/luajit/src/lj_trace.h +2 -1
- data/lua-hooks/ext/luajit/src/lj_traceerr.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_udata.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_udata.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_vm.h +5 -1
- data/lua-hooks/ext/luajit/src/lj_vmevent.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_vmevent.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_vmmath.c +1 -1
- data/lua-hooks/ext/luajit/src/ljamalg.c +1 -1
- data/lua-hooks/ext/luajit/src/lua.h +9 -1
- data/lua-hooks/ext/luajit/src/luaconf.h +3 -7
- data/lua-hooks/ext/luajit/src/luajit.c +69 -54
- data/lua-hooks/ext/luajit/src/luajit.h +4 -4
- data/lua-hooks/ext/luajit/src/lualib.h +1 -1
- data/lua-hooks/ext/luajit/src/msvcbuild.bat +12 -4
- data/lua-hooks/ext/luajit/src/vm_arm.dasc +1 -1
- data/lua-hooks/ext/luajit/src/vm_arm64.dasc +255 -32
- data/lua-hooks/ext/luajit/src/vm_mips.dasc +26 -23
- data/lua-hooks/ext/luajit/src/vm_mips64.dasc +5062 -0
- data/lua-hooks/ext/luajit/src/vm_ppc.dasc +1 -1
- data/lua-hooks/ext/luajit/src/vm_x64.dasc +24 -25
- data/lua-hooks/ext/luajit/src/vm_x86.dasc +77 -4
- data/lua-hooks/libluahooks.darwin.a +0 -0
- data/lua-hooks/libluahooks.linux.a +0 -0
- data/lua-hooks/options.mk +1 -1
- metadata +37 -77
- data/lua-hooks/ext/all.c +0 -69
- data/lua-hooks/ext/libinjection/COPYING +0 -37
- data/lua-hooks/ext/libinjection/libinjection.h +0 -65
- data/lua-hooks/ext/libinjection/libinjection_html5.c +0 -847
- data/lua-hooks/ext/libinjection/libinjection_html5.h +0 -54
- data/lua-hooks/ext/libinjection/libinjection_sqli.c +0 -2301
- data/lua-hooks/ext/libinjection/libinjection_sqli.h +0 -295
- data/lua-hooks/ext/libinjection/libinjection_sqli_data.h +0 -9349
- data/lua-hooks/ext/libinjection/libinjection_xss.c +0 -531
- data/lua-hooks/ext/libinjection/libinjection_xss.h +0 -21
- data/lua-hooks/ext/libinjection/lualib.c +0 -145
- data/lua-hooks/ext/libinjection/module.mk +0 -5
- data/lua-hooks/ext/lpeg/HISTORY +0 -96
- data/lua-hooks/ext/lpeg/lpcap.c +0 -537
- data/lua-hooks/ext/lpeg/lpcap.h +0 -56
- data/lua-hooks/ext/lpeg/lpcode.c +0 -1014
- data/lua-hooks/ext/lpeg/lpcode.h +0 -40
- data/lua-hooks/ext/lpeg/lpeg-128.gif +0 -0
- data/lua-hooks/ext/lpeg/lpeg.html +0 -1445
- data/lua-hooks/ext/lpeg/lpprint.c +0 -244
- data/lua-hooks/ext/lpeg/lpprint.h +0 -36
- data/lua-hooks/ext/lpeg/lptree.c +0 -1303
- data/lua-hooks/ext/lpeg/lptree.h +0 -82
- data/lua-hooks/ext/lpeg/lptypes.h +0 -149
- data/lua-hooks/ext/lpeg/lpvm.c +0 -364
- data/lua-hooks/ext/lpeg/lpvm.h +0 -58
- data/lua-hooks/ext/lpeg/makefile +0 -55
- data/lua-hooks/ext/lpeg/module.mk +0 -6
- data/lua-hooks/ext/lpeg/re.html +0 -498
- data/lua-hooks/ext/lua-cmsgpack/.gitignore +0 -13
- data/lua-hooks/ext/lua-cmsgpack/CMakeLists.txt +0 -45
- data/lua-hooks/ext/lua-cmsgpack/README.md +0 -115
- data/lua-hooks/ext/lua-cmsgpack/lua_cmsgpack.c +0 -970
- data/lua-hooks/ext/lua-cmsgpack/module.mk +0 -2
- data/lua-hooks/ext/lua-cmsgpack/test.lua +0 -570
- data/lua-hooks/ext/lua-snapshot/LICENSE +0 -7
- data/lua-hooks/ext/lua-snapshot/Makefile +0 -12
- data/lua-hooks/ext/lua-snapshot/README.md +0 -18
- data/lua-hooks/ext/lua-snapshot/dump.lua +0 -15
- data/lua-hooks/ext/lua-snapshot/module.mk +0 -2
- data/lua-hooks/ext/lua-snapshot/snapshot.c +0 -462
- data/lua-hooks/ext/luautf8/README.md +0 -152
- data/lua-hooks/ext/luautf8/lutf8lib.c +0 -1274
- data/lua-hooks/ext/luautf8/module.mk +0 -2
- data/lua-hooks/ext/luautf8/unidata.h +0 -3064
- data/lua-hooks/ext/module.mk +0 -15
- data/lua-hooks/ext/modules.h +0 -17
- data/lua-hooks/ext/perf/luacpu.c +0 -114
- data/lua-hooks/ext/perf/lualoadavg.c +0 -40
- data/lua-hooks/ext/perf/luameminfo.c +0 -38
- data/lua-hooks/ext/perf/luaoslib.c +0 -203
- data/lua-hooks/ext/perf/module.mk +0 -5
- data/lua-hooks/ext/sha1/luasha1.c +0 -74
- data/lua-hooks/ext/sha1/module.mk +0 -5
- data/lua-hooks/ext/sha1/sha1.c +0 -145
- data/lua-hooks/ext/sha2/luasha256.c +0 -77
- data/lua-hooks/ext/sha2/module.mk +0 -5
- data/lua-hooks/ext/sha2/sha256.c +0 -196
- data/lua-hooks/ext/sysutils/lua_utils.c +0 -56
- data/lua-hooks/ext/sysutils/module.mk +0 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
** Target architecture selection.
|
3
|
-
** Copyright (C) 2005-
|
3
|
+
** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
|
4
4
|
*/
|
5
5
|
|
6
6
|
#ifndef _LJ_ARCH_H
|
@@ -25,6 +25,10 @@
|
|
25
25
|
#define LUAJIT_ARCH_ppc 5
|
26
26
|
#define LUAJIT_ARCH_MIPS 6
|
27
27
|
#define LUAJIT_ARCH_mips 6
|
28
|
+
#define LUAJIT_ARCH_MIPS32 6
|
29
|
+
#define LUAJIT_ARCH_mips32 6
|
30
|
+
#define LUAJIT_ARCH_MIPS64 7
|
31
|
+
#define LUAJIT_ARCH_mips64 7
|
28
32
|
|
29
33
|
/* Target OS. */
|
30
34
|
#define LUAJIT_OS_OTHER 0
|
@@ -47,8 +51,10 @@
|
|
47
51
|
#define LUAJIT_TARGET LUAJIT_ARCH_ARM64
|
48
52
|
#elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC)
|
49
53
|
#define LUAJIT_TARGET LUAJIT_ARCH_PPC
|
54
|
+
#elif defined(__mips64__) || defined(__mips64) || defined(__MIPS64__) || defined(__MIPS64)
|
55
|
+
#define LUAJIT_TARGET LUAJIT_ARCH_MIPS64
|
50
56
|
#elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(__MIPS)
|
51
|
-
#define LUAJIT_TARGET
|
57
|
+
#define LUAJIT_TARGET LUAJIT_ARCH_MIPS32
|
52
58
|
#else
|
53
59
|
#error "No support for this architecture (yet)"
|
54
60
|
#endif
|
@@ -68,7 +74,10 @@
|
|
68
74
|
defined(__NetBSD__) || defined(__OpenBSD__) || \
|
69
75
|
defined(__DragonFly__)) && !defined(__ORBIS__)
|
70
76
|
#define LUAJIT_OS LUAJIT_OS_BSD
|
71
|
-
#elif (defined(__sun__) && defined(__svr4__)) || defined(
|
77
|
+
#elif (defined(__sun__) && defined(__svr4__)) || defined(__HAIKU__)
|
78
|
+
#define LUAJIT_OS LUAJIT_OS_POSIX
|
79
|
+
#elif defined(__CYGWIN__)
|
80
|
+
#define LJ_TARGET_CYGWIN 1
|
72
81
|
#define LUAJIT_OS LUAJIT_OS_POSIX
|
73
82
|
#else
|
74
83
|
#define LUAJIT_OS LUAJIT_OS_OTHER
|
@@ -137,7 +146,7 @@
|
|
137
146
|
#define LJ_ARCH_NAME "x86"
|
138
147
|
#define LJ_ARCH_BITS 32
|
139
148
|
#define LJ_ARCH_ENDIAN LUAJIT_LE
|
140
|
-
#if LJ_TARGET_WINDOWS ||
|
149
|
+
#if LJ_TARGET_WINDOWS || LJ_TARGET_CYGWIN
|
141
150
|
#define LJ_ABI_WIN 1
|
142
151
|
#else
|
143
152
|
#define LJ_ABI_WIN 0
|
@@ -155,7 +164,7 @@
|
|
155
164
|
#define LJ_ARCH_NAME "x64"
|
156
165
|
#define LJ_ARCH_BITS 64
|
157
166
|
#define LJ_ARCH_ENDIAN LUAJIT_LE
|
158
|
-
#if LJ_TARGET_WINDOWS ||
|
167
|
+
#if LJ_TARGET_WINDOWS || LJ_TARGET_CYGWIN
|
159
168
|
#define LJ_ABI_WIN 1
|
160
169
|
#else
|
161
170
|
#define LJ_ABI_WIN 0
|
@@ -206,9 +215,14 @@
|
|
206
215
|
|
207
216
|
#elif LUAJIT_TARGET == LUAJIT_ARCH_ARM64
|
208
217
|
|
209
|
-
#define LJ_ARCH_NAME "arm64"
|
210
218
|
#define LJ_ARCH_BITS 64
|
219
|
+
#if defined(__AARCH64EB__)
|
220
|
+
#define LJ_ARCH_NAME "arm64be"
|
221
|
+
#define LJ_ARCH_ENDIAN LUAJIT_BE
|
222
|
+
#else
|
223
|
+
#define LJ_ARCH_NAME "arm64"
|
211
224
|
#define LJ_ARCH_ENDIAN LUAJIT_LE
|
225
|
+
#endif
|
212
226
|
#define LJ_TARGET_ARM64 1
|
213
227
|
#define LJ_TARGET_EHRETREG 0
|
214
228
|
#define LJ_TARGET_JUMPRANGE 27 /* +-2^27 = +-128MB */
|
@@ -217,7 +231,6 @@
|
|
217
231
|
#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */
|
218
232
|
#define LJ_TARGET_GC64 1
|
219
233
|
#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL
|
220
|
-
#define LJ_ARCH_NOJIT 1 /* NYI */
|
221
234
|
|
222
235
|
#define LJ_ARCH_VERSION 80
|
223
236
|
|
@@ -286,13 +299,21 @@
|
|
286
299
|
#define LJ_ARCH_XENON 1
|
287
300
|
#endif
|
288
301
|
|
289
|
-
#elif LUAJIT_TARGET ==
|
302
|
+
#elif LUAJIT_TARGET == LUAJIT_ARCH_MIPS32 || LUAJIT_TARGET == LUAJIT_ARCH_MIPS64
|
290
303
|
|
291
304
|
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL)
|
305
|
+
#if LUAJIT_TARGET == LUAJIT_ARCH_MIPS32
|
292
306
|
#define LJ_ARCH_NAME "mipsel"
|
307
|
+
#else
|
308
|
+
#define LJ_ARCH_NAME "mips64el"
|
309
|
+
#endif
|
293
310
|
#define LJ_ARCH_ENDIAN LUAJIT_LE
|
294
311
|
#else
|
312
|
+
#if LUAJIT_TARGET == LUAJIT_ARCH_MIPS32
|
295
313
|
#define LJ_ARCH_NAME "mips"
|
314
|
+
#else
|
315
|
+
#define LJ_ARCH_NAME "mips64"
|
316
|
+
#endif
|
296
317
|
#define LJ_ARCH_ENDIAN LUAJIT_BE
|
297
318
|
#endif
|
298
319
|
|
@@ -304,11 +325,6 @@
|
|
304
325
|
#endif
|
305
326
|
#endif
|
306
327
|
|
307
|
-
/* Temporarily disable features until the code has been merged. */
|
308
|
-
#if !defined(LUAJIT_NO_UNWIND) && __GNU_COMPACT_EH__
|
309
|
-
#define LUAJIT_NO_UNWIND 1
|
310
|
-
#endif
|
311
|
-
|
312
328
|
#if !defined(LJ_ABI_SOFTFP)
|
313
329
|
#ifdef __mips_soft_float
|
314
330
|
#define LJ_ABI_SOFTFP 1
|
@@ -317,7 +333,17 @@
|
|
317
333
|
#endif
|
318
334
|
#endif
|
319
335
|
|
336
|
+
#if LUAJIT_TARGET == LUAJIT_ARCH_MIPS32
|
320
337
|
#define LJ_ARCH_BITS 32
|
338
|
+
#define LJ_TARGET_MIPS32 1
|
339
|
+
#else
|
340
|
+
#if LJ_ABI_SOFTFP || !LJ_ARCH_HASFPU
|
341
|
+
#define LJ_ARCH_NOJIT 1 /* NYI */
|
342
|
+
#endif
|
343
|
+
#define LJ_ARCH_BITS 64
|
344
|
+
#define LJ_TARGET_MIPS64 1
|
345
|
+
#define LJ_TARGET_GC64 1
|
346
|
+
#endif
|
321
347
|
#define LJ_TARGET_MIPS 1
|
322
348
|
#define LJ_TARGET_EHRETREG 4
|
323
349
|
#define LJ_TARGET_JUMPRANGE 27 /* 2*2^27 = 256MB-aligned region */
|
@@ -326,7 +352,7 @@
|
|
326
352
|
#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */
|
327
353
|
#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL
|
328
354
|
|
329
|
-
#if _MIPS_ARCH_MIPS32R2
|
355
|
+
#if _MIPS_ARCH_MIPS32R2 || _MIPS_ARCH_MIPS64R2
|
330
356
|
#define LJ_ARCH_VERSION 20
|
331
357
|
#else
|
332
358
|
#define LJ_ARCH_VERSION 10
|
@@ -356,7 +382,7 @@
|
|
356
382
|
#endif
|
357
383
|
#elif LJ_TARGET_ARM64
|
358
384
|
#if __clang__
|
359
|
-
#if (__clang_major__ < 3) || ((__clang_major__ == 3) && __clang_minor__ < 5)
|
385
|
+
#if ((__clang_major__ < 3) || ((__clang_major__ == 3) && __clang_minor__ < 5)) && !defined(__NX_TOOLCHAIN_MAJOR__)
|
360
386
|
#error "Need at least Clang 3.5 or newer"
|
361
387
|
#endif
|
362
388
|
#else
|
@@ -388,9 +414,6 @@
|
|
388
414
|
#error "Only ARM EABI or iOS 3.0+ ABI is supported"
|
389
415
|
#endif
|
390
416
|
#elif LJ_TARGET_ARM64
|
391
|
-
#if defined(__AARCH64EB__)
|
392
|
-
#error "No support for big-endian ARM64"
|
393
|
-
#endif
|
394
417
|
#if defined(_ILP32)
|
395
418
|
#error "No support for ILP32 model on ARM64"
|
396
419
|
#endif
|
@@ -407,9 +430,13 @@
|
|
407
430
|
#ifdef __NO_FPRS__
|
408
431
|
#error "No support for PPC/e500 anymore (use LuaJIT 2.0)"
|
409
432
|
#endif
|
410
|
-
#elif
|
411
|
-
#if defined(
|
412
|
-
#error "
|
433
|
+
#elif LJ_TARGET_MIPS32
|
434
|
+
#if !((defined(_MIPS_SIM_ABI32) && _MIPS_SIM == _MIPS_SIM_ABI32) || (defined(_ABIO32) && _MIPS_SIM == _ABIO32))
|
435
|
+
#error "Only o32 ABI supported for MIPS32"
|
436
|
+
#endif
|
437
|
+
#elif LJ_TARGET_MIPS64
|
438
|
+
#if !((defined(_MIPS_SIM_ABI64) && _MIPS_SIM == _MIPS_SIM_ABI64) || (defined(_ABI64) && _MIPS_SIM == _ABI64))
|
439
|
+
#error "Only n64 ABI supported for MIPS64"
|
413
440
|
#endif
|
414
441
|
#endif
|
415
442
|
#endif
|
@@ -450,7 +477,7 @@
|
|
450
477
|
#endif
|
451
478
|
|
452
479
|
/* Disable or enable the JIT compiler. */
|
453
|
-
#if defined(LUAJIT_DISABLE_JIT) || defined(LJ_ARCH_NOJIT) || defined(LJ_OS_NOJIT)
|
480
|
+
#if defined(LUAJIT_DISABLE_JIT) || defined(LJ_ARCH_NOJIT) || defined(LJ_OS_NOJIT)
|
454
481
|
#define LJ_HASJIT 0
|
455
482
|
#else
|
456
483
|
#define LJ_HASJIT 1
|
@@ -521,6 +548,11 @@
|
|
521
548
|
#define LJ_NO_SYSTEM 1
|
522
549
|
#endif
|
523
550
|
|
551
|
+
#if !defined(LUAJIT_NO_UNWIND) && __GNU_COMPACT_EH__
|
552
|
+
/* NYI: no support for compact unwind specification, yet. */
|
553
|
+
#define LUAJIT_NO_UNWIND 1
|
554
|
+
#endif
|
555
|
+
|
524
556
|
#if defined(LUAJIT_NO_UNWIND) || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 || LJ_TARGET_PS4
|
525
557
|
#define LJ_NO_UNWIND 1
|
526
558
|
#endif
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
** IR assembler (SSA IR -> machine code).
|
3
|
-
** Copyright (C) 2005-
|
3
|
+
** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
|
4
4
|
*/
|
5
5
|
|
6
6
|
#define lj_asm_c
|
@@ -91,7 +91,7 @@ typedef struct ASMState {
|
|
91
91
|
MCode *realign; /* Realign loop if not NULL. */
|
92
92
|
|
93
93
|
#ifdef RID_NUM_KREF
|
94
|
-
|
94
|
+
intptr_t krefk[RID_NUM_KREF];
|
95
95
|
#endif
|
96
96
|
IRRef1 phireg[RID_MAX]; /* PHI register references. */
|
97
97
|
uint16_t parentmap[LJ_MAX_JSLOTS]; /* Parent instruction to RegSP map. */
|
@@ -144,7 +144,7 @@ static LJ_AINLINE void checkmclim(ASMState *as)
|
|
144
144
|
#define ra_krefreg(ref) ((Reg)(RID_MIN_KREF + (Reg)(ref)))
|
145
145
|
#define ra_krefk(as, ref) (as->krefk[(ref)])
|
146
146
|
|
147
|
-
static LJ_AINLINE void ra_setkref(ASMState *as, Reg r,
|
147
|
+
static LJ_AINLINE void ra_setkref(ASMState *as, Reg r, intptr_t k)
|
148
148
|
{
|
149
149
|
IRRef ref = (IRRef)(r - RID_MIN_KREF);
|
150
150
|
as->krefk[ref] = k;
|
@@ -171,6 +171,8 @@ IRFLDEF(FLOFS)
|
|
171
171
|
#include "lj_emit_x86.h"
|
172
172
|
#elif LJ_TARGET_ARM
|
173
173
|
#include "lj_emit_arm.h"
|
174
|
+
#elif LJ_TARGET_ARM64
|
175
|
+
#include "lj_emit_arm64.h"
|
174
176
|
#elif LJ_TARGET_PPC
|
175
177
|
#include "lj_emit_ppc.h"
|
176
178
|
#elif LJ_TARGET_MIPS
|
@@ -322,7 +324,11 @@ static Reg ra_rematk(ASMState *as, IRRef ref)
|
|
322
324
|
lua_assert(!rset_test(as->freeset, r));
|
323
325
|
ra_free(as, r);
|
324
326
|
ra_modified(as, r);
|
327
|
+
#if LJ_64
|
328
|
+
emit_loadu64(as, r, ra_krefk(as, ref));
|
329
|
+
#else
|
325
330
|
emit_loadi(as, r, ra_krefk(as, ref));
|
331
|
+
#endif
|
326
332
|
return r;
|
327
333
|
}
|
328
334
|
ir = IR(ref);
|
@@ -334,7 +340,7 @@ static Reg ra_rematk(ASMState *as, IRRef ref)
|
|
334
340
|
RA_DBGX((as, "remat $i $r", ir, r));
|
335
341
|
#if !LJ_SOFTFP
|
336
342
|
if (ir->o == IR_KNUM) {
|
337
|
-
|
343
|
+
emit_loadk64(as, r, ir);
|
338
344
|
} else
|
339
345
|
#endif
|
340
346
|
if (emit_canremat(REF_BASE) && ir->o == IR_BASE) {
|
@@ -346,6 +352,12 @@ static Reg ra_rematk(ASMState *as, IRRef ref)
|
|
346
352
|
#if LJ_64
|
347
353
|
} else if (ir->o == IR_KINT64) {
|
348
354
|
emit_loadu64(as, r, ir_kint64(ir)->u64);
|
355
|
+
#if LJ_GC64
|
356
|
+
} else if (ir->o == IR_KGC) {
|
357
|
+
emit_loadu64(as, r, (uintptr_t)ir_kgc(ir));
|
358
|
+
} else if (ir->o == IR_KPTR || ir->o == IR_KKPTR) {
|
359
|
+
emit_loadu64(as, r, (uintptr_t)ir_kptr(ir));
|
360
|
+
#endif
|
349
361
|
#endif
|
350
362
|
} else {
|
351
363
|
lua_assert(ir->o == IR_KINT || ir->o == IR_KGC ||
|
@@ -518,7 +530,7 @@ static void ra_evictk(ASMState *as)
|
|
518
530
|
|
519
531
|
#ifdef RID_NUM_KREF
|
520
532
|
/* Allocate a register for a constant. */
|
521
|
-
static Reg ra_allock(ASMState *as,
|
533
|
+
static Reg ra_allock(ASMState *as, intptr_t k, RegSet allow)
|
522
534
|
{
|
523
535
|
/* First try to find a register which already holds the same constant. */
|
524
536
|
RegSet pick, work = ~as->freeset & RSET_GPR;
|
@@ -527,9 +539,31 @@ static Reg ra_allock(ASMState *as, int32_t k, RegSet allow)
|
|
527
539
|
IRRef ref;
|
528
540
|
r = rset_pickbot(work);
|
529
541
|
ref = regcost_ref(as->cost[r]);
|
542
|
+
#if LJ_64
|
543
|
+
if (ref < ASMREF_L) {
|
544
|
+
if (ra_iskref(ref)) {
|
545
|
+
if (k == ra_krefk(as, ref))
|
546
|
+
return r;
|
547
|
+
} else {
|
548
|
+
IRIns *ir = IR(ref);
|
549
|
+
if ((ir->o == IR_KINT64 && k == (int64_t)ir_kint64(ir)->u64) ||
|
550
|
+
#if LJ_GC64
|
551
|
+
(ir->o == IR_KINT && k == ir->i) ||
|
552
|
+
(ir->o == IR_KGC && k == (intptr_t)ir_kgc(ir)) ||
|
553
|
+
((ir->o == IR_KPTR || ir->o == IR_KKPTR) &&
|
554
|
+
k == (intptr_t)ir_kptr(ir))
|
555
|
+
#else
|
556
|
+
(ir->o != IR_KINT64 && k == ir->i)
|
557
|
+
#endif
|
558
|
+
)
|
559
|
+
return r;
|
560
|
+
}
|
561
|
+
}
|
562
|
+
#else
|
530
563
|
if (ref < ASMREF_L &&
|
531
564
|
k == (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i))
|
532
565
|
return r;
|
566
|
+
#endif
|
533
567
|
rset_clear(work, r);
|
534
568
|
}
|
535
569
|
pick = as->freeset & allow;
|
@@ -549,7 +583,7 @@ static Reg ra_allock(ASMState *as, int32_t k, RegSet allow)
|
|
549
583
|
}
|
550
584
|
|
551
585
|
/* Allocate a specific register for a constant. */
|
552
|
-
static void ra_allockreg(ASMState *as,
|
586
|
+
static void ra_allockreg(ASMState *as, intptr_t k, Reg r)
|
553
587
|
{
|
554
588
|
Reg kr = ra_allock(as, k, RID2RSET(r));
|
555
589
|
if (kr != r) {
|
@@ -619,10 +653,20 @@ static Reg ra_alloc1(ASMState *as, IRRef ref, RegSet allow)
|
|
619
653
|
return r;
|
620
654
|
}
|
621
655
|
|
656
|
+
/* Add a register rename to the IR. */
|
657
|
+
static void ra_addrename(ASMState *as, Reg down, IRRef ref, SnapNo snapno)
|
658
|
+
{
|
659
|
+
IRRef ren;
|
660
|
+
lj_ir_set(as->J, IRT(IR_RENAME, IRT_NIL), ref, snapno);
|
661
|
+
ren = tref_ref(lj_ir_emit(as->J));
|
662
|
+
as->J->cur.ir[ren].r = (uint8_t)down;
|
663
|
+
as->J->cur.ir[ren].s = SPS_NONE;
|
664
|
+
}
|
665
|
+
|
622
666
|
/* Rename register allocation and emit move. */
|
623
667
|
static void ra_rename(ASMState *as, Reg down, Reg up)
|
624
668
|
{
|
625
|
-
IRRef
|
669
|
+
IRRef ref = regcost_ref(as->cost[up] = as->cost[down]);
|
626
670
|
IRIns *ir = IR(ref);
|
627
671
|
ir->r = (uint8_t)up;
|
628
672
|
as->cost[down] = 0;
|
@@ -635,11 +679,7 @@ static void ra_rename(ASMState *as, Reg down, Reg up)
|
|
635
679
|
RA_DBGX((as, "rename $f $r $r", regcost_ref(as->cost[up]), down, up));
|
636
680
|
emit_movrr(as, ir, down, up); /* Backwards codegen needs inverse move. */
|
637
681
|
if (!ra_hasspill(IR(ref)->s)) { /* Add the rename to the IR. */
|
638
|
-
|
639
|
-
ren = tref_ref(lj_ir_emit(as->J));
|
640
|
-
as->ir = as->T->ir; /* The IR may have been reallocated. */
|
641
|
-
IR(ren)->r = (uint8_t)down;
|
642
|
-
IR(ren)->s = SPS_NONE;
|
682
|
+
ra_addrename(as, down, ref, as->snapno);
|
643
683
|
}
|
644
684
|
}
|
645
685
|
|
@@ -689,16 +729,20 @@ static void ra_left(ASMState *as, Reg dest, IRRef lref)
|
|
689
729
|
if (ra_noreg(left)) {
|
690
730
|
if (irref_isk(lref)) {
|
691
731
|
if (ir->o == IR_KNUM) {
|
692
|
-
cTValue *tv = ir_knum(ir);
|
693
732
|
/* FP remat needs a load except for +0. Still better than eviction. */
|
694
|
-
if (tvispzero(
|
695
|
-
|
733
|
+
if (tvispzero(ir_knum(ir)) || !(as->freeset & RSET_FPR)) {
|
734
|
+
emit_loadk64(as, dest, ir);
|
696
735
|
return;
|
697
736
|
}
|
698
737
|
#if LJ_64
|
699
738
|
} else if (ir->o == IR_KINT64) {
|
700
|
-
|
739
|
+
emit_loadk64(as, dest, ir);
|
740
|
+
return;
|
741
|
+
#if LJ_GC64
|
742
|
+
} else if (ir->o == IR_KGC || ir->o == IR_KPTR || ir->o == IR_KKPTR) {
|
743
|
+
emit_loadk64(as, dest, ir);
|
701
744
|
return;
|
745
|
+
#endif
|
702
746
|
#endif
|
703
747
|
} else if (ir->o != IR_KPRI) {
|
704
748
|
lua_assert(ir->o == IR_KINT || ir->o == IR_KGC ||
|
@@ -941,7 +985,7 @@ static void asm_snap_prep(ASMState *as)
|
|
941
985
|
} else {
|
942
986
|
/* Process any renames above the highwater mark. */
|
943
987
|
for (; as->snaprename < as->T->nins; as->snaprename++) {
|
944
|
-
IRIns *ir =
|
988
|
+
IRIns *ir = &as->T->ir[as->snaprename];
|
945
989
|
if (asm_snap_checkrename(as, ir->op1))
|
946
990
|
ir->op2 = REF_BIAS-1; /* Kill rename. */
|
947
991
|
}
|
@@ -1055,7 +1099,7 @@ static void asm_bufhdr(ASMState *as, IRIns *ir)
|
|
1055
1099
|
}
|
1056
1100
|
} else {
|
1057
1101
|
Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, sb));
|
1058
|
-
/* Passing ir isn't strictly correct, but it's an
|
1102
|
+
/* Passing ir isn't strictly correct, but it's an IRT_PGC, too. */
|
1059
1103
|
emit_storeofs(as, ir, tmp, sb, offsetof(SBuf, p));
|
1060
1104
|
emit_loadofs(as, ir, tmp, sb, offsetof(SBuf, b));
|
1061
1105
|
}
|
@@ -1472,12 +1516,7 @@ static void asm_phi_fixup(ASMState *as)
|
|
1472
1516
|
irt_clearmark(ir->t);
|
1473
1517
|
/* Left PHI gained a spill slot before the loop? */
|
1474
1518
|
if (ra_hasspill(ir->s)) {
|
1475
|
-
|
1476
|
-
lj_ir_set(as->J, IRT(IR_RENAME, IRT_NIL), lref, as->loopsnapno);
|
1477
|
-
ren = tref_ref(lj_ir_emit(as->J));
|
1478
|
-
as->ir = as->T->ir; /* The IR may have been reallocated. */
|
1479
|
-
IR(ren)->r = (uint8_t)r;
|
1480
|
-
IR(ren)->s = SPS_NONE;
|
1519
|
+
ra_addrename(as, r, lref, as->loopsnapno);
|
1481
1520
|
}
|
1482
1521
|
}
|
1483
1522
|
rset_clear(work, r);
|
@@ -1552,6 +1591,8 @@ static void asm_loop(ASMState *as)
|
|
1552
1591
|
#include "lj_asm_x86.h"
|
1553
1592
|
#elif LJ_TARGET_ARM
|
1554
1593
|
#include "lj_asm_arm.h"
|
1594
|
+
#elif LJ_TARGET_ARM64
|
1595
|
+
#include "lj_asm_arm64.h"
|
1555
1596
|
#elif LJ_TARGET_PPC
|
1556
1597
|
#include "lj_asm_ppc.h"
|
1557
1598
|
#elif LJ_TARGET_MIPS
|
@@ -1888,7 +1929,7 @@ static BCReg asm_baseslot(ASMState *as, SnapShot *snap, int *gotframe)
|
|
1888
1929
|
SnapEntry sn = map[n-1];
|
1889
1930
|
if ((sn & SNAP_FRAME)) {
|
1890
1931
|
*gotframe = 1;
|
1891
|
-
return snap_slot(sn);
|
1932
|
+
return snap_slot(sn) - LJ_FR2;
|
1892
1933
|
}
|
1893
1934
|
}
|
1894
1935
|
return 0;
|
@@ -1908,16 +1949,20 @@ static void asm_tail_link(ASMState *as)
|
|
1908
1949
|
|
1909
1950
|
if (as->T->link == 0) {
|
1910
1951
|
/* Setup fixed registers for exit to interpreter. */
|
1911
|
-
const BCIns *pc = snap_pc(as->T->snapmap[snap->mapofs + snap->nent]);
|
1952
|
+
const BCIns *pc = snap_pc(&as->T->snapmap[snap->mapofs + snap->nent]);
|
1912
1953
|
int32_t mres;
|
1913
1954
|
if (bc_op(*pc) == BC_JLOOP) { /* NYI: find a better way to do this. */
|
1914
1955
|
BCIns *retpc = &traceref(as->J, bc_d(*pc))->startins;
|
1915
1956
|
if (bc_isret(bc_op(*retpc)))
|
1916
1957
|
pc = retpc;
|
1917
1958
|
}
|
1959
|
+
#if LJ_GC64
|
1960
|
+
emit_loadu64(as, RID_LPC, u64ptr(pc));
|
1961
|
+
#else
|
1918
1962
|
ra_allockreg(as, i32ptr(J2GG(as->J)->dispatch), RID_DISPATCH);
|
1919
1963
|
ra_allockreg(as, i32ptr(pc), RID_LPC);
|
1920
|
-
|
1964
|
+
#endif
|
1965
|
+
mres = (int32_t)(snap->nslots - baseslot - LJ_FR2);
|
1921
1966
|
switch (bc_op(*pc)) {
|
1922
1967
|
case BC_CALLM: case BC_CALLMT:
|
1923
1968
|
mres -= (int32_t)(1 + LJ_FR2 + bc_a(*pc) + bc_c(*pc)); break;
|
@@ -1932,6 +1977,11 @@ static void asm_tail_link(ASMState *as)
|
|
1932
1977
|
}
|
1933
1978
|
emit_addptr(as, RID_BASE, 8*(int32_t)baseslot);
|
1934
1979
|
|
1980
|
+
if (as->J->ktrace) { /* Patch ktrace slot with the final GCtrace pointer. */
|
1981
|
+
setgcref(IR(as->J->ktrace)[LJ_GC64].gcr, obj2gco(as->J->curfinal));
|
1982
|
+
IR(as->J->ktrace)->o = IR_KGC;
|
1983
|
+
}
|
1984
|
+
|
1935
1985
|
/* Sync the interpreter state with the on-trace state. */
|
1936
1986
|
asm_stack_restore(as, snap);
|
1937
1987
|
|
@@ -1957,17 +2007,22 @@ static void asm_setup_regsp(ASMState *as)
|
|
1957
2007
|
ra_setup(as);
|
1958
2008
|
|
1959
2009
|
/* Clear reg/sp for constants. */
|
1960
|
-
for (ir = IR(T->nk), lastir = IR(REF_BASE); ir < lastir; ir++)
|
2010
|
+
for (ir = IR(T->nk), lastir = IR(REF_BASE); ir < lastir; ir++) {
|
1961
2011
|
ir->prev = REGSP_INIT;
|
2012
|
+
if (irt_is64(ir->t) && ir->o != IR_KNULL) {
|
2013
|
+
#if LJ_GC64
|
2014
|
+
ir->i = 0; /* Will become non-zero only for RIP-relative addresses. */
|
2015
|
+
#else
|
2016
|
+
/* Make life easier for backends by putting address of constant in i. */
|
2017
|
+
ir->i = (int32_t)(intptr_t)(ir+1);
|
2018
|
+
#endif
|
2019
|
+
ir++;
|
2020
|
+
}
|
2021
|
+
}
|
1962
2022
|
|
1963
2023
|
/* REF_BASE is used for implicit references to the BASE register. */
|
1964
2024
|
lastir->prev = REGSP_HINT(RID_BASE);
|
1965
2025
|
|
1966
|
-
ir = IR(nins-1);
|
1967
|
-
if (ir->o == IR_RENAME) {
|
1968
|
-
do { ir--; nins--; } while (ir->o == IR_RENAME);
|
1969
|
-
T->nins = nins; /* Remove any renames left over from ASM restart. */
|
1970
|
-
}
|
1971
2026
|
as->snaprename = nins;
|
1972
2027
|
as->snapref = nins;
|
1973
2028
|
as->snapno = T->nsnap;
|
@@ -2150,7 +2205,10 @@ static void asm_setup_regsp(ASMState *as)
|
|
2150
2205
|
#endif
|
2151
2206
|
#if LJ_TARGET_X86ORX64
|
2152
2207
|
/* Non-constant shift counts need to be in RID_ECX on x86/x64. */
|
2153
|
-
case IR_BSHL: case IR_BSHR: case IR_BSAR:
|
2208
|
+
case IR_BSHL: case IR_BSHR: case IR_BSAR:
|
2209
|
+
if ((as->flags & JIT_F_BMI2)) /* Except if BMI2 is available. */
|
2210
|
+
break;
|
2211
|
+
case IR_BROL: case IR_BROR:
|
2154
2212
|
if (!irref_isk(ir->op2) && !ra_hashint(IR(ir->op2)->r)) {
|
2155
2213
|
IR(ir->op2)->r = REGSP_HINT(RID_ECX);
|
2156
2214
|
if (inloop)
|
@@ -2196,14 +2254,25 @@ void lj_asm_trace(jit_State *J, GCtrace *T)
|
|
2196
2254
|
ASMState *as = &as_;
|
2197
2255
|
MCode *origtop;
|
2198
2256
|
|
2257
|
+
/* Remove nops/renames left over from ASM restart due to LJ_TRERR_MCODELM. */
|
2258
|
+
{
|
2259
|
+
IRRef nins = T->nins;
|
2260
|
+
IRIns *ir = &T->ir[nins-1];
|
2261
|
+
if (ir->o == IR_NOP || ir->o == IR_RENAME) {
|
2262
|
+
do { ir--; nins--; } while (ir->o == IR_NOP || ir->o == IR_RENAME);
|
2263
|
+
T->nins = nins;
|
2264
|
+
}
|
2265
|
+
}
|
2266
|
+
|
2199
2267
|
/* Ensure an initialized instruction beyond the last one for HIOP checks. */
|
2200
|
-
|
2201
|
-
|
2268
|
+
/* This also allows one RENAME to be added without reallocating curfinal. */
|
2269
|
+
as->orignins = lj_ir_nextins(J);
|
2270
|
+
J->cur.ir[as->orignins].o = IR_NOP;
|
2202
2271
|
|
2203
2272
|
/* Setup initial state. Copy some fields to reduce indirections. */
|
2204
2273
|
as->J = J;
|
2205
2274
|
as->T = T;
|
2206
|
-
|
2275
|
+
J->curfinal = lj_trace_alloc(J->L, T); /* This copies the IR, too. */
|
2207
2276
|
as->flags = J->flags;
|
2208
2277
|
as->loopref = J->loopref;
|
2209
2278
|
as->realign = NULL;
|
@@ -2216,12 +2285,41 @@ void lj_asm_trace(jit_State *J, GCtrace *T)
|
|
2216
2285
|
as->mclim = as->mcbot + MCLIM_REDZONE;
|
2217
2286
|
asm_setup_target(as);
|
2218
2287
|
|
2219
|
-
|
2288
|
+
/*
|
2289
|
+
** This is a loop, because the MCode may have to be (re-)assembled
|
2290
|
+
** multiple times:
|
2291
|
+
**
|
2292
|
+
** 1. as->realign is set (and the assembly aborted), if the arch-specific
|
2293
|
+
** backend wants the MCode to be aligned differently.
|
2294
|
+
**
|
2295
|
+
** This is currently only the case on x86/x64, where small loops get
|
2296
|
+
** an aligned loop body plus a short branch. Not much effort is wasted,
|
2297
|
+
** because the abort happens very quickly and only once.
|
2298
|
+
**
|
2299
|
+
** 2. The IR is immovable, since the MCode embeds pointers to various
|
2300
|
+
** constants inside the IR. But RENAMEs may need to be added to the IR
|
2301
|
+
** during assembly, which might grow and reallocate the IR. We check
|
2302
|
+
** at the end if the IR (in J->cur.ir) has actually grown, resize the
|
2303
|
+
** copy (in J->curfinal.ir) and try again.
|
2304
|
+
**
|
2305
|
+
** 95% of all traces have zero RENAMEs, 3% have one RENAME, 1.5% have
|
2306
|
+
** 2 RENAMEs and only 0.5% have more than that. That's why we opt to
|
2307
|
+
** always have one spare slot in the IR (see above), which means we
|
2308
|
+
** have to redo the assembly for only ~2% of all traces.
|
2309
|
+
**
|
2310
|
+
** Very, very rarely, this needs to be done repeatedly, since the
|
2311
|
+
** location of constants inside the IR (actually, reachability from
|
2312
|
+
** a global pointer) may affect register allocation and thus the
|
2313
|
+
** number of RENAMEs.
|
2314
|
+
*/
|
2315
|
+
for (;;) {
|
2220
2316
|
as->mcp = as->mctop;
|
2221
2317
|
#ifdef LUA_USE_ASSERT
|
2222
2318
|
as->mcp_prev = as->mcp;
|
2223
2319
|
#endif
|
2224
|
-
as->
|
2320
|
+
as->ir = J->curfinal->ir; /* Use the copied IR. */
|
2321
|
+
as->curins = J->cur.nins = as->orignins;
|
2322
|
+
|
2225
2323
|
RA_DBG_START();
|
2226
2324
|
RA_DBGX((as, "===== STOP ====="));
|
2227
2325
|
|
@@ -2249,22 +2347,40 @@ void lj_asm_trace(jit_State *J, GCtrace *T)
|
|
2249
2347
|
checkmclim(as);
|
2250
2348
|
asm_ir(as, ir);
|
2251
2349
|
}
|
2252
|
-
} while (as->realign); /* Retry in case the MCode needs to be realigned. */
|
2253
2350
|
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2351
|
+
if (as->realign && J->curfinal->nins >= T->nins)
|
2352
|
+
continue; /* Retry in case only the MCode needs to be realigned. */
|
2353
|
+
|
2354
|
+
/* Emit head of trace. */
|
2355
|
+
RA_DBG_REF();
|
2356
|
+
checkmclim(as);
|
2357
|
+
if (as->gcsteps > 0) {
|
2358
|
+
as->curins = as->T->snap[0].ref;
|
2359
|
+
asm_snap_prep(as); /* The GC check is a guard. */
|
2360
|
+
asm_gc_check(as);
|
2361
|
+
as->curins = as->stopins;
|
2362
|
+
}
|
2363
|
+
ra_evictk(as);
|
2364
|
+
if (as->parent)
|
2365
|
+
asm_head_side(as);
|
2366
|
+
else
|
2367
|
+
asm_head_root(as);
|
2368
|
+
asm_phi_fixup(as);
|
2369
|
+
|
2370
|
+
if (J->curfinal->nins >= T->nins) { /* IR didn't grow? */
|
2371
|
+
lua_assert(J->curfinal->nk == T->nk);
|
2372
|
+
memcpy(J->curfinal->ir + as->orignins, T->ir + as->orignins,
|
2373
|
+
(T->nins - as->orignins) * sizeof(IRIns)); /* Copy RENAMEs. */
|
2374
|
+
T->nins = J->curfinal->nins;
|
2375
|
+
break; /* Done. */
|
2376
|
+
}
|
2377
|
+
|
2378
|
+
/* Otherwise try again with a bigger IR. */
|
2379
|
+
lj_trace_free(J2G(J), J->curfinal);
|
2380
|
+
J->curfinal = NULL; /* In case lj_trace_alloc() OOMs. */
|
2381
|
+
J->curfinal = lj_trace_alloc(J->L, T);
|
2382
|
+
as->realign = NULL;
|
2261
2383
|
}
|
2262
|
-
ra_evictk(as);
|
2263
|
-
if (as->parent)
|
2264
|
-
asm_head_side(as);
|
2265
|
-
else
|
2266
|
-
asm_head_root(as);
|
2267
|
-
asm_phi_fixup(as);
|
2268
2384
|
|
2269
2385
|
RA_DBGX((as, "===== START ===="));
|
2270
2386
|
RA_DBG_FLUSH();
|
@@ -2277,6 +2393,9 @@ void lj_asm_trace(jit_State *J, GCtrace *T)
|
|
2277
2393
|
if (!as->loopref)
|
2278
2394
|
asm_tail_fixup(as, T->link); /* Note: this may change as->mctop! */
|
2279
2395
|
T->szmcode = (MSize)((char *)as->mctop - (char *)as->mcp);
|
2396
|
+
#if LJ_TARGET_MCODE_FIXUP
|
2397
|
+
asm_mcode_fixup(T->mcode, T->szmcode);
|
2398
|
+
#endif
|
2280
2399
|
lj_mcode_sync(T->mcode, origtop);
|
2281
2400
|
}
|
2282
2401
|
|