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
|
** Snapshot handling.
|
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_snap_c
|
@@ -68,10 +68,22 @@ static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots)
|
|
68
68
|
for (s = 0; s < nslots; s++) {
|
69
69
|
TRef tr = J->slot[s];
|
70
70
|
IRRef ref = tref_ref(tr);
|
71
|
+
#if LJ_FR2
|
72
|
+
if (s == 1) { /* Ignore slot 1 in LJ_FR2 mode, except if tailcalled. */
|
73
|
+
if ((tr & TREF_FRAME))
|
74
|
+
map[n++] = SNAP(1, SNAP_FRAME | SNAP_NORESTORE, REF_NIL);
|
75
|
+
continue;
|
76
|
+
}
|
77
|
+
if ((tr & (TREF_FRAME | TREF_CONT)) && !ref) {
|
78
|
+
cTValue *base = J->L->base - J->baseslot;
|
79
|
+
tr = J->slot[s] = (tr & 0xff0000) | lj_ir_k64(J, IR_KNUM, base[s].u64);
|
80
|
+
ref = tref_ref(tr);
|
81
|
+
}
|
82
|
+
#endif
|
71
83
|
if (ref) {
|
72
84
|
SnapEntry sn = SNAP_TR(s, tr);
|
73
85
|
IRIns *ir = &J->cur.ir[ref];
|
74
|
-
if (!(sn & (SNAP_CONT|SNAP_FRAME)) &&
|
86
|
+
if ((LJ_FR2 || !(sn & (SNAP_CONT|SNAP_FRAME))) &&
|
75
87
|
ir->o == IR_SLOAD && ir->op1 == s && ref > retf) {
|
76
88
|
/* No need to snapshot unmodified non-inherited slots. */
|
77
89
|
if (!(ir->op2 & IRSLOAD_INHERIT))
|
@@ -90,34 +102,51 @@ static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots)
|
|
90
102
|
}
|
91
103
|
|
92
104
|
/* Add frame links at the end of the snapshot. */
|
93
|
-
static
|
105
|
+
static MSize snapshot_framelinks(jit_State *J, SnapEntry *map, uint8_t *topslot)
|
94
106
|
{
|
95
107
|
cTValue *frame = J->L->base - 1;
|
96
|
-
cTValue *lim = J->L->base - J->baseslot;
|
108
|
+
cTValue *lim = J->L->base - J->baseslot + LJ_FR2;
|
97
109
|
GCfunc *fn = frame_func(frame);
|
98
110
|
cTValue *ftop = isluafunc(fn) ? (frame+funcproto(fn)->framesize) : J->L->top;
|
111
|
+
#if LJ_FR2
|
112
|
+
uint64_t pcbase = (u64ptr(J->pc) << 8) | (J->baseslot - 2);
|
113
|
+
lua_assert(2 <= J->baseslot && J->baseslot <= 257);
|
114
|
+
memcpy(map, &pcbase, sizeof(uint64_t));
|
115
|
+
#else
|
99
116
|
MSize f = 0;
|
100
|
-
lua_assert(!LJ_FR2); /* TODO_FR2: store 64 bit PCs. */
|
101
117
|
map[f++] = SNAP_MKPC(J->pc); /* The current PC is always the first entry. */
|
118
|
+
#endif
|
102
119
|
while (frame > lim) { /* Backwards traversal of all frames above base. */
|
103
120
|
if (frame_islua(frame)) {
|
121
|
+
#if !LJ_FR2
|
104
122
|
map[f++] = SNAP_MKPC(frame_pc(frame));
|
123
|
+
#endif
|
105
124
|
frame = frame_prevl(frame);
|
106
125
|
} else if (frame_iscont(frame)) {
|
126
|
+
#if !LJ_FR2
|
107
127
|
map[f++] = SNAP_MKFTSZ(frame_ftsz(frame));
|
108
128
|
map[f++] = SNAP_MKPC(frame_contpc(frame));
|
129
|
+
#endif
|
109
130
|
frame = frame_prevd(frame);
|
110
131
|
} else {
|
111
132
|
lua_assert(!frame_isc(frame));
|
133
|
+
#if !LJ_FR2
|
112
134
|
map[f++] = SNAP_MKFTSZ(frame_ftsz(frame));
|
135
|
+
#endif
|
113
136
|
frame = frame_prevd(frame);
|
114
137
|
continue;
|
115
138
|
}
|
116
139
|
if (frame + funcproto(frame_func(frame))->framesize > ftop)
|
117
140
|
ftop = frame + funcproto(frame_func(frame))->framesize;
|
118
141
|
}
|
142
|
+
*topslot = (uint8_t)(ftop - lim);
|
143
|
+
#if LJ_FR2
|
144
|
+
lua_assert(sizeof(SnapEntry) * 2 == sizeof(uint64_t));
|
145
|
+
return 2;
|
146
|
+
#else
|
119
147
|
lua_assert(f == (MSize)(1 + J->framedepth));
|
120
|
-
return
|
148
|
+
return f;
|
149
|
+
#endif
|
121
150
|
}
|
122
151
|
|
123
152
|
/* Take a snapshot of the current stack. */
|
@@ -127,16 +156,16 @@ static void snapshot_stack(jit_State *J, SnapShot *snap, MSize nsnapmap)
|
|
127
156
|
MSize nent;
|
128
157
|
SnapEntry *p;
|
129
158
|
/* Conservative estimate. */
|
130
|
-
lj_snap_grow_map(J, nsnapmap + nslots + (MSize)J->framedepth+1);
|
159
|
+
lj_snap_grow_map(J, nsnapmap + nslots + (MSize)(LJ_FR2?2:J->framedepth+1));
|
131
160
|
p = &J->cur.snapmap[nsnapmap];
|
132
161
|
nent = snapshot_slots(J, p, nslots);
|
133
|
-
snap->
|
162
|
+
snap->nent = (uint8_t)nent;
|
163
|
+
nent += snapshot_framelinks(J, p + nent, &snap->topslot);
|
134
164
|
snap->mapofs = (uint16_t)nsnapmap;
|
135
165
|
snap->ref = (IRRef1)J->cur.nins;
|
136
|
-
snap->nent = (uint8_t)nent;
|
137
166
|
snap->nslots = (uint8_t)nslots;
|
138
167
|
snap->count = 0;
|
139
|
-
J->cur.nsnapmap = (uint16_t)(nsnapmap + nent
|
168
|
+
J->cur.nsnapmap = (uint16_t)(nsnapmap + nent);
|
140
169
|
}
|
141
170
|
|
142
171
|
/* Add or merge a snapshot. */
|
@@ -284,8 +313,8 @@ void lj_snap_shrink(jit_State *J)
|
|
284
313
|
MSize n, m, nlim, nent = snap->nent;
|
285
314
|
uint8_t udf[SNAP_USEDEF_SLOTS];
|
286
315
|
BCReg maxslot = J->maxslot;
|
287
|
-
BCReg minslot = snap_usedef(J, udf, snap_pc(map[nent]), maxslot);
|
288
316
|
BCReg baseslot = J->baseslot;
|
317
|
+
BCReg minslot = snap_usedef(J, udf, snap_pc(&map[nent]), maxslot);
|
289
318
|
maxslot += baseslot;
|
290
319
|
minslot += baseslot;
|
291
320
|
snap->nslots = (uint8_t)maxslot;
|
@@ -371,8 +400,8 @@ static TRef snap_replay_const(jit_State *J, IRIns *ir)
|
|
371
400
|
case IR_KPRI: return TREF_PRI(irt_type(ir->t));
|
372
401
|
case IR_KINT: return lj_ir_kint(J, ir->i);
|
373
402
|
case IR_KGC: return lj_ir_kgc(J, ir_kgc(ir), irt_t(ir->t));
|
374
|
-
case IR_KNUM:
|
375
|
-
|
403
|
+
case IR_KNUM: case IR_KINT64:
|
404
|
+
return lj_ir_k64(J, (IROp)ir->o, ir_k64(ir)->u64);
|
376
405
|
case IR_KPTR: return lj_ir_kptr(J, ir_kptr(ir)); /* Continuation. */
|
377
406
|
default: lua_assert(0); return TREF_NIL; break;
|
378
407
|
}
|
@@ -445,7 +474,11 @@ void lj_snap_replay(jit_State *J, GCtrace *T)
|
|
445
474
|
goto setslot;
|
446
475
|
bloomset(seen, ref);
|
447
476
|
if (irref_isk(ref)) {
|
448
|
-
|
477
|
+
/* See special treatment of LJ_FR2 slot 1 in snapshot_slots() above. */
|
478
|
+
if (LJ_FR2 && (sn == SNAP(1, SNAP_FRAME | SNAP_NORESTORE, REF_NIL)))
|
479
|
+
tr = 0;
|
480
|
+
else
|
481
|
+
tr = snap_replay_const(J, ir);
|
449
482
|
} else if (!regsp_used(ir->prev)) {
|
450
483
|
pass23 = 1;
|
451
484
|
lua_assert(s != 0);
|
@@ -459,7 +492,7 @@ void lj_snap_replay(jit_State *J, GCtrace *T)
|
|
459
492
|
}
|
460
493
|
setslot:
|
461
494
|
J->slot[s] = tr | (sn&(SNAP_CONT|SNAP_FRAME)); /* Same as TREF_* flags. */
|
462
|
-
J->framedepth += ((sn & (SNAP_CONT|SNAP_FRAME)) && s);
|
495
|
+
J->framedepth += ((sn & (SNAP_CONT|SNAP_FRAME)) && (s != LJ_FR2));
|
463
496
|
if ((sn & SNAP_FRAME))
|
464
497
|
J->baseslot = s+1;
|
465
498
|
}
|
@@ -555,8 +588,7 @@ void lj_snap_replay(jit_State *J, GCtrace *T)
|
|
555
588
|
if (irref_isk(irs->op2) && irref_isk((irs+1)->op2)) {
|
556
589
|
uint64_t k = (uint32_t)T->ir[irs->op2].i +
|
557
590
|
((uint64_t)T->ir[(irs+1)->op2].i << 32);
|
558
|
-
val = lj_ir_k64(J, t == IRT_I64 ? IR_KINT64 : IR_KNUM,
|
559
|
-
lj_ir_k64_find(J, k));
|
591
|
+
val = lj_ir_k64(J, t == IRT_I64 ? IR_KINT64 : IR_KNUM, k);
|
560
592
|
} else {
|
561
593
|
val = emitir_raw(IRT(IR_HIOP, t), val,
|
562
594
|
snap_pref(J, T, map, nent, seen, (irs+1)->op2));
|
@@ -599,7 +631,6 @@ static void snap_restoreval(jit_State *J, GCtrace *T, ExitState *ex,
|
|
599
631
|
}
|
600
632
|
if (LJ_UNLIKELY(bloomtest(rfilt, ref)))
|
601
633
|
rs = snap_renameref(T, snapno, ref, rs);
|
602
|
-
lua_assert(!LJ_GC64); /* TODO_GC64: handle 64 bit references. */
|
603
634
|
if (ra_hasspill(regsp_spill(rs))) { /* Restore from spill slot. */
|
604
635
|
int32_t *sps = &ex->spill[regsp_spill(rs)];
|
605
636
|
if (irt_isinteger(t)) {
|
@@ -608,9 +639,11 @@ static void snap_restoreval(jit_State *J, GCtrace *T, ExitState *ex,
|
|
608
639
|
} else if (irt_isnum(t)) {
|
609
640
|
o->u64 = *(uint64_t *)sps;
|
610
641
|
#endif
|
611
|
-
|
642
|
+
#if LJ_64 && !LJ_GC64
|
643
|
+
} else if (irt_islightud(t)) {
|
612
644
|
/* 64 bit lightuserdata which may escape already has the tag bits. */
|
613
645
|
o->u64 = *(uint64_t *)sps;
|
646
|
+
#endif
|
614
647
|
} else {
|
615
648
|
lua_assert(!irt_ispri(t)); /* PRI refs never have a spill slot. */
|
616
649
|
setgcV(J->L, o, (GCobj *)(uintptr_t)*(GCSize *)sps, irt_toitype(t));
|
@@ -628,9 +661,11 @@ static void snap_restoreval(jit_State *J, GCtrace *T, ExitState *ex,
|
|
628
661
|
} else if (irt_isnum(t)) {
|
629
662
|
setnumV(o, ex->fpr[r-RID_MIN_FPR]);
|
630
663
|
#endif
|
631
|
-
|
664
|
+
#if LJ_64 && !LJ_GC64
|
665
|
+
} else if (irt_is64(t)) {
|
632
666
|
/* 64 bit values that already have the tag bits. */
|
633
667
|
o->u64 = ex->gpr[r-RID_MIN_GPR];
|
668
|
+
#endif
|
634
669
|
} else if (irt_ispri(t)) {
|
635
670
|
setpriV(o, irt_toitype(t));
|
636
671
|
} else {
|
@@ -651,7 +686,7 @@ static void snap_restoredata(GCtrace *T, ExitState *ex,
|
|
651
686
|
uint64_t tmp;
|
652
687
|
if (irref_isk(ref)) {
|
653
688
|
if (ir->o == IR_KNUM || ir->o == IR_KINT64) {
|
654
|
-
src =
|
689
|
+
src = (int32_t *)&ir[1];
|
655
690
|
} else if (sz == 8) {
|
656
691
|
tmp = (uint64_t)(uint32_t)ir->i;
|
657
692
|
src = (int32_t *)&tmp;
|
@@ -688,8 +723,9 @@ static void snap_restoredata(GCtrace *T, ExitState *ex,
|
|
688
723
|
#else
|
689
724
|
if (LJ_BE && sz == 4) src++;
|
690
725
|
#endif
|
691
|
-
}
|
726
|
+
} else
|
692
727
|
#endif
|
728
|
+
if (LJ_64 && LJ_BE && sz == 4) src++;
|
693
729
|
}
|
694
730
|
}
|
695
731
|
lua_assert(sz == 1 || sz == 2 || sz == 4 || sz == 8);
|
@@ -795,11 +831,15 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr)
|
|
795
831
|
SnapShot *snap = &T->snap[snapno];
|
796
832
|
MSize n, nent = snap->nent;
|
797
833
|
SnapEntry *map = &T->snapmap[snap->mapofs];
|
798
|
-
|
834
|
+
#if !LJ_FR2 || defined(LUA_USE_ASSERT)
|
835
|
+
SnapEntry *flinks = &T->snapmap[snap_nextofs(T, snap)-1-LJ_FR2];
|
836
|
+
#endif
|
837
|
+
#if !LJ_FR2
|
799
838
|
ptrdiff_t ftsz0;
|
839
|
+
#endif
|
800
840
|
TValue *frame;
|
801
841
|
BloomFilter rfilt = snap_renamefilter(T, snapno);
|
802
|
-
const BCIns *pc = snap_pc(map[nent]);
|
842
|
+
const BCIns *pc = snap_pc(&map[nent]);
|
803
843
|
lua_State *L = J->L;
|
804
844
|
|
805
845
|
/* Set interpreter PC to the next PC to get correct error messages. */
|
@@ -812,8 +852,10 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr)
|
|
812
852
|
}
|
813
853
|
|
814
854
|
/* Fill stack slots with data from the registers and spill slots. */
|
815
|
-
frame = L->base-1;
|
855
|
+
frame = L->base-1-LJ_FR2;
|
856
|
+
#if !LJ_FR2
|
816
857
|
ftsz0 = frame_ftsz(frame); /* Preserve link to previous frame in slot #0. */
|
858
|
+
#endif
|
817
859
|
for (n = 0; n < nent; n++) {
|
818
860
|
SnapEntry sn = map[n];
|
819
861
|
if (!(sn & SNAP_NORESTORE)) {
|
@@ -836,14 +878,18 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr)
|
|
836
878
|
TValue tmp;
|
837
879
|
snap_restoreval(J, T, ex, snapno, rfilt, ref+1, &tmp);
|
838
880
|
o->u32.hi = tmp.u32.lo;
|
881
|
+
#if !LJ_FR2
|
839
882
|
} else if ((sn & (SNAP_CONT|SNAP_FRAME))) {
|
840
|
-
lua_assert(!LJ_FR2); /* TODO_FR2: store 64 bit PCs. */
|
841
883
|
/* Overwrite tag with frame link. */
|
842
884
|
setframe_ftsz(o, snap_slot(sn) != 0 ? (int32_t)*flinks-- : ftsz0);
|
843
885
|
L->base = o+1;
|
886
|
+
#endif
|
844
887
|
}
|
845
888
|
}
|
846
889
|
}
|
890
|
+
#if LJ_FR2
|
891
|
+
L->base += (map[nent+LJ_BE] & 0xff);
|
892
|
+
#endif
|
847
893
|
lua_assert(map + nent == flinks);
|
848
894
|
|
849
895
|
/* Compute current stack top. */
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
** State and stack handling.
|
3
|
-
** Copyright (C) 2005-
|
3
|
+
** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
|
4
4
|
**
|
5
5
|
** Portions taken verbatim or adapted from the Lua interpreter.
|
6
6
|
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
@@ -180,7 +180,7 @@ static void close_state(lua_State *L)
|
|
180
180
|
g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0);
|
181
181
|
}
|
182
182
|
|
183
|
-
#if LJ_64 && !(defined(LUAJIT_USE_VALGRIND) && defined(LUAJIT_USE_SYSMALLOC))
|
183
|
+
#if LJ_64 && !LJ_GC64 && !(defined(LUAJIT_USE_VALGRIND) && defined(LUAJIT_USE_SYSMALLOC))
|
184
184
|
lua_State *lj_state_newstate(lua_Alloc f, void *ud)
|
185
185
|
#else
|
186
186
|
LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud)
|
@@ -224,7 +224,7 @@ LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud)
|
|
224
224
|
close_state(L);
|
225
225
|
return NULL;
|
226
226
|
}
|
227
|
-
L->status =
|
227
|
+
L->status = LUA_OK;
|
228
228
|
return L;
|
229
229
|
}
|
230
230
|
|
@@ -256,10 +256,10 @@ LUA_API void lua_close(lua_State *L)
|
|
256
256
|
#endif
|
257
257
|
for (i = 0;;) {
|
258
258
|
hook_enter(g);
|
259
|
-
L->status =
|
259
|
+
L->status = LUA_OK;
|
260
260
|
L->base = L->top = tvref(L->stack) + 1 + LJ_FR2;
|
261
261
|
L->cframe = NULL;
|
262
|
-
if (lj_vm_cpcall(L, NULL, NULL, cpfinalize) ==
|
262
|
+
if (lj_vm_cpcall(L, NULL, NULL, cpfinalize) == LUA_OK) {
|
263
263
|
if (++i >= 10) break;
|
264
264
|
lj_gc_separateudata(g, 1); /* Separate udata again. */
|
265
265
|
if (gcref(g->gc.mmudata) == NULL) /* Until nothing is left to do. */
|
@@ -274,7 +274,7 @@ lua_State *lj_state_new(lua_State *L)
|
|
274
274
|
lua_State *L1 = lj_mem_newobj(L, lua_State);
|
275
275
|
L1->gct = ~LJ_TTHREAD;
|
276
276
|
L1->dummy_ffid = FF_C;
|
277
|
-
L1->status =
|
277
|
+
L1->status = LUA_OK;
|
278
278
|
L1->stacksize = 0;
|
279
279
|
setmref(L1->stack, NULL);
|
280
280
|
L1->cframe = NULL;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
** State and stack handling.
|
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_STATE_H
|
@@ -28,7 +28,7 @@ static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need)
|
|
28
28
|
|
29
29
|
LJ_FUNC lua_State *lj_state_new(lua_State *L);
|
30
30
|
LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L);
|
31
|
-
#if LJ_64
|
31
|
+
#if LJ_64 && !LJ_GC64 && !(defined(LUAJIT_USE_VALGRIND) && defined(LUAJIT_USE_SYSMALLOC))
|
32
32
|
LJ_FUNC lua_State *lj_state_newstate(lua_Alloc f, void *ud);
|
33
33
|
#endif
|
34
34
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
** String formatting.
|
3
|
-
** Copyright (C) 2005-
|
3
|
+
** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
|
4
4
|
*/
|
5
5
|
|
6
6
|
#include <stdio.h>
|
@@ -98,11 +98,15 @@ char * LJ_FASTCALL lj_strfmt_wint(char *p, int32_t k)
|
|
98
98
|
uint32_t u = (uint32_t)k;
|
99
99
|
if (k < 0) { u = (uint32_t)-k; *p++ = '-'; }
|
100
100
|
if (u < 10000) {
|
101
|
-
if (u < 10) goto dig1;
|
101
|
+
if (u < 10) goto dig1;
|
102
|
+
if (u < 100) goto dig2;
|
103
|
+
if (u < 1000) goto dig3;
|
102
104
|
} else {
|
103
105
|
uint32_t v = u / 10000; u -= v * 10000;
|
104
106
|
if (v < 10000) {
|
105
|
-
if (v < 10) goto dig5;
|
107
|
+
if (v < 10) goto dig5;
|
108
|
+
if (v < 100) goto dig6;
|
109
|
+
if (v < 1000) goto dig7;
|
106
110
|
} else {
|
107
111
|
uint32_t w = v / 10000; v -= w * 10000;
|
108
112
|
if (w >= 10) WINT_R(w, 10, 10)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
** String formatting for floating-point numbers.
|
3
|
-
** Copyright (C) 2005-
|
3
|
+
** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
|
4
4
|
** Contributed by Peter Cawley.
|
5
5
|
*/
|
6
6
|
|
@@ -138,7 +138,7 @@ static uint32_t nd_mul2k(uint32_t* nd, uint32_t ndhi, uint32_t k,
|
|
138
138
|
}
|
139
139
|
if (carry_in) {
|
140
140
|
nd[++ndhi] = carry_in; carry_in = 0;
|
141
|
-
if(start++ == ndlo) ++ndlo;
|
141
|
+
if (start++ == ndlo) ++ndlo;
|
142
142
|
}
|
143
143
|
k -= ND_MUL2K_MAX_SHIFT;
|
144
144
|
}
|
@@ -364,6 +364,7 @@ static char *lj_strfmt_wfnum(SBuf *sb, SFormat sf, lua_Number n, char *p)
|
|
364
364
|
/* Precision is sufficiently low that rescaling will probably work. */
|
365
365
|
if ((ndebias = rescale_e[e >> 6])) {
|
366
366
|
t.n = n * rescale_n[e >> 6];
|
367
|
+
if (LJ_UNLIKELY(!e)) t.n *= 1e10, ndebias -= 10;
|
367
368
|
t.u64 -= 2; /* Convert 2ulp below (later we convert 2ulp above). */
|
368
369
|
nd[0] = 0x100000 | (t.u32.hi & 0xfffff);
|
369
370
|
e = ((t.u32.hi >> 20) & 0x7ff) - 1075 - (ND_MUL2K_MAX_SHIFT < 29);
|
@@ -479,7 +480,7 @@ static char *lj_strfmt_wfnum(SBuf *sb, SFormat sf, lua_Number n, char *p)
|
|
479
480
|
if ((prec | (sf & STRFMT_F_ALT))) {
|
480
481
|
/* Emit fractional part. */
|
481
482
|
p[1] = '.'; p += 2;
|
482
|
-
prec -= (q - p); p = q; /* Account for
|
483
|
+
prec -= (MSize)(q - p); p = q; /* Account for digits already emitted. */
|
483
484
|
/* Then emit chunks of 9 digits (this may emit 8 digits too many). */
|
484
485
|
for (i = ndhi; (int32_t)prec > 0 && i != ndlo; prec -= 9) {
|
485
486
|
i = (i - 1) & 0x3f;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
** Table handling.
|
3
|
-
** Copyright (C) 2005-
|
3
|
+
** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
|
4
4
|
**
|
5
5
|
** Major portions taken verbatim or adapted from the Lua interpreter.
|
6
6
|
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
@@ -28,7 +28,6 @@ static LJ_AINLINE Node *hashmask(const GCtab *t, uint32_t hash)
|
|
28
28
|
|
29
29
|
#define hashlohi(t, lo, hi) hashmask((t), hashrot((lo), (hi)))
|
30
30
|
#define hashnum(t, o) hashlohi((t), (o)->u32.lo, ((o)->u32.hi << 1))
|
31
|
-
#define hashptr(t, p) hashlohi((t), u32ptr(p), u32ptr(p) + HASH_BIAS)
|
32
31
|
#if LJ_GC64
|
33
32
|
#define hashgcref(t, r) \
|
34
33
|
hashlohi((t), (uint32_t)gcrefu(r), (uint32_t)(gcrefu(r) >> 32))
|