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
|
** MIPS 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
|
/* -- Register allocator extensions --------------------------------------- */
|
@@ -23,7 +23,7 @@ static Reg ra_alloc1z(ASMState *as, IRRef ref, RegSet allow)
|
|
23
23
|
{
|
24
24
|
Reg r = IR(ref)->r;
|
25
25
|
if (ra_noreg(r)) {
|
26
|
-
if (!(allow & RSET_FPR) && irref_isk(ref) && IR(ref)
|
26
|
+
if (!(allow & RSET_FPR) && irref_isk(ref) && get_kval(IR(ref)) == 0)
|
27
27
|
return RID_ZERO;
|
28
28
|
r = ra_allocref(as, ref, allow);
|
29
29
|
} else {
|
@@ -166,9 +166,9 @@ static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow)
|
|
166
166
|
} else if (ir->o == IR_UREFC) {
|
167
167
|
if (irref_isk(ir->op1)) {
|
168
168
|
GCfunc *fn = ir_kfunc(IR(ir->op1));
|
169
|
-
|
170
|
-
|
171
|
-
if ((
|
169
|
+
intptr_t ofs = (intptr_t)&gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.tv;
|
170
|
+
intptr_t jgl = (intptr_t)J2G(as->J);
|
171
|
+
if ((uintptr_t)(ofs-jgl) < 65536) {
|
172
172
|
*ofsp = ofs-jgl-32768;
|
173
173
|
return RID_JGL;
|
174
174
|
} else {
|
@@ -190,20 +190,21 @@ static void asm_fusexref(ASMState *as, MIPSIns mi, Reg rt, IRRef ref,
|
|
190
190
|
Reg base;
|
191
191
|
if (ra_noreg(ir->r) && canfuse(as, ir)) {
|
192
192
|
if (ir->o == IR_ADD) {
|
193
|
-
|
194
|
-
if (irref_isk(ir->op2) && (ofs2 = ofs + IR(ir->op2)
|
193
|
+
intptr_t ofs2;
|
194
|
+
if (irref_isk(ir->op2) && (ofs2 = ofs + get_kval(IR(ir->op2)),
|
195
|
+
checki16(ofs2))) {
|
195
196
|
ref = ir->op1;
|
196
|
-
ofs = ofs2;
|
197
|
+
ofs = (int32_t)ofs2;
|
197
198
|
}
|
198
199
|
} else if (ir->o == IR_STRREF) {
|
199
|
-
|
200
|
+
intptr_t ofs2 = 65536;
|
200
201
|
lua_assert(ofs == 0);
|
201
202
|
ofs = (int32_t)sizeof(GCstr);
|
202
203
|
if (irref_isk(ir->op2)) {
|
203
|
-
ofs2 = ofs + IR(ir->op2)
|
204
|
+
ofs2 = ofs + get_kval(IR(ir->op2));
|
204
205
|
ref = ir->op1;
|
205
206
|
} else if (irref_isk(ir->op1)) {
|
206
|
-
ofs2 = ofs + IR(ir->op1)
|
207
|
+
ofs2 = ofs + get_kval(IR(ir->op1));
|
207
208
|
ref = ir->op2;
|
208
209
|
}
|
209
210
|
if (!checki16(ofs2)) {
|
@@ -211,7 +212,7 @@ static void asm_fusexref(ASMState *as, MIPSIns mi, Reg rt, IRRef ref,
|
|
211
212
|
Reg right, left = ra_alloc2(as, ir, allow);
|
212
213
|
right = (left >> 8); left &= 255;
|
213
214
|
emit_hsi(as, mi, rt, RID_TMP, ofs);
|
214
|
-
emit_dst(as,
|
215
|
+
emit_dst(as, MIPSI_AADDU, RID_TMP, left, right);
|
215
216
|
return;
|
216
217
|
}
|
217
218
|
ofs = ofs2;
|
@@ -227,7 +228,7 @@ static void asm_fusexref(ASMState *as, MIPSIns mi, Reg rt, IRRef ref,
|
|
227
228
|
static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args)
|
228
229
|
{
|
229
230
|
uint32_t n, nargs = CCI_XNARGS(ci);
|
230
|
-
int32_t ofs = 16;
|
231
|
+
int32_t ofs = LJ_32 ? 16 : 0;
|
231
232
|
#if LJ_SOFTFP
|
232
233
|
Reg gpr = REGARG_FIRSTGPR;
|
233
234
|
#else
|
@@ -249,15 +250,15 @@ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args)
|
|
249
250
|
!(ci->flags & CCI_VARARG)) {
|
250
251
|
lua_assert(rset_test(as->freeset, fpr)); /* Already evicted. */
|
251
252
|
ra_leftov(as, fpr, ref);
|
252
|
-
fpr += 2;
|
253
|
-
gpr += irt_isnum(ir->t) ? 2 : 1;
|
253
|
+
fpr += LJ_32 ? 2 : 1;
|
254
|
+
gpr += (LJ_32 && irt_isnum(ir->t)) ? 2 : 1;
|
254
255
|
} else
|
255
256
|
#endif
|
256
257
|
{
|
257
|
-
#if !LJ_SOFTFP
|
258
|
+
#if LJ_32 && !LJ_SOFTFP
|
258
259
|
fpr = REGARG_LASTFPR+1;
|
259
260
|
#endif
|
260
|
-
if (irt_isnum(ir->t)) gpr = (gpr+1) & ~1;
|
261
|
+
if (LJ_32 && irt_isnum(ir->t)) gpr = (gpr+1) & ~1;
|
261
262
|
if (gpr <= REGARG_LASTGPR) {
|
262
263
|
lua_assert(rset_test(as->freeset, gpr)); /* Already evicted. */
|
263
264
|
#if !LJ_SOFTFP
|
@@ -269,35 +270,55 @@ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args)
|
|
269
270
|
r = ra_alloc1(as, ref, RSET_FPR);
|
270
271
|
as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1));
|
271
272
|
if (irt_isnum(ir->t)) {
|
273
|
+
#if LJ_32
|
272
274
|
emit_tg(as, MIPSI_MFC1, gpr+(LJ_BE?0:1), r+1);
|
273
275
|
emit_tg(as, MIPSI_MFC1, gpr+(LJ_BE?1:0), r);
|
274
276
|
lua_assert(rset_test(as->freeset, gpr+1)); /* Already evicted. */
|
275
277
|
gpr += 2;
|
278
|
+
#else
|
279
|
+
emit_tg(as, MIPSI_DMFC1, gpr, r);
|
280
|
+
gpr++; fpr++;
|
281
|
+
#endif
|
276
282
|
} else if (irt_isfloat(ir->t)) {
|
277
283
|
emit_tg(as, MIPSI_MFC1, gpr, r);
|
278
284
|
gpr++;
|
285
|
+
#if LJ_64
|
286
|
+
fpr++;
|
287
|
+
#endif
|
279
288
|
}
|
280
289
|
} else
|
281
290
|
#endif
|
282
291
|
{
|
283
292
|
ra_leftov(as, gpr, ref);
|
284
293
|
gpr++;
|
294
|
+
#if LJ_64
|
295
|
+
fpr++;
|
296
|
+
#endif
|
285
297
|
}
|
286
298
|
} else {
|
287
299
|
Reg r = ra_alloc1z(as, ref, !LJ_SOFTFP && irt_isfp(ir->t) ? RSET_FPR : RSET_GPR);
|
300
|
+
#if LJ_32
|
288
301
|
if (irt_isnum(ir->t)) ofs = (ofs + 4) & ~4;
|
289
302
|
emit_spstore(as, ir, r, ofs);
|
290
303
|
ofs += irt_isnum(ir->t) ? 8 : 4;
|
304
|
+
#else
|
305
|
+
emit_spstore(as, ir, r, ofs + ((LJ_BE && (LJ_SOFTFP || r < RID_MAX_GPR) && !irt_is64(ir->t)) ? 4 : 0));
|
306
|
+
ofs += 8;
|
307
|
+
#endif
|
291
308
|
}
|
292
309
|
}
|
293
310
|
} else {
|
294
311
|
#if !LJ_SOFTFP
|
295
312
|
fpr = REGARG_LASTFPR+1;
|
296
313
|
#endif
|
297
|
-
if (gpr <= REGARG_LASTGPR)
|
314
|
+
if (gpr <= REGARG_LASTGPR) {
|
298
315
|
gpr++;
|
299
|
-
|
300
|
-
|
316
|
+
#if LJ_64
|
317
|
+
fpr++;
|
318
|
+
#endif
|
319
|
+
} else {
|
320
|
+
ofs += LJ_32 ? 4 : 8;
|
321
|
+
}
|
301
322
|
}
|
302
323
|
checkmclim(as);
|
303
324
|
}
|
@@ -307,15 +328,19 @@ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args)
|
|
307
328
|
static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci)
|
308
329
|
{
|
309
330
|
RegSet drop = RSET_SCRATCH;
|
331
|
+
#if LJ_32
|
310
332
|
int hiop = ((ir+1)->o == IR_HIOP && !irt_isnil((ir+1)->t));
|
333
|
+
#endif
|
311
334
|
#if !LJ_SOFTFP
|
312
335
|
if ((ci->flags & CCI_NOFPRCLOBBER))
|
313
336
|
drop &= ~RSET_FPR;
|
314
337
|
#endif
|
315
338
|
if (ra_hasreg(ir->r))
|
316
339
|
rset_clear(drop, ir->r); /* Dest reg handled below. */
|
340
|
+
#if LJ_32
|
317
341
|
if (hiop && ra_hasreg((ir+1)->r))
|
318
342
|
rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */
|
343
|
+
#endif
|
319
344
|
ra_evictset(as, drop); /* Evictions must be performed first. */
|
320
345
|
if (ra_used(ir)) {
|
321
346
|
lua_assert(!irt_ispri(ir->t));
|
@@ -326,18 +351,28 @@ static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci)
|
|
326
351
|
if (ra_hasreg(dest)) {
|
327
352
|
ra_free(as, dest);
|
328
353
|
ra_modified(as, dest);
|
354
|
+
#if LJ_32
|
329
355
|
emit_tg(as, MIPSI_MTC1, RID_RETHI, dest+1);
|
330
356
|
emit_tg(as, MIPSI_MTC1, RID_RETLO, dest);
|
357
|
+
#else
|
358
|
+
emit_tg(as, MIPSI_DMTC1, RID_RET, dest);
|
359
|
+
#endif
|
331
360
|
}
|
332
361
|
if (ofs) {
|
362
|
+
#if LJ_32
|
333
363
|
emit_tsi(as, MIPSI_SW, RID_RETLO, RID_SP, ofs+(LJ_BE?4:0));
|
334
364
|
emit_tsi(as, MIPSI_SW, RID_RETHI, RID_SP, ofs+(LJ_BE?0:4));
|
365
|
+
#else
|
366
|
+
emit_tsi(as, MIPSI_SD, RID_RET, RID_SP, ofs);
|
367
|
+
#endif
|
335
368
|
}
|
336
369
|
} else {
|
337
370
|
ra_destreg(as, ir, RID_FPRET);
|
338
371
|
}
|
372
|
+
#if LJ_32
|
339
373
|
} else if (hiop) {
|
340
374
|
ra_destpair(as, ir);
|
375
|
+
#endif
|
341
376
|
} else {
|
342
377
|
ra_destreg(as, ir, RID_RET);
|
343
378
|
}
|
@@ -356,7 +391,7 @@ static void asm_callx(ASMState *as, IRIns *ir)
|
|
356
391
|
func = ir->op2; irf = IR(func);
|
357
392
|
if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); }
|
358
393
|
if (irref_isk(func)) { /* Call to constant address. */
|
359
|
-
ci.func = (ASMFunction)(void *)(irf
|
394
|
+
ci.func = (ASMFunction)(void *)get_kval(irf);
|
360
395
|
} else { /* Need specific register for indirect calls. */
|
361
396
|
Reg r = ra_alloc1(as, func, RID2RSET(RID_CFUNCADDR));
|
362
397
|
MCode *p = as->mcp;
|
@@ -399,8 +434,8 @@ static void asm_retf(ASMState *as, IRIns *ir)
|
|
399
434
|
emit_setgl(as, base, jit_base);
|
400
435
|
emit_addptr(as, base, -8*delta);
|
401
436
|
asm_guard(as, MIPSI_BNE, RID_TMP,
|
402
|
-
ra_allock(as,
|
403
|
-
emit_tsi(as,
|
437
|
+
ra_allock(as, igcptr(pc), rset_exclude(RSET_GPR, base)));
|
438
|
+
emit_tsi(as, MIPSI_AL, RID_TMP, base, -8);
|
404
439
|
}
|
405
440
|
|
406
441
|
/* -- Type conversions ---------------------------------------------------- */
|
@@ -434,11 +469,16 @@ static void asm_conv(ASMState *as, IRIns *ir)
|
|
434
469
|
IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK);
|
435
470
|
#if !LJ_SOFTFP
|
436
471
|
int stfp = (st == IRT_NUM || st == IRT_FLOAT);
|
472
|
+
#endif
|
473
|
+
#if LJ_64
|
474
|
+
int st64 = (st == IRT_I64 || st == IRT_U64 || st == IRT_P64);
|
437
475
|
#endif
|
438
476
|
IRRef lref = ir->op1;
|
477
|
+
#if LJ_32
|
439
478
|
lua_assert(!(irt_isint64(ir->t) ||
|
440
479
|
(st == IRT_I64 || st == IRT_U64))); /* Handled by SPLIT. */
|
441
|
-
#
|
480
|
+
#endif
|
481
|
+
#if LJ_32 && LJ_SOFTFP
|
442
482
|
/* FP conversions are handled by SPLIT. */
|
443
483
|
lua_assert(!irt_isfp(ir->t) && !(st == IRT_NUM || st == IRT_FLOAT));
|
444
484
|
/* Can't check for same types: SPLIT uses CONV int.int + BXOR for sfp NEG. */
|
@@ -453,26 +493,50 @@ static void asm_conv(ASMState *as, IRIns *ir)
|
|
453
493
|
/* y = (x ^ 0x8000000) + 2147483648.0 */
|
454
494
|
Reg left = ra_alloc1(as, lref, RSET_GPR);
|
455
495
|
Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, dest));
|
456
|
-
emit_fgh(as, irt_isfloat(ir->t) ? MIPSI_ADD_S : MIPSI_ADD_D,
|
457
|
-
dest, dest, tmp);
|
458
|
-
emit_fg(as, irt_isfloat(ir->t) ? MIPSI_CVT_S_W : MIPSI_CVT_D_W,
|
459
|
-
dest, dest);
|
460
496
|
if (irt_isfloat(ir->t))
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
RSET_GPR);
|
497
|
+
emit_fg(as, MIPSI_CVT_S_D, dest, dest);
|
498
|
+
/* Must perform arithmetic with doubles to keep the precision. */
|
499
|
+
emit_fgh(as, MIPSI_ADD_D, dest, dest, tmp);
|
500
|
+
emit_fg(as, MIPSI_CVT_D_W, dest, dest);
|
501
|
+
emit_lsptr(as, MIPSI_LDC1, (tmp & 31),
|
502
|
+
(void *)&as->J->k64[LJ_K64_2P31], RSET_GPR);
|
468
503
|
emit_tg(as, MIPSI_MTC1, RID_TMP, dest);
|
469
504
|
emit_dst(as, MIPSI_XOR, RID_TMP, RID_TMP, left);
|
470
505
|
emit_ti(as, MIPSI_LUI, RID_TMP, 0x8000);
|
506
|
+
#if LJ_64
|
507
|
+
} else if(st == IRT_U64) { /* U64 to FP conversion. */
|
508
|
+
/* if (x >= 1u<<63) y = (double)(int64_t)(x&(1u<<63)-1) + pow(2.0, 63) */
|
509
|
+
Reg left = ra_alloc1(as, lref, RSET_GPR);
|
510
|
+
Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, dest));
|
511
|
+
MCLabel l_end = emit_label(as);
|
512
|
+
if (irt_isfloat(ir->t)) {
|
513
|
+
emit_fgh(as, MIPSI_ADD_S, dest, dest, tmp);
|
514
|
+
emit_lsptr(as, MIPSI_LWC1, (tmp & 31), (void *)&as->J->k32[LJ_K32_2P63],
|
515
|
+
rset_exclude(RSET_GPR, left));
|
516
|
+
emit_fg(as, MIPSI_CVT_S_L, dest, dest);
|
517
|
+
} else {
|
518
|
+
emit_fgh(as, MIPSI_ADD_D, dest, dest, tmp);
|
519
|
+
emit_lsptr(as, MIPSI_LDC1, (tmp & 31), (void *)&as->J->k64[LJ_K64_2P63],
|
520
|
+
rset_exclude(RSET_GPR, left));
|
521
|
+
emit_fg(as, MIPSI_CVT_D_L, dest, dest);
|
522
|
+
}
|
523
|
+
emit_branch(as, MIPSI_BGEZ, left, RID_ZERO, l_end);
|
524
|
+
emit_tg(as, MIPSI_DMTC1, RID_TMP, dest);
|
525
|
+
emit_tsml(as, MIPSI_DEXTM, RID_TMP, left, 30, 0);
|
526
|
+
#endif
|
471
527
|
} else { /* Integer to FP conversion. */
|
472
528
|
Reg left = ra_alloc1(as, lref, RSET_GPR);
|
529
|
+
#if LJ_32
|
473
530
|
emit_fg(as, irt_isfloat(ir->t) ? MIPSI_CVT_S_W : MIPSI_CVT_D_W,
|
474
531
|
dest, dest);
|
475
532
|
emit_tg(as, MIPSI_MTC1, left, dest);
|
533
|
+
#else
|
534
|
+
MIPSIns mi = irt_isfloat(ir->t) ?
|
535
|
+
(st64 ? MIPSI_CVT_S_L : MIPSI_CVT_S_W) :
|
536
|
+
(st64 ? MIPSI_CVT_D_L : MIPSI_CVT_D_W);
|
537
|
+
emit_fg(as, mi, dest, dest);
|
538
|
+
emit_tg(as, st64 ? MIPSI_DMTC1 : MIPSI_MTC1, left, dest);
|
539
|
+
#endif
|
476
540
|
}
|
477
541
|
} else if (stfp) { /* FP to integer conversion. */
|
478
542
|
if (irt_isguard(ir->t)) {
|
@@ -483,7 +547,7 @@ static void asm_conv(ASMState *as, IRIns *ir)
|
|
483
547
|
Reg dest = ra_dest(as, ir, RSET_GPR);
|
484
548
|
Reg left = ra_alloc1(as, lref, RSET_FPR);
|
485
549
|
Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left));
|
486
|
-
if (irt_isu32(ir->t)) {
|
550
|
+
if (irt_isu32(ir->t)) { /* FP to U32 conversion. */
|
487
551
|
/* y = (int)floor(x - 2147483648.0) ^ 0x80000000 */
|
488
552
|
emit_dst(as, MIPSI_XOR, dest, dest, RID_TMP);
|
489
553
|
emit_ti(as, MIPSI_LUI, RID_TMP, 0x8000);
|
@@ -494,16 +558,54 @@ static void asm_conv(ASMState *as, IRIns *ir)
|
|
494
558
|
tmp, left, tmp);
|
495
559
|
if (st == IRT_FLOAT)
|
496
560
|
emit_lsptr(as, MIPSI_LWC1, (tmp & 31),
|
497
|
-
(void *)
|
498
|
-
RSET_GPR);
|
561
|
+
(void *)&as->J->k32[LJ_K32_2P31], RSET_GPR);
|
499
562
|
else
|
500
563
|
emit_lsptr(as, MIPSI_LDC1, (tmp & 31),
|
501
|
-
(void *)
|
502
|
-
|
564
|
+
(void *)&as->J->k64[LJ_K64_2P31], RSET_GPR);
|
565
|
+
#if LJ_64
|
566
|
+
} else if (irt_isu64(ir->t)) { /* FP to U64 conversion. */
|
567
|
+
MCLabel l_end;
|
568
|
+
emit_tg(as, MIPSI_DMFC1, dest, tmp);
|
569
|
+
l_end = emit_label(as);
|
570
|
+
/* For inputs >= 2^63 add -2^64 and convert again. */
|
571
|
+
if (st == IRT_NUM) {
|
572
|
+
emit_fg(as, MIPSI_TRUNC_L_D, tmp, tmp);
|
573
|
+
emit_fgh(as, MIPSI_ADD_D, tmp, left, tmp);
|
574
|
+
emit_lsptr(as, MIPSI_LDC1, (tmp & 31),
|
575
|
+
(void *)&as->J->k64[LJ_K64_M2P64],
|
576
|
+
rset_exclude(RSET_GPR, dest));
|
577
|
+
emit_fg(as, MIPSI_TRUNC_L_D, tmp, left); /* Delay slot. */
|
578
|
+
emit_branch(as, MIPSI_BC1T, 0, 0, l_end);
|
579
|
+
emit_fgh(as, MIPSI_C_OLT_D, 0, left, tmp);
|
580
|
+
emit_lsptr(as, MIPSI_LDC1, (tmp & 31),
|
581
|
+
(void *)&as->J->k64[LJ_K64_2P63],
|
582
|
+
rset_exclude(RSET_GPR, dest));
|
583
|
+
} else {
|
584
|
+
emit_fg(as, MIPSI_TRUNC_L_S, tmp, tmp);
|
585
|
+
emit_fgh(as, MIPSI_ADD_S, tmp, left, tmp);
|
586
|
+
emit_lsptr(as, MIPSI_LWC1, (tmp & 31),
|
587
|
+
(void *)&as->J->k32[LJ_K32_M2P64],
|
588
|
+
rset_exclude(RSET_GPR, dest));
|
589
|
+
emit_fg(as, MIPSI_TRUNC_L_S, tmp, left); /* Delay slot. */
|
590
|
+
emit_branch(as, MIPSI_BC1T, 0, 0, l_end);
|
591
|
+
emit_fgh(as, MIPSI_C_OLT_S, 0, left, tmp);
|
592
|
+
emit_lsptr(as, MIPSI_LWC1, (tmp & 31),
|
593
|
+
(void *)&as->J->k32[LJ_K32_2P63],
|
594
|
+
rset_exclude(RSET_GPR, dest));
|
595
|
+
}
|
596
|
+
#endif
|
503
597
|
} else {
|
598
|
+
#if LJ_32
|
504
599
|
emit_tg(as, MIPSI_MFC1, dest, tmp);
|
505
600
|
emit_fg(as, st == IRT_FLOAT ? MIPSI_TRUNC_W_S : MIPSI_TRUNC_W_D,
|
506
601
|
tmp, left);
|
602
|
+
#else
|
603
|
+
MIPSIns mi = irt_is64(ir->t) ?
|
604
|
+
(st == IRT_NUM ? MIPSI_TRUNC_L_D : MIPSI_TRUNC_L_S) :
|
605
|
+
(st == IRT_NUM ? MIPSI_TRUNC_W_D : MIPSI_TRUNC_W_S);
|
606
|
+
emit_tg(as, irt_is64(ir->t) ? MIPSI_DMFC1 : MIPSI_MFC1, dest, left);
|
607
|
+
emit_fg(as, mi, left, left);
|
608
|
+
#endif
|
507
609
|
}
|
508
610
|
}
|
509
611
|
} else
|
@@ -514,7 +616,7 @@ static void asm_conv(ASMState *as, IRIns *ir)
|
|
514
616
|
Reg left = ra_alloc1(as, ir->op1, RSET_GPR);
|
515
617
|
lua_assert(irt_isint(ir->t) || irt_isu32(ir->t));
|
516
618
|
if ((ir->op2 & IRCONV_SEXT)) {
|
517
|
-
if ((as->flags &
|
619
|
+
if (LJ_64 || (as->flags & JIT_F_MIPSXXR2)) {
|
518
620
|
emit_dst(as, st == IRT_I8 ? MIPSI_SEB : MIPSI_SEH, dest, 0, left);
|
519
621
|
} else {
|
520
622
|
uint32_t shift = st == IRT_I8 ? 24 : 16;
|
@@ -526,8 +628,35 @@ static void asm_conv(ASMState *as, IRIns *ir)
|
|
526
628
|
(int32_t)(st == IRT_U8 ? 0xff : 0xffff));
|
527
629
|
}
|
528
630
|
} else { /* 32/64 bit integer conversions. */
|
631
|
+
#if LJ_32
|
529
632
|
/* Only need to handle 32/32 bit no-op (cast) on 32 bit archs. */
|
530
633
|
ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */
|
634
|
+
#else
|
635
|
+
if (irt_is64(ir->t)) {
|
636
|
+
if (st64) {
|
637
|
+
/* 64/64 bit no-op (cast)*/
|
638
|
+
ra_leftov(as, dest, lref);
|
639
|
+
} else {
|
640
|
+
Reg left = ra_alloc1(as, lref, RSET_GPR);
|
641
|
+
if ((ir->op2 & IRCONV_SEXT)) { /* 32 to 64 bit sign extension. */
|
642
|
+
emit_dta(as, MIPSI_SLL, dest, left, 0);
|
643
|
+
} else { /* 32 to 64 bit zero extension. */
|
644
|
+
emit_tsml(as, MIPSI_DEXT, dest, left, 31, 0);
|
645
|
+
}
|
646
|
+
}
|
647
|
+
} else {
|
648
|
+
if (st64) {
|
649
|
+
/* This is either a 32 bit reg/reg mov which zeroes the hiword
|
650
|
+
** or a load of the loword from a 64 bit address.
|
651
|
+
*/
|
652
|
+
Reg left = ra_alloc1(as, lref, RSET_GPR);
|
653
|
+
emit_tsml(as, MIPSI_DEXT, dest, left, 31, 0);
|
654
|
+
} else { /* 32/32 bit no-op (cast). */
|
655
|
+
/* Do nothing, but may need to move regs. */
|
656
|
+
ra_leftov(as, dest, lref);
|
657
|
+
}
|
658
|
+
}
|
659
|
+
#endif
|
531
660
|
}
|
532
661
|
}
|
533
662
|
}
|
@@ -570,23 +699,50 @@ static void asm_strto(ASMState *as, IRIns *ir)
|
|
570
699
|
args[1] = ASMREF_TMP1; /* TValue *n */
|
571
700
|
asm_gencall(as, ci, args);
|
572
701
|
/* Store the result to the spill slot or temp slots. */
|
573
|
-
emit_tsi(as,
|
702
|
+
emit_tsi(as, MIPSI_AADDIU, ra_releasetmp(as, ASMREF_TMP1),
|
574
703
|
RID_SP, ofs);
|
575
704
|
}
|
576
705
|
|
577
706
|
/* -- Memory references --------------------------------------------------- */
|
578
707
|
|
708
|
+
#if LJ_64
|
709
|
+
/* Store tagged value for ref at base+ofs. */
|
710
|
+
static void asm_tvstore64(ASMState *as, Reg base, int32_t ofs, IRRef ref)
|
711
|
+
{
|
712
|
+
RegSet allow = rset_exclude(RSET_GPR, base);
|
713
|
+
IRIns *ir = IR(ref);
|
714
|
+
lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || irt_isinteger(ir->t));
|
715
|
+
if (irref_isk(ref)) {
|
716
|
+
TValue k;
|
717
|
+
lj_ir_kvalue(as->J->L, &k, ir);
|
718
|
+
emit_tsi(as, MIPSI_SD, ra_allock(as, (int64_t)k.u64, allow), base, ofs);
|
719
|
+
} else {
|
720
|
+
Reg src = ra_alloc1(as, ref, allow);
|
721
|
+
Reg type = ra_allock(as, (int64_t)irt_toitype(ir->t) << 47,
|
722
|
+
rset_exclude(allow, src));
|
723
|
+
emit_tsi(as, MIPSI_SD, RID_TMP, base, ofs);
|
724
|
+
if (irt_isinteger(ir->t)) {
|
725
|
+
emit_dst(as, MIPSI_DADDU, RID_TMP, RID_TMP, type);
|
726
|
+
emit_tsml(as, MIPSI_DEXT, RID_TMP, src, 31, 0);
|
727
|
+
} else {
|
728
|
+
emit_dst(as, MIPSI_DADDU, RID_TMP, src, type);
|
729
|
+
}
|
730
|
+
}
|
731
|
+
}
|
732
|
+
#endif
|
733
|
+
|
579
734
|
/* Get pointer to TValue. */
|
580
735
|
static void asm_tvptr(ASMState *as, Reg dest, IRRef ref)
|
581
736
|
{
|
582
737
|
IRIns *ir = IR(ref);
|
583
738
|
if (irt_isnum(ir->t)) {
|
584
739
|
if (irref_isk(ref)) /* Use the number constant itself as a TValue. */
|
585
|
-
ra_allockreg(as,
|
740
|
+
ra_allockreg(as, igcptr(ir_knum(ir)), dest);
|
586
741
|
else /* Otherwise force a spill and use the spill slot. */
|
587
|
-
emit_tsi(as,
|
742
|
+
emit_tsi(as, MIPSI_AADDIU, dest, RID_SP, ra_spill(as, ir));
|
588
743
|
} else {
|
589
744
|
/* Otherwise use g->tmptv to hold the TValue. */
|
745
|
+
#if LJ_32
|
590
746
|
RegSet allow = rset_exclude(RSET_GPR, dest);
|
591
747
|
Reg type;
|
592
748
|
emit_tsi(as, MIPSI_ADDIU, dest, RID_JGL, (int32_t)(offsetof(global_State, tmptv)-32768));
|
@@ -599,6 +755,11 @@ static void asm_tvptr(ASMState *as, Reg dest, IRRef ref)
|
|
599
755
|
else
|
600
756
|
type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow);
|
601
757
|
emit_setgl(as, type, tmptv.it);
|
758
|
+
#else
|
759
|
+
asm_tvstore64(as, dest, 0, ref);
|
760
|
+
emit_tsi(as, MIPSI_DADDIU, dest, RID_JGL,
|
761
|
+
(int32_t)(offsetof(global_State, tmptv)-32768));
|
762
|
+
#endif
|
602
763
|
}
|
603
764
|
}
|
604
765
|
|
@@ -613,13 +774,13 @@ static void asm_aref(ASMState *as, IRIns *ir)
|
|
613
774
|
ofs += 8*IR(ir->op2)->i;
|
614
775
|
if (checki16(ofs)) {
|
615
776
|
base = ra_alloc1(as, refa, RSET_GPR);
|
616
|
-
emit_tsi(as,
|
777
|
+
emit_tsi(as, MIPSI_AADDIU, dest, base, ofs);
|
617
778
|
return;
|
618
779
|
}
|
619
780
|
}
|
620
781
|
base = ra_alloc1(as, ir->op1, RSET_GPR);
|
621
782
|
idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base));
|
622
|
-
emit_dst(as,
|
783
|
+
emit_dst(as, MIPSI_AADDU, dest, RID_TMP, base);
|
623
784
|
emit_dta(as, MIPSI_SLL, RID_TMP, idx, 3);
|
624
785
|
}
|
625
786
|
|
@@ -640,19 +801,19 @@ static void asm_href(ASMState *as, IRIns *ir, IROp merge)
|
|
640
801
|
Reg key = RID_NONE, type = RID_NONE, tmpnum = RID_NONE, tmp1 = RID_TMP, tmp2;
|
641
802
|
IRRef refkey = ir->op2;
|
642
803
|
IRIns *irkey = IR(refkey);
|
804
|
+
int isk = irref_isk(refkey);
|
643
805
|
IRType1 kt = irkey->t;
|
644
806
|
uint32_t khash;
|
645
807
|
MCLabel l_end, l_loop, l_next;
|
646
808
|
|
647
809
|
rset_clear(allow, tab);
|
648
|
-
#if LJ_SOFTFP
|
649
|
-
if (!
|
810
|
+
#if LJ_32 && LJ_SOFTFP
|
811
|
+
if (!isk) {
|
650
812
|
key = ra_alloc1(as, refkey, allow);
|
651
813
|
rset_clear(allow, key);
|
652
814
|
if (irkey[1].o == IR_HIOP) {
|
653
815
|
if (ra_hasreg((irkey+1)->r)) {
|
654
|
-
tmpnum = (irkey+1)->r;
|
655
|
-
type = RID_TMP;
|
816
|
+
type = tmpnum = (irkey+1)->r;
|
656
817
|
tmp1 = ra_scratch(as, allow);
|
657
818
|
rset_clear(allow, tmp1);
|
658
819
|
ra_noweak(as, tmpnum);
|
@@ -672,8 +833,10 @@ static void asm_href(ASMState *as, IRIns *ir, IROp merge)
|
|
672
833
|
} else if (!irt_ispri(kt)) {
|
673
834
|
key = ra_alloc1(as, refkey, allow);
|
674
835
|
rset_clear(allow, key);
|
836
|
+
#if LJ_32
|
675
837
|
type = ra_allock(as, (int32_t)irt_toitype(irkey->t), allow);
|
676
838
|
rset_clear(allow, type);
|
839
|
+
#endif
|
677
840
|
}
|
678
841
|
#endif
|
679
842
|
tmp2 = ra_scratch(as, allow);
|
@@ -687,9 +850,9 @@ static void asm_href(ASMState *as, IRIns *ir, IROp merge)
|
|
687
850
|
else if (destused)
|
688
851
|
emit_loada(as, dest, niltvg(J2G(as->J)));
|
689
852
|
/* Follow hash chain until the end. */
|
690
|
-
emit_move(as, dest,
|
853
|
+
emit_move(as, dest, tmp1);
|
691
854
|
l_loop = --as->mcp;
|
692
|
-
emit_tsi(as,
|
855
|
+
emit_tsi(as, MIPSI_AL, tmp1, dest, (int32_t)offsetof(Node, next));
|
693
856
|
l_next = emit_label(as);
|
694
857
|
|
695
858
|
/* Type and value comparison. */
|
@@ -701,38 +864,66 @@ static void asm_href(ASMState *as, IRIns *ir, IROp merge)
|
|
701
864
|
emit_branch(as, MIPSI_BC1T, 0, 0, l_end);
|
702
865
|
emit_fgh(as, MIPSI_C_EQ_D, 0, tmpnum, key);
|
703
866
|
*--as->mcp = MIPSI_NOP; /* Avoid NaN comparison overhead. */
|
704
|
-
emit_branch(as, MIPSI_BEQ,
|
705
|
-
emit_tsi(as, MIPSI_SLTIU,
|
867
|
+
emit_branch(as, MIPSI_BEQ, tmp1, RID_ZERO, l_next);
|
868
|
+
emit_tsi(as, MIPSI_SLTIU, tmp1, tmp1, (int32_t)LJ_TISNUM);
|
869
|
+
#if LJ_32
|
706
870
|
emit_hsi(as, MIPSI_LDC1, tmpnum, dest, (int32_t)offsetof(Node, key.n));
|
707
871
|
} else {
|
708
872
|
if (irt_ispri(kt)) {
|
709
|
-
emit_branch(as, MIPSI_BEQ,
|
873
|
+
emit_branch(as, MIPSI_BEQ, tmp1, type, l_end);
|
710
874
|
} else {
|
711
|
-
emit_branch(as, MIPSI_BEQ,
|
712
|
-
emit_tsi(as, MIPSI_LW,
|
713
|
-
emit_branch(as, MIPSI_BNE,
|
875
|
+
emit_branch(as, MIPSI_BEQ, tmp2, key, l_end);
|
876
|
+
emit_tsi(as, MIPSI_LW, tmp2, dest, (int32_t)offsetof(Node, key.gcr));
|
877
|
+
emit_branch(as, MIPSI_BNE, tmp1, type, l_next);
|
878
|
+
}
|
879
|
+
}
|
880
|
+
emit_tsi(as, MIPSI_LW, tmp1, dest, (int32_t)offsetof(Node, key.it));
|
881
|
+
*l_loop = MIPSI_BNE | MIPSF_S(tmp1) | ((as->mcp-l_loop-1) & 0xffffu);
|
882
|
+
#else
|
883
|
+
emit_dta(as, MIPSI_DSRA32, tmp1, tmp1, 15);
|
884
|
+
emit_tg(as, MIPSI_DMTC1, tmp1, tmpnum);
|
885
|
+
emit_tsi(as, MIPSI_LD, tmp1, dest, (int32_t)offsetof(Node, key.u64));
|
886
|
+
} else if (irt_isaddr(kt)) {
|
887
|
+
Reg refk = tmp2;
|
888
|
+
if (isk) {
|
889
|
+
int64_t k = ((int64_t)irt_toitype(irkey->t) << 47) | irkey[1].tv.u64;
|
890
|
+
refk = ra_allock(as, k, allow);
|
891
|
+
rset_clear(allow, refk);
|
714
892
|
}
|
893
|
+
emit_branch(as, MIPSI_BEQ, tmp1, refk, l_end);
|
894
|
+
emit_tsi(as, MIPSI_LD, tmp1, dest, offsetof(Node, key));
|
895
|
+
} else {
|
896
|
+
Reg pri = ra_allock(as, ~((int64_t)~irt_toitype(ir->t) << 47), allow);
|
897
|
+
rset_clear(allow, pri);
|
898
|
+
lua_assert(irt_ispri(kt) && !irt_isnil(kt));
|
899
|
+
emit_branch(as, MIPSI_BEQ, tmp1, pri, l_end);
|
900
|
+
emit_tsi(as, MIPSI_LD, tmp1, dest, offsetof(Node, key));
|
901
|
+
}
|
902
|
+
*l_loop = MIPSI_BNE | MIPSF_S(tmp1) | ((as->mcp-l_loop-1) & 0xffffu);
|
903
|
+
if (!isk && irt_isaddr(kt)) {
|
904
|
+
type = ra_allock(as, (int64_t)irt_toitype(kt) << 47, allow);
|
905
|
+
emit_dst(as, MIPSI_DADDU, tmp2, key, type);
|
906
|
+
rset_clear(allow, type);
|
715
907
|
}
|
716
|
-
|
717
|
-
*l_loop = MIPSI_BNE | MIPSF_S(tmp2) | ((as->mcp-l_loop-1) & 0xffffu);
|
908
|
+
#endif
|
718
909
|
|
719
910
|
/* Load main position relative to tab->node into dest. */
|
720
|
-
khash =
|
911
|
+
khash = isk ? ir_khash(irkey) : 1;
|
721
912
|
if (khash == 0) {
|
722
|
-
emit_tsi(as,
|
913
|
+
emit_tsi(as, MIPSI_AL, dest, tab, (int32_t)offsetof(GCtab, node));
|
723
914
|
} else {
|
724
915
|
Reg tmphash = tmp1;
|
725
|
-
if (
|
916
|
+
if (isk)
|
726
917
|
tmphash = ra_allock(as, khash, allow);
|
727
|
-
emit_dst(as,
|
918
|
+
emit_dst(as, MIPSI_AADDU, dest, dest, tmp1);
|
728
919
|
lua_assert(sizeof(Node) == 24);
|
729
920
|
emit_dst(as, MIPSI_SUBU, tmp1, tmp2, tmp1);
|
730
921
|
emit_dta(as, MIPSI_SLL, tmp1, tmp1, 3);
|
731
922
|
emit_dta(as, MIPSI_SLL, tmp2, tmp1, 5);
|
732
923
|
emit_dst(as, MIPSI_AND, tmp1, tmp2, tmphash);
|
733
|
-
emit_tsi(as,
|
924
|
+
emit_tsi(as, MIPSI_AL, dest, tab, (int32_t)offsetof(GCtab, node));
|
734
925
|
emit_tsi(as, MIPSI_LW, tmp2, tab, (int32_t)offsetof(GCtab, hmask));
|
735
|
-
if (
|
926
|
+
if (isk) {
|
736
927
|
/* Nothing to do. */
|
737
928
|
} else if (irt_isstr(kt)) {
|
738
929
|
emit_tsi(as, MIPSI_LW, tmp1, key, (int32_t)offsetof(GCstr, hash));
|
@@ -742,9 +933,10 @@ static void asm_href(ASMState *as, IRIns *ir, IROp merge)
|
|
742
933
|
emit_dst(as, MIPSI_XOR, tmp1, tmp1, tmp2);
|
743
934
|
emit_rotr(as, tmp1, tmp1, dest, (-HASH_ROT2-HASH_ROT1)&31);
|
744
935
|
emit_dst(as, MIPSI_SUBU, tmp2, tmp2, dest);
|
936
|
+
#if LJ_32
|
745
937
|
if (LJ_SOFTFP ? (irkey[1].o == IR_HIOP) : irt_isnum(kt)) {
|
746
938
|
emit_dst(as, MIPSI_XOR, tmp2, tmp2, tmp1);
|
747
|
-
if ((as->flags &
|
939
|
+
if ((as->flags & JIT_F_MIPSXXR2)) {
|
748
940
|
emit_dta(as, MIPSI_ROTR, dest, tmp1, (-HASH_ROT1)&31);
|
749
941
|
} else {
|
750
942
|
emit_dst(as, MIPSI_OR, dest, dest, tmp1);
|
@@ -764,6 +956,23 @@ static void asm_href(ASMState *as, IRIns *ir, IROp merge)
|
|
764
956
|
emit_rotr(as, dest, tmp1, tmp2, (-HASH_ROT1)&31);
|
765
957
|
emit_dst(as, MIPSI_ADDU, tmp1, key, ra_allock(as, HASH_BIAS, allow));
|
766
958
|
}
|
959
|
+
#else
|
960
|
+
emit_dst(as, MIPSI_XOR, tmp2, tmp2, tmp1);
|
961
|
+
emit_dta(as, MIPSI_ROTR, dest, tmp1, (-HASH_ROT1)&31);
|
962
|
+
if (irt_isnum(kt)) {
|
963
|
+
emit_dst(as, MIPSI_ADDU, tmp1, tmp1, tmp1);
|
964
|
+
emit_dta(as, MIPSI_DSRA32, tmp1, tmp1, 0);
|
965
|
+
emit_dta(as, MIPSI_SLL, tmp2, LJ_SOFTFP ? key : tmp1, 0);
|
966
|
+
#if !LJ_SOFTFP
|
967
|
+
emit_tg(as, MIPSI_DMFC1, tmp1, key);
|
968
|
+
#endif
|
969
|
+
} else {
|
970
|
+
checkmclim(as);
|
971
|
+
emit_dta(as, MIPSI_DSRA32, tmp1, tmp1, 0);
|
972
|
+
emit_dta(as, MIPSI_SLL, tmp2, key, 0);
|
973
|
+
emit_dst(as, MIPSI_DADDU, tmp1, key, type);
|
974
|
+
}
|
975
|
+
#endif
|
767
976
|
}
|
768
977
|
}
|
769
978
|
}
|
@@ -776,17 +985,24 @@ static void asm_hrefk(ASMState *as, IRIns *ir)
|
|
776
985
|
int32_t kofs = ofs + (int32_t)offsetof(Node, key);
|
777
986
|
Reg dest = (ra_used(ir)||ofs > 32736) ? ra_dest(as, ir, RSET_GPR) : RID_NONE;
|
778
987
|
Reg node = ra_alloc1(as, ir->op1, RSET_GPR);
|
779
|
-
Reg key = RID_NONE, type = RID_TMP, idx = node;
|
780
988
|
RegSet allow = rset_exclude(RSET_GPR, node);
|
989
|
+
Reg idx = node;
|
990
|
+
#if LJ_32
|
991
|
+
Reg key = RID_NONE, type = RID_TMP;
|
781
992
|
int32_t lo, hi;
|
993
|
+
#else
|
994
|
+
Reg key = ra_scratch(as, allow);
|
995
|
+
int64_t k;
|
996
|
+
#endif
|
782
997
|
lua_assert(ofs % sizeof(Node) == 0);
|
783
998
|
if (ofs > 32736) {
|
784
999
|
idx = dest;
|
785
1000
|
rset_clear(allow, dest);
|
786
1001
|
kofs = (int32_t)offsetof(Node, key);
|
787
1002
|
} else if (ra_hasreg(dest)) {
|
788
|
-
emit_tsi(as,
|
1003
|
+
emit_tsi(as, MIPSI_AADDIU, dest, node, ofs);
|
789
1004
|
}
|
1005
|
+
#if LJ_32
|
790
1006
|
if (!irt_ispri(irkey->t)) {
|
791
1007
|
key = ra_scratch(as, allow);
|
792
1008
|
rset_clear(allow, key);
|
@@ -805,30 +1021,41 @@ nolo:
|
|
805
1021
|
asm_guard(as, MIPSI_BNE, type, hi ? ra_allock(as, hi, allow) : RID_ZERO);
|
806
1022
|
if (ra_hasreg(key)) emit_tsi(as, MIPSI_LW, key, idx, kofs+(LJ_BE?4:0));
|
807
1023
|
emit_tsi(as, MIPSI_LW, type, idx, kofs+(LJ_BE?0:4));
|
1024
|
+
#else
|
1025
|
+
if (irt_ispri(irkey->t)) {
|
1026
|
+
lua_assert(!irt_isnil(irkey->t));
|
1027
|
+
k = ~((int64_t)~irt_toitype(irkey->t) << 47);
|
1028
|
+
} else if (irt_isnum(irkey->t)) {
|
1029
|
+
k = (int64_t)ir_knum(irkey)->u64;
|
1030
|
+
} else {
|
1031
|
+
k = ((int64_t)irt_toitype(irkey->t) << 47) | (int64_t)ir_kgc(irkey);
|
1032
|
+
}
|
1033
|
+
asm_guard(as, MIPSI_BNE, key, ra_allock(as, k, allow));
|
1034
|
+
emit_tsi(as, MIPSI_LD, key, idx, kofs);
|
1035
|
+
#endif
|
808
1036
|
if (ofs > 32736)
|
809
|
-
emit_tsi(as,
|
1037
|
+
emit_tsi(as, MIPSI_AADDU, dest, node, ra_allock(as, ofs, allow));
|
810
1038
|
}
|
811
1039
|
|
812
1040
|
static void asm_uref(ASMState *as, IRIns *ir)
|
813
1041
|
{
|
814
|
-
/* NYI: Check that UREFO is still open and not aliasing a slot. */
|
815
1042
|
Reg dest = ra_dest(as, ir, RSET_GPR);
|
816
1043
|
if (irref_isk(ir->op1)) {
|
817
1044
|
GCfunc *fn = ir_kfunc(IR(ir->op1));
|
818
1045
|
MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v;
|
819
|
-
emit_lsptr(as,
|
1046
|
+
emit_lsptr(as, MIPSI_AL, dest, v, RSET_GPR);
|
820
1047
|
} else {
|
821
1048
|
Reg uv = ra_scratch(as, RSET_GPR);
|
822
1049
|
Reg func = ra_alloc1(as, ir->op1, RSET_GPR);
|
823
1050
|
if (ir->o == IR_UREFC) {
|
824
1051
|
asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO);
|
825
|
-
emit_tsi(as,
|
1052
|
+
emit_tsi(as, MIPSI_AADDIU, dest, uv, (int32_t)offsetof(GCupval, tv));
|
826
1053
|
emit_tsi(as, MIPSI_LBU, RID_TMP, uv, (int32_t)offsetof(GCupval, closed));
|
827
1054
|
} else {
|
828
|
-
emit_tsi(as,
|
1055
|
+
emit_tsi(as, MIPSI_AL, dest, uv, (int32_t)offsetof(GCupval, v));
|
829
1056
|
}
|
830
|
-
emit_tsi(as,
|
831
|
-
(int32_t)
|
1057
|
+
emit_tsi(as, MIPSI_AL, uv, func, (int32_t)offsetof(GCfuncL, uvptr) +
|
1058
|
+
(int32_t)sizeof(MRef) * (int32_t)(ir->op2 >> 8));
|
832
1059
|
}
|
833
1060
|
}
|
834
1061
|
|
@@ -840,6 +1067,7 @@ static void asm_fref(ASMState *as, IRIns *ir)
|
|
840
1067
|
|
841
1068
|
static void asm_strref(ASMState *as, IRIns *ir)
|
842
1069
|
{
|
1070
|
+
#if LJ_32
|
843
1071
|
Reg dest = ra_dest(as, ir, RSET_GPR);
|
844
1072
|
IRRef ref = ir->op2, refk = ir->op1;
|
845
1073
|
int32_t ofs = (int32_t)sizeof(GCstr);
|
@@ -871,6 +1099,20 @@ static void asm_strref(ASMState *as, IRIns *ir)
|
|
871
1099
|
else
|
872
1100
|
emit_dst(as, MIPSI_ADDU, dest, r,
|
873
1101
|
ra_allock(as, ofs, rset_exclude(RSET_GPR, r)));
|
1102
|
+
#else
|
1103
|
+
RegSet allow = RSET_GPR;
|
1104
|
+
Reg dest = ra_dest(as, ir, allow);
|
1105
|
+
Reg base = ra_alloc1(as, ir->op1, allow);
|
1106
|
+
IRIns *irr = IR(ir->op2);
|
1107
|
+
int32_t ofs = sizeof(GCstr);
|
1108
|
+
rset_clear(allow, base);
|
1109
|
+
if (irref_isk(ir->op2) && checki16(ofs + irr->i)) {
|
1110
|
+
emit_tsi(as, MIPSI_DADDIU, dest, base, ofs + irr->i);
|
1111
|
+
} else {
|
1112
|
+
emit_tsi(as, MIPSI_DADDIU, dest, dest, ofs);
|
1113
|
+
emit_dst(as, MIPSI_DADDU, dest, base, ra_alloc1(as, ir->op2, allow));
|
1114
|
+
}
|
1115
|
+
#endif
|
874
1116
|
}
|
875
1117
|
|
876
1118
|
/* -- Loads and stores ---------------------------------------------------- */
|
@@ -884,7 +1126,7 @@ static MIPSIns asm_fxloadins(IRIns *ir)
|
|
884
1126
|
case IRT_U16: return MIPSI_LHU;
|
885
1127
|
case IRT_NUM: lua_assert(!LJ_SOFTFP); return MIPSI_LDC1;
|
886
1128
|
case IRT_FLOAT: if (!LJ_SOFTFP) return MIPSI_LWC1;
|
887
|
-
default: return MIPSI_LW;
|
1129
|
+
default: return (LJ_64 && irt_is64(ir->t)) ? MIPSI_LD : MIPSI_LW;
|
888
1130
|
}
|
889
1131
|
}
|
890
1132
|
|
@@ -895,24 +1137,30 @@ static MIPSIns asm_fxstoreins(IRIns *ir)
|
|
895
1137
|
case IRT_I16: case IRT_U16: return MIPSI_SH;
|
896
1138
|
case IRT_NUM: lua_assert(!LJ_SOFTFP); return MIPSI_SDC1;
|
897
1139
|
case IRT_FLOAT: if (!LJ_SOFTFP) return MIPSI_SWC1;
|
898
|
-
default: return MIPSI_SW;
|
1140
|
+
default: return (LJ_64 && irt_is64(ir->t)) ? MIPSI_SD : MIPSI_SW;
|
899
1141
|
}
|
900
1142
|
}
|
901
1143
|
|
902
1144
|
static void asm_fload(ASMState *as, IRIns *ir)
|
903
1145
|
{
|
904
1146
|
Reg dest = ra_dest(as, ir, RSET_GPR);
|
905
|
-
Reg idx = ra_alloc1(as, ir->op1, RSET_GPR);
|
906
1147
|
MIPSIns mi = asm_fxloadins(ir);
|
1148
|
+
Reg idx;
|
907
1149
|
int32_t ofs;
|
908
|
-
if (ir->
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
1150
|
+
if (ir->op1 == REF_NIL) {
|
1151
|
+
idx = RID_JGL;
|
1152
|
+
ofs = (ir->op2 << 2) - 32768 - GG_OFS(g);
|
1153
|
+
} else {
|
1154
|
+
idx = ra_alloc1(as, ir->op1, RSET_GPR);
|
1155
|
+
if (ir->op2 == IRFL_TAB_ARRAY) {
|
1156
|
+
ofs = asm_fuseabase(as, ir->op1);
|
1157
|
+
if (ofs) { /* Turn the t->array load into an add for colocated arrays. */
|
1158
|
+
emit_tsi(as, MIPSI_AADDIU, dest, idx, ofs);
|
1159
|
+
return;
|
1160
|
+
}
|
913
1161
|
}
|
1162
|
+
ofs = field_ofs[ir->op2];
|
914
1163
|
}
|
915
|
-
ofs = field_ofs[ir->op2];
|
916
1164
|
lua_assert(!irt_isfp(ir->t));
|
917
1165
|
emit_tsi(as, mi, dest, idx, ofs);
|
918
1166
|
}
|
@@ -952,36 +1200,59 @@ static void asm_xstore_(ASMState *as, IRIns *ir, int32_t ofs)
|
|
952
1200
|
|
953
1201
|
static void asm_ahuvload(ASMState *as, IRIns *ir)
|
954
1202
|
{
|
955
|
-
int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP);
|
956
|
-
IRType t = hiop ? IRT_NUM : irt_type(ir->t);
|
1203
|
+
int hiop = (LJ_32 && LJ_SOFTFP && (ir+1)->o == IR_HIOP);
|
957
1204
|
Reg dest = RID_NONE, type = RID_TMP, idx;
|
958
1205
|
RegSet allow = RSET_GPR;
|
959
1206
|
int32_t ofs = 0;
|
960
|
-
|
961
|
-
|
962
|
-
|
1207
|
+
IRType1 t = ir->t;
|
1208
|
+
if (hiop) {
|
1209
|
+
t.irt = IRT_NUM;
|
1210
|
+
if (ra_used(ir+1)) {
|
1211
|
+
type = ra_dest(as, ir+1, allow);
|
1212
|
+
rset_clear(allow, type);
|
1213
|
+
}
|
963
1214
|
}
|
964
1215
|
if (ra_used(ir)) {
|
965
1216
|
lua_assert((LJ_SOFTFP ? 0 : irt_isnum(ir->t)) ||
|
966
1217
|
irt_isint(ir->t) || irt_isaddr(ir->t));
|
967
|
-
dest = ra_dest(as, ir, (!LJ_SOFTFP && t
|
1218
|
+
dest = ra_dest(as, ir, (!LJ_SOFTFP && irt_isnum(t)) ? RSET_FPR : allow);
|
968
1219
|
rset_clear(allow, dest);
|
1220
|
+
#if LJ_64
|
1221
|
+
if (irt_isaddr(t))
|
1222
|
+
emit_tsml(as, MIPSI_DEXTM, dest, dest, 14, 0);
|
1223
|
+
else if (irt_isint(t))
|
1224
|
+
emit_dta(as, MIPSI_SLL, dest, dest, 0);
|
1225
|
+
#endif
|
969
1226
|
}
|
970
1227
|
idx = asm_fuseahuref(as, ir->op1, &ofs, allow);
|
971
1228
|
rset_clear(allow, idx);
|
972
|
-
if (t
|
1229
|
+
if (irt_isnum(t)) {
|
973
1230
|
asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO);
|
974
1231
|
emit_tsi(as, MIPSI_SLTIU, RID_TMP, type, (int32_t)LJ_TISNUM);
|
975
1232
|
} else {
|
976
|
-
asm_guard(as, MIPSI_BNE, type,
|
1233
|
+
asm_guard(as, MIPSI_BNE, type,
|
1234
|
+
ra_allock(as, (int32_t)irt_toitype(t), allow));
|
977
1235
|
}
|
1236
|
+
#if LJ_32
|
978
1237
|
if (ra_hasreg(dest)) {
|
979
|
-
if (!LJ_SOFTFP && t
|
1238
|
+
if (!LJ_SOFTFP && irt_isnum(t))
|
980
1239
|
emit_hsi(as, MIPSI_LDC1, dest, idx, ofs);
|
981
1240
|
else
|
982
1241
|
emit_tsi(as, MIPSI_LW, dest, idx, ofs+(LJ_BE?4:0));
|
983
1242
|
}
|
984
1243
|
emit_tsi(as, MIPSI_LW, type, idx, ofs+(LJ_BE?0:4));
|
1244
|
+
#else
|
1245
|
+
if (ra_hasreg(dest)) {
|
1246
|
+
if (!LJ_SOFTFP && irt_isnum(t)) {
|
1247
|
+
emit_hsi(as, MIPSI_LDC1, dest, idx, ofs);
|
1248
|
+
dest = type;
|
1249
|
+
}
|
1250
|
+
} else {
|
1251
|
+
dest = type;
|
1252
|
+
}
|
1253
|
+
emit_dta(as, MIPSI_DSRA32, type, dest, 15);
|
1254
|
+
emit_tsi(as, MIPSI_LD, dest, idx, ofs);
|
1255
|
+
#endif
|
985
1256
|
}
|
986
1257
|
|
987
1258
|
static void asm_ahustore(ASMState *as, IRIns *ir)
|
@@ -993,103 +1264,159 @@ static void asm_ahustore(ASMState *as, IRIns *ir)
|
|
993
1264
|
return;
|
994
1265
|
if (!LJ_SOFTFP && irt_isnum(ir->t)) {
|
995
1266
|
src = ra_alloc1(as, ir->op2, RSET_FPR);
|
1267
|
+
idx = asm_fuseahuref(as, ir->op1, &ofs, allow);
|
1268
|
+
emit_hsi(as, MIPSI_SDC1, src, idx, ofs);
|
996
1269
|
} else {
|
997
|
-
|
1270
|
+
#if LJ_32
|
998
1271
|
if (!irt_ispri(ir->t)) {
|
999
1272
|
src = ra_alloc1(as, ir->op2, allow);
|
1000
1273
|
rset_clear(allow, src);
|
1001
1274
|
}
|
1002
|
-
if (
|
1275
|
+
if (LJ_SOFTFP && (ir+1)->o == IR_HIOP)
|
1003
1276
|
type = ra_alloc1(as, (ir+1)->op2, allow);
|
1004
1277
|
else
|
1005
1278
|
type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow);
|
1006
1279
|
rset_clear(allow, type);
|
1007
|
-
|
1008
|
-
idx = asm_fuseahuref(as, ir->op1, &ofs, allow);
|
1009
|
-
if (!LJ_SOFTFP && irt_isnum(ir->t)) {
|
1010
|
-
emit_hsi(as, MIPSI_SDC1, src, idx, ofs);
|
1011
|
-
} else {
|
1280
|
+
idx = asm_fuseahuref(as, ir->op1, &ofs, allow);
|
1012
1281
|
if (ra_hasreg(src))
|
1013
1282
|
emit_tsi(as, MIPSI_SW, src, idx, ofs+(LJ_BE?4:0));
|
1014
1283
|
emit_tsi(as, MIPSI_SW, type, idx, ofs+(LJ_BE?0:4));
|
1284
|
+
#else
|
1285
|
+
Reg tmp = RID_TMP;
|
1286
|
+
if (irt_ispri(ir->t)) {
|
1287
|
+
tmp = ra_allock(as, ~((int64_t)~irt_toitype(ir->t) << 47), allow);
|
1288
|
+
rset_clear(allow, tmp);
|
1289
|
+
} else {
|
1290
|
+
src = ra_alloc1(as, ir->op2, allow);
|
1291
|
+
rset_clear(allow, src);
|
1292
|
+
type = ra_allock(as, (int64_t)irt_toitype(ir->t) << 47, allow);
|
1293
|
+
rset_clear(allow, type);
|
1294
|
+
}
|
1295
|
+
idx = asm_fuseahuref(as, ir->op1, &ofs, allow);
|
1296
|
+
emit_tsi(as, MIPSI_SD, tmp, idx, ofs);
|
1297
|
+
if (ra_hasreg(src)) {
|
1298
|
+
if (irt_isinteger(ir->t)) {
|
1299
|
+
emit_dst(as, MIPSI_DADDU, tmp, tmp, type);
|
1300
|
+
emit_tsml(as, MIPSI_DEXT, tmp, src, 31, 0);
|
1301
|
+
} else {
|
1302
|
+
emit_dst(as, MIPSI_DADDU, tmp, src, type);
|
1303
|
+
}
|
1304
|
+
}
|
1305
|
+
#endif
|
1015
1306
|
}
|
1016
1307
|
}
|
1017
1308
|
|
1018
1309
|
static void asm_sload(ASMState *as, IRIns *ir)
|
1019
1310
|
{
|
1020
|
-
int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0);
|
1021
|
-
int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP);
|
1022
|
-
IRType t = hiop ? IRT_NUM : irt_type(ir->t);
|
1023
1311
|
Reg dest = RID_NONE, type = RID_NONE, base;
|
1024
1312
|
RegSet allow = RSET_GPR;
|
1313
|
+
IRType1 t = ir->t;
|
1314
|
+
#if LJ_32
|
1315
|
+
int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0);
|
1316
|
+
int hiop = (LJ_32 && LJ_SOFTFP && (ir+1)->o == IR_HIOP);
|
1317
|
+
if (hiop)
|
1318
|
+
t.irt = IRT_NUM;
|
1319
|
+
#else
|
1320
|
+
int32_t ofs = 8*((int32_t)ir->op1-2);
|
1321
|
+
#endif
|
1025
1322
|
lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */
|
1026
1323
|
lua_assert(irt_isguard(ir->t) || !(ir->op2 & IRSLOAD_TYPECHECK));
|
1027
|
-
#if LJ_SOFTFP
|
1324
|
+
#if LJ_32 && LJ_SOFTFP
|
1028
1325
|
lua_assert(!(ir->op2 & IRSLOAD_CONVERT)); /* Handled by LJ_SOFTFP SPLIT. */
|
1029
1326
|
if (hiop && ra_used(ir+1)) {
|
1030
1327
|
type = ra_dest(as, ir+1, allow);
|
1031
1328
|
rset_clear(allow, type);
|
1032
1329
|
}
|
1033
1330
|
#else
|
1034
|
-
if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(
|
1331
|
+
if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(t) && irt_isint(t)) {
|
1035
1332
|
dest = ra_scratch(as, RSET_FPR);
|
1036
1333
|
asm_tointg(as, ir, dest);
|
1037
|
-
t = IRT_NUM; /* Continue with a regular number type check. */
|
1334
|
+
t.irt = IRT_NUM; /* Continue with a regular number type check. */
|
1038
1335
|
} else
|
1039
1336
|
#endif
|
1040
1337
|
if (ra_used(ir)) {
|
1041
1338
|
lua_assert((LJ_SOFTFP ? 0 : irt_isnum(ir->t)) ||
|
1042
1339
|
irt_isint(ir->t) || irt_isaddr(ir->t));
|
1043
|
-
dest = ra_dest(as, ir, (!LJ_SOFTFP && t
|
1340
|
+
dest = ra_dest(as, ir, (!LJ_SOFTFP && irt_isnum(t)) ? RSET_FPR : allow);
|
1044
1341
|
rset_clear(allow, dest);
|
1045
1342
|
base = ra_alloc1(as, REF_BASE, allow);
|
1046
1343
|
rset_clear(allow, base);
|
1047
1344
|
if (!LJ_SOFTFP && (ir->op2 & IRSLOAD_CONVERT)) {
|
1048
|
-
if (t
|
1345
|
+
if (irt_isint(t)) {
|
1049
1346
|
Reg tmp = ra_scratch(as, RSET_FPR);
|
1050
1347
|
emit_tg(as, MIPSI_MFC1, dest, tmp);
|
1051
1348
|
emit_fg(as, MIPSI_TRUNC_W_D, tmp, tmp);
|
1052
1349
|
dest = tmp;
|
1053
|
-
t = IRT_NUM; /* Check for original type. */
|
1350
|
+
t.irt = IRT_NUM; /* Check for original type. */
|
1054
1351
|
} else {
|
1055
1352
|
Reg tmp = ra_scratch(as, RSET_GPR);
|
1056
1353
|
emit_fg(as, MIPSI_CVT_D_W, dest, dest);
|
1057
1354
|
emit_tg(as, MIPSI_MTC1, tmp, dest);
|
1058
1355
|
dest = tmp;
|
1059
|
-
t = IRT_INT; /* Check for original type. */
|
1356
|
+
t.irt = IRT_INT; /* Check for original type. */
|
1060
1357
|
}
|
1061
1358
|
}
|
1359
|
+
#if LJ_64
|
1360
|
+
else if (irt_isaddr(t)) {
|
1361
|
+
/* Clear type from pointers. */
|
1362
|
+
emit_tsml(as, MIPSI_DEXTM, dest, dest, 14, 0);
|
1363
|
+
} else if (irt_isint(t) && (ir->op2 & IRSLOAD_TYPECHECK)) {
|
1364
|
+
/* Sign-extend integers. */
|
1365
|
+
emit_dta(as, MIPSI_SLL, dest, dest, 0);
|
1366
|
+
}
|
1367
|
+
#endif
|
1062
1368
|
goto dotypecheck;
|
1063
1369
|
}
|
1064
1370
|
base = ra_alloc1(as, REF_BASE, allow);
|
1065
1371
|
rset_clear(allow, base);
|
1066
1372
|
dotypecheck:
|
1373
|
+
#if LJ_32
|
1067
1374
|
if ((ir->op2 & IRSLOAD_TYPECHECK)) {
|
1068
|
-
if (ra_noreg(type))
|
1069
|
-
|
1070
|
-
|
1071
|
-
type = dest+1;
|
1072
|
-
ra_modified(as, type);
|
1073
|
-
} else {
|
1074
|
-
type = RID_TMP;
|
1075
|
-
}
|
1076
|
-
}
|
1077
|
-
if (t == IRT_NUM) {
|
1375
|
+
if (ra_noreg(type))
|
1376
|
+
type = RID_TMP;
|
1377
|
+
if (irt_isnum(t)) {
|
1078
1378
|
asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO);
|
1079
1379
|
emit_tsi(as, MIPSI_SLTIU, RID_TMP, type, (int32_t)LJ_TISNUM);
|
1080
1380
|
} else {
|
1081
|
-
Reg ktype = ra_allock(as,
|
1381
|
+
Reg ktype = ra_allock(as, irt_toitype(t), allow);
|
1082
1382
|
asm_guard(as, MIPSI_BNE, type, ktype);
|
1083
1383
|
}
|
1084
1384
|
}
|
1085
1385
|
if (ra_hasreg(dest)) {
|
1086
|
-
if (!LJ_SOFTFP && t
|
1386
|
+
if (!LJ_SOFTFP && irt_isnum(t))
|
1087
1387
|
emit_hsi(as, MIPSI_LDC1, dest, base, ofs);
|
1088
1388
|
else
|
1089
1389
|
emit_tsi(as, MIPSI_LW, dest, base, ofs ^ (LJ_BE?4:0));
|
1090
1390
|
}
|
1091
1391
|
if (ra_hasreg(type))
|
1092
1392
|
emit_tsi(as, MIPSI_LW, type, base, ofs ^ (LJ_BE?0:4));
|
1393
|
+
#else
|
1394
|
+
if ((ir->op2 & IRSLOAD_TYPECHECK)) {
|
1395
|
+
type = dest < RID_MAX_GPR ? dest : RID_TMP;
|
1396
|
+
if (irt_ispri(t)) {
|
1397
|
+
asm_guard(as, MIPSI_BNE, type,
|
1398
|
+
ra_allock(as, ~((int64_t)~irt_toitype(t) << 47) , allow));
|
1399
|
+
} else {
|
1400
|
+
if (irt_isnum(t)) {
|
1401
|
+
asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO);
|
1402
|
+
emit_tsi(as, MIPSI_SLTIU, RID_TMP, RID_TMP, (int32_t)LJ_TISNUM);
|
1403
|
+
if (ra_hasreg(dest))
|
1404
|
+
emit_hsi(as, MIPSI_LDC1, dest, base, ofs);
|
1405
|
+
} else {
|
1406
|
+
asm_guard(as, MIPSI_BNE, RID_TMP,
|
1407
|
+
ra_allock(as, (int32_t)irt_toitype(t), allow));
|
1408
|
+
}
|
1409
|
+
emit_dta(as, MIPSI_DSRA32, RID_TMP, type, 15);
|
1410
|
+
}
|
1411
|
+
emit_tsi(as, MIPSI_LD, type, base, ofs);
|
1412
|
+
} else if (ra_hasreg(dest)) {
|
1413
|
+
if (irt_isnum(t))
|
1414
|
+
emit_hsi(as, MIPSI_LDC1, dest, base, ofs);
|
1415
|
+
else
|
1416
|
+
emit_tsi(as, irt_isint(t) ? MIPSI_LW : MIPSI_LD, dest, base,
|
1417
|
+
ofs ^ ((LJ_BE && irt_isint(t)) ? 4 : 0));
|
1418
|
+
}
|
1419
|
+
#endif
|
1093
1420
|
}
|
1094
1421
|
|
1095
1422
|
/* -- Allocations --------------------------------------------------------- */
|
@@ -1116,8 +1443,8 @@ static void asm_cnew(ASMState *as, IRIns *ir)
|
|
1116
1443
|
/* Initialize immutable cdata object. */
|
1117
1444
|
if (ir->o == IR_CNEWI) {
|
1118
1445
|
RegSet allow = (RSET_GPR & ~RSET_SCRATCH);
|
1446
|
+
#if LJ_32
|
1119
1447
|
int32_t ofs = sizeof(GCcdata);
|
1120
|
-
lua_assert(sz == 4 || sz == 8);
|
1121
1448
|
if (sz == 8) {
|
1122
1449
|
ofs += 4;
|
1123
1450
|
lua_assert((ir+1)->o == IR_HIOP);
|
@@ -1130,6 +1457,11 @@ static void asm_cnew(ASMState *as, IRIns *ir)
|
|
1130
1457
|
if (ofs == sizeof(GCcdata)) break;
|
1131
1458
|
ofs -= 4; if (LJ_BE) ir++; else ir--;
|
1132
1459
|
}
|
1460
|
+
#else
|
1461
|
+
emit_tsi(as, MIPSI_SD, ra_alloc1(as, ir->op2, allow),
|
1462
|
+
RID_RET, sizeof(GCcdata));
|
1463
|
+
#endif
|
1464
|
+
lua_assert(sz == 4 || sz == 8);
|
1133
1465
|
} else if (ir->op2 != REF_NIL) { /* Create VLA/VLS/aligned cdata. */
|
1134
1466
|
ci = &lj_ir_callinfo[IRCALL_lj_cdata_newv];
|
1135
1467
|
args[0] = ASMREF_L; /* lua_State *L */
|
@@ -1164,7 +1496,7 @@ static void asm_tbar(ASMState *as, IRIns *ir)
|
|
1164
1496
|
Reg mark = ra_scratch(as, rset_exclude(RSET_GPR, tab));
|
1165
1497
|
Reg link = RID_TMP;
|
1166
1498
|
MCLabel l_end = emit_label(as);
|
1167
|
-
emit_tsi(as,
|
1499
|
+
emit_tsi(as, MIPSI_AS, link, tab, (int32_t)offsetof(GCtab, gclist));
|
1168
1500
|
emit_tsi(as, MIPSI_SB, mark, tab, (int32_t)offsetof(GCtab, marked));
|
1169
1501
|
emit_setgl(as, tab, gc.grayagain);
|
1170
1502
|
emit_getgl(as, link, gc.grayagain);
|
@@ -1187,7 +1519,7 @@ static void asm_obar(ASMState *as, IRIns *ir)
|
|
1187
1519
|
args[0] = ASMREF_TMP1; /* global_State *g */
|
1188
1520
|
args[1] = ir->op1; /* TValue *tv */
|
1189
1521
|
asm_gencall(as, ci, args);
|
1190
|
-
emit_tsi(as,
|
1522
|
+
emit_tsi(as, MIPSI_AADDIU, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768);
|
1191
1523
|
obj = IR(ir->op1)->r;
|
1192
1524
|
tmp = ra_scratch(as, rset_exclude(RSET_GPR, obj));
|
1193
1525
|
emit_branch(as, MIPSI_BEQ, RID_TMP, RID_ZERO, l_end);
|
@@ -1233,8 +1565,9 @@ static void asm_fpmath(ASMState *as, IRIns *ir)
|
|
1233
1565
|
|
1234
1566
|
static void asm_add(ASMState *as, IRIns *ir)
|
1235
1567
|
{
|
1568
|
+
IRType1 t = ir->t;
|
1236
1569
|
#if !LJ_SOFTFP
|
1237
|
-
if (irt_isnum(
|
1570
|
+
if (irt_isnum(t)) {
|
1238
1571
|
asm_fparith(as, ir, MIPSI_ADD_D);
|
1239
1572
|
} else
|
1240
1573
|
#endif
|
@@ -1242,14 +1575,16 @@ static void asm_add(ASMState *as, IRIns *ir)
|
|
1242
1575
|
Reg dest = ra_dest(as, ir, RSET_GPR);
|
1243
1576
|
Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR);
|
1244
1577
|
if (irref_isk(ir->op2)) {
|
1245
|
-
|
1578
|
+
intptr_t k = get_kval(IR(ir->op2));
|
1246
1579
|
if (checki16(k)) {
|
1247
|
-
emit_tsi(as, MIPSI_ADDIU, dest,
|
1580
|
+
emit_tsi(as, (LJ_64 && irt_is64(t)) ? MIPSI_DADDIU : MIPSI_ADDIU, dest,
|
1581
|
+
left, k);
|
1248
1582
|
return;
|
1249
1583
|
}
|
1250
1584
|
}
|
1251
1585
|
right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left));
|
1252
|
-
emit_dst(as, MIPSI_ADDU, dest,
|
1586
|
+
emit_dst(as, (LJ_64 && irt_is64(t)) ? MIPSI_DADDU : MIPSI_ADDU, dest,
|
1587
|
+
left, right);
|
1253
1588
|
}
|
1254
1589
|
}
|
1255
1590
|
|
@@ -1264,7 +1599,8 @@ static void asm_sub(ASMState *as, IRIns *ir)
|
|
1264
1599
|
Reg dest = ra_dest(as, ir, RSET_GPR);
|
1265
1600
|
Reg right, left = ra_alloc2(as, ir, RSET_GPR);
|
1266
1601
|
right = (left >> 8); left &= 255;
|
1267
|
-
emit_dst(as, MIPSI_SUBU, dest,
|
1602
|
+
emit_dst(as, (LJ_64 && irt_is64(ir->t)) ? MIPSI_DSUBU : MIPSI_SUBU, dest,
|
1603
|
+
left, right);
|
1268
1604
|
}
|
1269
1605
|
}
|
1270
1606
|
|
@@ -1279,13 +1615,49 @@ static void asm_mul(ASMState *as, IRIns *ir)
|
|
1279
1615
|
Reg dest = ra_dest(as, ir, RSET_GPR);
|
1280
1616
|
Reg right, left = ra_alloc2(as, ir, RSET_GPR);
|
1281
1617
|
right = (left >> 8); left &= 255;
|
1282
|
-
|
1618
|
+
if (LJ_64 && irt_is64(ir->t)) {
|
1619
|
+
emit_dst(as, MIPSI_MFLO, dest, 0, 0);
|
1620
|
+
emit_dst(as, MIPSI_DMULT, 0, left, right);
|
1621
|
+
} else {
|
1622
|
+
emit_dst(as, MIPSI_MUL, dest, left, right);
|
1623
|
+
}
|
1283
1624
|
}
|
1284
1625
|
}
|
1285
1626
|
|
1286
|
-
|
1287
|
-
|
1288
|
-
#
|
1627
|
+
static void asm_mod(ASMState *as, IRIns *ir)
|
1628
|
+
{
|
1629
|
+
#if LJ_64 && LJ_HASFFI
|
1630
|
+
if (!irt_isint(ir->t))
|
1631
|
+
asm_callid(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_modi64 :
|
1632
|
+
IRCALL_lj_carith_modu64);
|
1633
|
+
else
|
1634
|
+
#endif
|
1635
|
+
asm_callid(as, ir, IRCALL_lj_vm_modi);
|
1636
|
+
}
|
1637
|
+
|
1638
|
+
#if !LJ_SOFTFP
|
1639
|
+
static void asm_pow(ASMState *as, IRIns *ir)
|
1640
|
+
{
|
1641
|
+
#if LJ_64 && LJ_HASFFI
|
1642
|
+
if (!irt_isnum(ir->t))
|
1643
|
+
asm_callid(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_powi64 :
|
1644
|
+
IRCALL_lj_carith_powu64);
|
1645
|
+
else
|
1646
|
+
#endif
|
1647
|
+
asm_callid(as, ir, IRCALL_lj_vm_powi);
|
1648
|
+
}
|
1649
|
+
|
1650
|
+
static void asm_div(ASMState *as, IRIns *ir)
|
1651
|
+
{
|
1652
|
+
#if LJ_64 && LJ_HASFFI
|
1653
|
+
if (!irt_isnum(ir->t))
|
1654
|
+
asm_callid(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_divi64 :
|
1655
|
+
IRCALL_lj_carith_divu64);
|
1656
|
+
else
|
1657
|
+
#endif
|
1658
|
+
asm_fparith(as, ir, MIPSI_DIV_D);
|
1659
|
+
}
|
1660
|
+
#endif
|
1289
1661
|
|
1290
1662
|
static void asm_neg(ASMState *as, IRIns *ir)
|
1291
1663
|
{
|
@@ -1297,7 +1669,8 @@ static void asm_neg(ASMState *as, IRIns *ir)
|
|
1297
1669
|
{
|
1298
1670
|
Reg dest = ra_dest(as, ir, RSET_GPR);
|
1299
1671
|
Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR);
|
1300
|
-
emit_dst(as, MIPSI_SUBU, dest,
|
1672
|
+
emit_dst(as, (LJ_64 && irt_is64(ir->t)) ? MIPSI_DSUBU : MIPSI_SUBU, dest,
|
1673
|
+
RID_ZERO, left);
|
1301
1674
|
}
|
1302
1675
|
}
|
1303
1676
|
|
@@ -1308,6 +1681,7 @@ static void asm_neg(ASMState *as, IRIns *ir)
|
|
1308
1681
|
static void asm_arithov(ASMState *as, IRIns *ir)
|
1309
1682
|
{
|
1310
1683
|
Reg right, left, tmp, dest = ra_dest(as, ir, RSET_GPR);
|
1684
|
+
lua_assert(!irt_is64(ir->t));
|
1311
1685
|
if (irref_isk(ir->op2)) {
|
1312
1686
|
int k = IR(ir->op2)->i;
|
1313
1687
|
if (ir->o == IR_SUBOV) k = -k;
|
@@ -1355,7 +1729,7 @@ static void asm_mulov(ASMState *as, IRIns *ir)
|
|
1355
1729
|
emit_dst(as, MIPSI_MULT, 0, left, right);
|
1356
1730
|
}
|
1357
1731
|
|
1358
|
-
#if LJ_HASFFI
|
1732
|
+
#if LJ_32 && LJ_HASFFI
|
1359
1733
|
static void asm_add64(ASMState *as, IRIns *ir)
|
1360
1734
|
{
|
1361
1735
|
Reg dest = ra_dest(as, ir, RSET_GPR);
|
@@ -1457,7 +1831,8 @@ static void asm_bswap(ASMState *as, IRIns *ir)
|
|
1457
1831
|
{
|
1458
1832
|
Reg dest = ra_dest(as, ir, RSET_GPR);
|
1459
1833
|
Reg left = ra_alloc1(as, ir->op1, RSET_GPR);
|
1460
|
-
|
1834
|
+
#if LJ_32
|
1835
|
+
if ((as->flags & JIT_F_MIPSXXR2)) {
|
1461
1836
|
emit_dta(as, MIPSI_ROTR, dest, RID_TMP, 16);
|
1462
1837
|
emit_dst(as, MIPSI_WSBH, RID_TMP, 0, left);
|
1463
1838
|
} else {
|
@@ -1472,6 +1847,15 @@ static void asm_bswap(ASMState *as, IRIns *ir)
|
|
1472
1847
|
emit_dta(as, MIPSI_SRL, tmp, left, 24);
|
1473
1848
|
emit_dta(as, MIPSI_SLL, RID_TMP, left, 24);
|
1474
1849
|
}
|
1850
|
+
#else
|
1851
|
+
if (irt_is64(ir->t)) {
|
1852
|
+
emit_dst(as, MIPSI_DSHD, dest, 0, RID_TMP);
|
1853
|
+
emit_dst(as, MIPSI_DSBH, RID_TMP, 0, left);
|
1854
|
+
} else {
|
1855
|
+
emit_dta(as, MIPSI_ROTR, dest, RID_TMP, 16);
|
1856
|
+
emit_dst(as, MIPSI_WSBH, RID_TMP, 0, left);
|
1857
|
+
}
|
1858
|
+
#endif
|
1475
1859
|
}
|
1476
1860
|
|
1477
1861
|
static void asm_bitop(ASMState *as, IRIns *ir, MIPSIns mi, MIPSIns mik)
|
@@ -1479,7 +1863,7 @@ static void asm_bitop(ASMState *as, IRIns *ir, MIPSIns mi, MIPSIns mik)
|
|
1479
1863
|
Reg dest = ra_dest(as, ir, RSET_GPR);
|
1480
1864
|
Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR);
|
1481
1865
|
if (irref_isk(ir->op2)) {
|
1482
|
-
|
1866
|
+
intptr_t k = get_kval(IR(ir->op2));
|
1483
1867
|
if (checku16(k)) {
|
1484
1868
|
emit_tsi(as, mik, dest, left, k);
|
1485
1869
|
return;
|
@@ -1497,11 +1881,14 @@ static void asm_bitshift(ASMState *as, IRIns *ir, MIPSIns mi, MIPSIns mik)
|
|
1497
1881
|
{
|
1498
1882
|
Reg dest = ra_dest(as, ir, RSET_GPR);
|
1499
1883
|
if (irref_isk(ir->op2)) { /* Constant shifts. */
|
1500
|
-
uint32_t shift = (uint32_t)
|
1501
|
-
|
1884
|
+
uint32_t shift = (uint32_t)IR(ir->op2)->i;
|
1885
|
+
if (LJ_64 && irt_is64(ir->t)) mik |= (shift & 32) ? MIPSI_D32 : MIPSI_D;
|
1886
|
+
emit_dta(as, mik, dest, ra_hintalloc(as, ir->op1, dest, RSET_GPR),
|
1887
|
+
(shift & 31));
|
1502
1888
|
} else {
|
1503
1889
|
Reg right, left = ra_alloc2(as, ir, RSET_GPR);
|
1504
1890
|
right = (left >> 8); left &= 255;
|
1891
|
+
if (LJ_64 && irt_is64(ir->t)) mi |= MIPSI_DV;
|
1505
1892
|
emit_dst(as, mi, dest, right, left); /* Shift amount is in rs. */
|
1506
1893
|
}
|
1507
1894
|
}
|
@@ -1513,7 +1900,7 @@ static void asm_bitshift(ASMState *as, IRIns *ir, MIPSIns mi, MIPSIns mik)
|
|
1513
1900
|
|
1514
1901
|
static void asm_bror(ASMState *as, IRIns *ir)
|
1515
1902
|
{
|
1516
|
-
if ((as->flags &
|
1903
|
+
if (LJ_64 || (as->flags & JIT_F_MIPSXXR2)) {
|
1517
1904
|
asm_bitshift(as, ir, MIPSI_ROTRV, MIPSI_ROTR);
|
1518
1905
|
} else {
|
1519
1906
|
Reg dest = ra_dest(as, ir, RSET_GPR);
|
@@ -1532,7 +1919,7 @@ static void asm_bror(ASMState *as, IRIns *ir)
|
|
1532
1919
|
}
|
1533
1920
|
}
|
1534
1921
|
|
1535
|
-
#if LJ_SOFTFP
|
1922
|
+
#if LJ_32 && LJ_SOFTFP
|
1536
1923
|
static void asm_sfpmin_max(ASMState *as, IRIns *ir)
|
1537
1924
|
{
|
1538
1925
|
CCallInfo ci = lj_ir_callinfo[(IROp)ir->o == IR_MIN ? IRCALL_lj_vm_sfmin : IRCALL_lj_vm_sfmax];
|
@@ -1581,7 +1968,7 @@ static void asm_min_max(ASMState *as, IRIns *ir, int ismax)
|
|
1581
1968
|
|
1582
1969
|
/* -- Comparisons --------------------------------------------------------- */
|
1583
1970
|
|
1584
|
-
#if LJ_SOFTFP
|
1971
|
+
#if LJ_32 && LJ_SOFTFP
|
1585
1972
|
/* SFP comparisons. */
|
1586
1973
|
static void asm_sfpcomp(ASMState *as, IRIns *ir)
|
1587
1974
|
{
|
@@ -1654,13 +2041,13 @@ static void asm_comp(ASMState *as, IRIns *ir)
|
|
1654
2041
|
} else {
|
1655
2042
|
Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR);
|
1656
2043
|
if (op == IR_ABC) op = IR_UGT;
|
1657
|
-
if ((op&4) == 0 && irref_isk(ir->op2) && IR(ir->op2)
|
2044
|
+
if ((op&4) == 0 && irref_isk(ir->op2) && get_kval(IR(ir->op2)) == 0) {
|
1658
2045
|
MIPSIns mi = (op&2) ? ((op&1) ? MIPSI_BLEZ : MIPSI_BGTZ) :
|
1659
2046
|
((op&1) ? MIPSI_BLTZ : MIPSI_BGEZ);
|
1660
2047
|
asm_guard(as, mi, left, 0);
|
1661
2048
|
} else {
|
1662
2049
|
if (irref_isk(ir->op2)) {
|
1663
|
-
|
2050
|
+
intptr_t k = get_kval(IR(ir->op2));
|
1664
2051
|
if ((op&2)) k++;
|
1665
2052
|
if (checki16(k)) {
|
1666
2053
|
asm_guard(as, (op&1) ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO);
|
@@ -1679,7 +2066,8 @@ static void asm_comp(ASMState *as, IRIns *ir)
|
|
1679
2066
|
|
1680
2067
|
static void asm_equal(ASMState *as, IRIns *ir)
|
1681
2068
|
{
|
1682
|
-
Reg right, left = ra_alloc2(as, ir, (!LJ_SOFTFP && irt_isnum(ir->t)) ?
|
2069
|
+
Reg right, left = ra_alloc2(as, ir, (!LJ_SOFTFP && irt_isnum(ir->t)) ?
|
2070
|
+
RSET_FPR : RSET_GPR);
|
1683
2071
|
right = (left >> 8); left &= 255;
|
1684
2072
|
if (!LJ_SOFTFP && irt_isnum(ir->t)) {
|
1685
2073
|
asm_guard(as, (ir->o & 1) ? MIPSI_BC1T : MIPSI_BC1F, 0, 0);
|
@@ -1689,7 +2077,7 @@ static void asm_equal(ASMState *as, IRIns *ir)
|
|
1689
2077
|
}
|
1690
2078
|
}
|
1691
2079
|
|
1692
|
-
#if LJ_HASFFI
|
2080
|
+
#if LJ_32 && LJ_HASFFI
|
1693
2081
|
/* 64 bit integer comparisons. */
|
1694
2082
|
static void asm_comp64(ASMState *as, IRIns *ir)
|
1695
2083
|
{
|
@@ -1731,7 +2119,7 @@ static void asm_comp64eq(ASMState *as, IRIns *ir)
|
|
1731
2119
|
/* Hiword op of a split 64 bit op. Previous op must be the loword op. */
|
1732
2120
|
static void asm_hiop(ASMState *as, IRIns *ir)
|
1733
2121
|
{
|
1734
|
-
#if LJ_HASFFI || LJ_SOFTFP
|
2122
|
+
#if LJ_32 && (LJ_HASFFI || LJ_SOFTFP)
|
1735
2123
|
/* HIOP is marked as a store because it needs its own DCE logic. */
|
1736
2124
|
int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */
|
1737
2125
|
if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1;
|
@@ -1835,36 +2223,42 @@ static void asm_stack_check(ASMState *as, BCReg topslot,
|
|
1835
2223
|
Reg tmp, pbase = irp ? (ra_hasreg(irp->r) ? irp->r : RID_TMP) : RID_BASE;
|
1836
2224
|
ExitNo oldsnap = as->snapno;
|
1837
2225
|
rset_clear(allow, pbase);
|
2226
|
+
#if LJ_32
|
1838
2227
|
tmp = allow ? rset_pickbot(allow) :
|
1839
2228
|
(pbase == RID_RETHI ? RID_RETLO : RID_RETHI);
|
2229
|
+
#else
|
2230
|
+
tmp = allow ? rset_pickbot(allow) : RID_RET;
|
2231
|
+
#endif
|
1840
2232
|
as->snapno = exitno;
|
1841
2233
|
asm_guard(as, MIPSI_BNE, RID_TMP, RID_ZERO);
|
1842
2234
|
as->snapno = oldsnap;
|
1843
2235
|
if (allow == RSET_EMPTY) /* Restore temp. register. */
|
1844
|
-
emit_tsi(as,
|
2236
|
+
emit_tsi(as, MIPSI_AL, tmp, RID_SP, 0);
|
1845
2237
|
else
|
1846
2238
|
ra_modified(as, tmp);
|
1847
2239
|
emit_tsi(as, MIPSI_SLTIU, RID_TMP, RID_TMP, (int32_t)(8*topslot));
|
1848
|
-
emit_dst(as,
|
1849
|
-
emit_tsi(as,
|
2240
|
+
emit_dst(as, MIPSI_ASUBU, RID_TMP, tmp, pbase);
|
2241
|
+
emit_tsi(as, MIPSI_AL, tmp, tmp, offsetof(lua_State, maxstack));
|
1850
2242
|
if (pbase == RID_TMP)
|
1851
2243
|
emit_getgl(as, RID_TMP, jit_base);
|
1852
2244
|
emit_getgl(as, tmp, cur_L);
|
1853
2245
|
if (allow == RSET_EMPTY) /* Spill temp. register. */
|
1854
|
-
emit_tsi(as,
|
2246
|
+
emit_tsi(as, MIPSI_AS, tmp, RID_SP, 0);
|
1855
2247
|
}
|
1856
2248
|
|
1857
2249
|
/* Restore Lua stack from on-trace state. */
|
1858
2250
|
static void asm_stack_restore(ASMState *as, SnapShot *snap)
|
1859
2251
|
{
|
1860
2252
|
SnapEntry *map = &as->T->snapmap[snap->mapofs];
|
1861
|
-
|
2253
|
+
#if LJ_32 || defined(LUA_USE_ASSERT)
|
2254
|
+
SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1-LJ_FR2];
|
2255
|
+
#endif
|
1862
2256
|
MSize n, nent = snap->nent;
|
1863
2257
|
/* Store the value of all modified slots to the Lua stack. */
|
1864
2258
|
for (n = 0; n < nent; n++) {
|
1865
2259
|
SnapEntry sn = map[n];
|
1866
2260
|
BCReg s = snap_slot(sn);
|
1867
|
-
int32_t ofs = 8*((int32_t)s-1);
|
2261
|
+
int32_t ofs = 8*((int32_t)s-1-LJ_FR2);
|
1868
2262
|
IRRef ref = snap_ref(sn);
|
1869
2263
|
IRIns *ir = IR(ref);
|
1870
2264
|
if ((sn & SNAP_NORESTORE))
|
@@ -1884,8 +2278,9 @@ static void asm_stack_restore(ASMState *as, SnapShot *snap)
|
|
1884
2278
|
emit_hsi(as, MIPSI_SDC1, src, RID_BASE, ofs);
|
1885
2279
|
#endif
|
1886
2280
|
} else {
|
1887
|
-
|
2281
|
+
#if LJ_32
|
1888
2282
|
RegSet allow = rset_exclude(RSET_GPR, RID_BASE);
|
2283
|
+
Reg type;
|
1889
2284
|
lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || irt_isinteger(ir->t));
|
1890
2285
|
if (!irt_ispri(ir->t)) {
|
1891
2286
|
Reg src = ra_alloc1(as, ref, allow);
|
@@ -1903,6 +2298,9 @@ static void asm_stack_restore(ASMState *as, SnapShot *snap)
|
|
1903
2298
|
type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow);
|
1904
2299
|
}
|
1905
2300
|
emit_tsi(as, MIPSI_SW, type, RID_BASE, ofs+(LJ_BE?0:4));
|
2301
|
+
#else
|
2302
|
+
asm_tvstore64(as, RID_BASE, ofs, ref);
|
2303
|
+
#endif
|
1906
2304
|
}
|
1907
2305
|
checkmclim(as);
|
1908
2306
|
}
|
@@ -1926,7 +2324,7 @@ static void asm_gc_check(ASMState *as)
|
|
1926
2324
|
args[0] = ASMREF_TMP1; /* global_State *g */
|
1927
2325
|
args[1] = ASMREF_TMP2; /* MSize steps */
|
1928
2326
|
asm_gencall(as, ci, args);
|
1929
|
-
emit_tsi(as,
|
2327
|
+
emit_tsi(as, MIPSI_AADDIU, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768);
|
1930
2328
|
tmp = ra_releasetmp(as, ASMREF_TMP2);
|
1931
2329
|
emit_loadi(as, tmp, as->gcsteps);
|
1932
2330
|
/* Jump around GC step if GC total < GC threshold. */
|
@@ -2001,7 +2399,7 @@ static void asm_tail_fixup(ASMState *as, TraceNo lnk)
|
|
2001
2399
|
MCode *target = lnk ? traceref(as->J,lnk)->mcode : (MCode *)lj_vm_exit_interp;
|
2002
2400
|
int32_t spadj = as->T->spadjust;
|
2003
2401
|
MCode *p = as->mctop-1;
|
2004
|
-
*p = spadj ? (
|
2402
|
+
*p = spadj ? (MIPSI_AADDIU|MIPSF_T(RID_SP)|MIPSF_S(RID_SP)|spadj) : MIPSI_NOP;
|
2005
2403
|
p[-1] = MIPSI_J|(((uintptr_t)target>>2)&0x03ffffffu);
|
2006
2404
|
}
|
2007
2405
|
|
@@ -2019,9 +2417,14 @@ static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci)
|
|
2019
2417
|
{
|
2020
2418
|
IRRef args[CCI_NARGS_MAX*2];
|
2021
2419
|
uint32_t i, nargs = CCI_XNARGS(ci);
|
2420
|
+
#if LJ_32
|
2022
2421
|
int nslots = 4, ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR;
|
2422
|
+
#else
|
2423
|
+
int nslots = 0, ngpr = REGARG_NUMGPR;
|
2424
|
+
#endif
|
2023
2425
|
asm_collectargs(as, ir, ci, args);
|
2024
2426
|
for (i = 0; i < nargs; i++) {
|
2427
|
+
#if LJ_32
|
2025
2428
|
if (!LJ_SOFTFP && args[i] && irt_isfp(IR(args[i])->t) &&
|
2026
2429
|
nfpr > 0 && !(ci->flags & CCI_VARARG)) {
|
2027
2430
|
nfpr--;
|
@@ -2034,6 +2437,9 @@ static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci)
|
|
2034
2437
|
nfpr = 0;
|
2035
2438
|
if (ngpr > 0) ngpr--; else nslots++;
|
2036
2439
|
}
|
2440
|
+
#else
|
2441
|
+
if (ngpr > 0) ngpr--; else nslots += 2;
|
2442
|
+
#endif
|
2037
2443
|
}
|
2038
2444
|
if (nslots > as->evenspill) /* Leave room for args in stack slots. */
|
2039
2445
|
as->evenspill = nslots;
|