immunio 1.1.2 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/lib/immunio/version.rb +1 -1
  3. data/lua-hooks/Makefile +56 -109
  4. data/lua-hooks/ext/all.c +3 -14
  5. data/lua-hooks/ext/libinjection/module.mk +5 -0
  6. data/lua-hooks/ext/lpeg/module.mk +6 -0
  7. data/lua-hooks/ext/lua-cmsgpack/module.mk +2 -0
  8. data/lua-hooks/ext/lua-snapshot/module.mk +2 -0
  9. data/lua-hooks/ext/luajit/COPYRIGHT +1 -1
  10. data/lua-hooks/ext/luajit/Makefile +2 -2
  11. data/lua-hooks/ext/luajit/README +2 -2
  12. data/lua-hooks/ext/luajit/doc/bluequad-print.css +1 -1
  13. data/lua-hooks/ext/luajit/doc/bluequad.css +1 -1
  14. data/lua-hooks/ext/luajit/doc/changes.html +15 -2
  15. data/lua-hooks/ext/luajit/doc/contact.html +3 -3
  16. data/lua-hooks/ext/luajit/doc/ext_c_api.html +2 -2
  17. data/lua-hooks/ext/luajit/doc/ext_ffi.html +2 -2
  18. data/lua-hooks/ext/luajit/doc/ext_ffi_api.html +2 -2
  19. data/lua-hooks/ext/luajit/doc/ext_ffi_semantics.html +4 -2
  20. data/lua-hooks/ext/luajit/doc/ext_ffi_tutorial.html +2 -2
  21. data/lua-hooks/ext/luajit/doc/ext_jit.html +2 -2
  22. data/lua-hooks/ext/luajit/doc/ext_profiler.html +2 -2
  23. data/lua-hooks/ext/luajit/doc/extensions.html +9 -2
  24. data/lua-hooks/ext/luajit/doc/faq.html +2 -2
  25. data/lua-hooks/ext/luajit/doc/install.html +22 -18
  26. data/lua-hooks/ext/luajit/doc/luajit.html +3 -3
  27. data/lua-hooks/ext/luajit/doc/running.html +2 -2
  28. data/lua-hooks/ext/luajit/doc/status.html +2 -2
  29. data/lua-hooks/ext/luajit/dynasm/dasm_arm.h +1 -1
  30. data/lua-hooks/ext/luajit/dynasm/dasm_arm.lua +4 -4
  31. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.h +1 -1
  32. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.lua +4 -4
  33. data/lua-hooks/ext/luajit/dynasm/dasm_mips.h +1 -1
  34. data/lua-hooks/ext/luajit/dynasm/dasm_mips.lua +4 -4
  35. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.h +1 -1
  36. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.lua +4 -4
  37. data/lua-hooks/ext/luajit/dynasm/dasm_proto.h +3 -3
  38. data/lua-hooks/ext/luajit/dynasm/dasm_x64.lua +1 -1
  39. data/lua-hooks/ext/luajit/dynasm/dasm_x86.h +34 -7
  40. data/lua-hooks/ext/luajit/dynasm/dasm_x86.lua +427 -102
  41. data/lua-hooks/ext/luajit/dynasm/dynasm.lua +5 -5
  42. data/lua-hooks/ext/luajit/etc/luajit.1 +1 -1
  43. data/lua-hooks/ext/luajit/etc/luajit.pc +1 -1
  44. data/lua-hooks/ext/luajit/src/Makefile +36 -21
  45. data/lua-hooks/ext/luajit/src/Makefile.dep +3 -1
  46. data/lua-hooks/ext/luajit/src/host/buildvm.c +1 -1
  47. data/lua-hooks/ext/luajit/src/host/buildvm.h +1 -1
  48. data/lua-hooks/ext/luajit/src/host/buildvm_asm.c +10 -1
  49. data/lua-hooks/ext/luajit/src/host/buildvm_fold.c +1 -1
  50. data/lua-hooks/ext/luajit/src/host/buildvm_lib.c +1 -1
  51. data/lua-hooks/ext/luajit/src/host/buildvm_peobj.c +1 -1
  52. data/lua-hooks/ext/luajit/src/host/genlibbc.lua +1 -1
  53. data/lua-hooks/ext/luajit/src/host/genminilua.lua +1 -1
  54. data/lua-hooks/ext/luajit/src/jit/bc.lua +1 -1
  55. data/lua-hooks/ext/luajit/src/jit/bcsave.lua +2 -2
  56. data/lua-hooks/ext/luajit/src/jit/dis_arm.lua +1 -1
  57. data/lua-hooks/ext/luajit/src/jit/dis_mips.lua +1 -1
  58. data/lua-hooks/ext/luajit/src/jit/dis_mipsel.lua +1 -1
  59. data/lua-hooks/ext/luajit/src/jit/dis_ppc.lua +1 -1
  60. data/lua-hooks/ext/luajit/src/jit/dis_x64.lua +1 -1
  61. data/lua-hooks/ext/luajit/src/jit/dis_x86.lua +163 -73
  62. data/lua-hooks/ext/luajit/src/jit/dump.lua +2 -1
  63. data/lua-hooks/ext/luajit/src/jit/p.lua +1 -1
  64. data/lua-hooks/ext/luajit/src/jit/v.lua +1 -1
  65. data/lua-hooks/ext/luajit/src/jit/zone.lua +1 -1
  66. data/lua-hooks/ext/luajit/src/lib_aux.c +1 -1
  67. data/lua-hooks/ext/luajit/src/lib_base.c +4 -5
  68. data/lua-hooks/ext/luajit/src/lib_bit.c +1 -1
  69. data/lua-hooks/ext/luajit/src/lib_debug.c +1 -1
  70. data/lua-hooks/ext/luajit/src/lib_ffi.c +2 -5
  71. data/lua-hooks/ext/luajit/src/lib_init.c +1 -1
  72. data/lua-hooks/ext/luajit/src/lib_io.c +2 -3
  73. data/lua-hooks/ext/luajit/src/lib_jit.c +1 -1
  74. data/lua-hooks/ext/luajit/src/lib_math.c +1 -1
  75. data/lua-hooks/ext/luajit/src/lib_os.c +2 -2
  76. data/lua-hooks/ext/luajit/src/lib_package.c +1 -1
  77. data/lua-hooks/ext/luajit/src/lib_string.c +1 -1
  78. data/lua-hooks/ext/luajit/src/lib_table.c +1 -1
  79. data/lua-hooks/ext/luajit/src/lj.supp +15 -0
  80. data/lua-hooks/ext/luajit/src/lj_alloc.c +1 -1
  81. data/lua-hooks/ext/luajit/src/lj_api.c +4 -1
  82. data/lua-hooks/ext/luajit/src/lj_arch.h +33 -7
  83. data/lua-hooks/ext/luajit/src/lj_asm.c +12 -5
  84. data/lua-hooks/ext/luajit/src/lj_asm.h +1 -1
  85. data/lua-hooks/ext/luajit/src/lj_asm_arm.h +3 -13
  86. data/lua-hooks/ext/luajit/src/lj_asm_mips.h +337 -71
  87. data/lua-hooks/ext/luajit/src/lj_asm_ppc.h +2 -2
  88. data/lua-hooks/ext/luajit/src/lj_asm_x86.h +2 -2
  89. data/lua-hooks/ext/luajit/src/lj_bc.c +1 -1
  90. data/lua-hooks/ext/luajit/src/lj_bc.h +1 -1
  91. data/lua-hooks/ext/luajit/src/lj_bcdump.h +1 -1
  92. data/lua-hooks/ext/luajit/src/lj_bcread.c +1 -1
  93. data/lua-hooks/ext/luajit/src/lj_bcwrite.c +1 -1
  94. data/lua-hooks/ext/luajit/src/lj_buf.c +2 -4
  95. data/lua-hooks/ext/luajit/src/lj_buf.h +1 -3
  96. data/lua-hooks/ext/luajit/src/lj_carith.c +1 -1
  97. data/lua-hooks/ext/luajit/src/lj_carith.h +1 -1
  98. data/lua-hooks/ext/luajit/src/lj_ccall.c +37 -14
  99. data/lua-hooks/ext/luajit/src/lj_ccall.h +3 -3
  100. data/lua-hooks/ext/luajit/src/lj_ccallback.c +16 -7
  101. data/lua-hooks/ext/luajit/src/lj_ccallback.h +1 -1
  102. data/lua-hooks/ext/luajit/src/lj_cconv.c +1 -1
  103. data/lua-hooks/ext/luajit/src/lj_cconv.h +1 -1
  104. data/lua-hooks/ext/luajit/src/lj_cdata.c +10 -1
  105. data/lua-hooks/ext/luajit/src/lj_cdata.h +3 -1
  106. data/lua-hooks/ext/luajit/src/lj_clib.c +1 -1
  107. data/lua-hooks/ext/luajit/src/lj_clib.h +1 -1
  108. data/lua-hooks/ext/luajit/src/lj_cparse.c +27 -6
  109. data/lua-hooks/ext/luajit/src/lj_cparse.h +1 -1
  110. data/lua-hooks/ext/luajit/src/lj_crecord.c +1 -1
  111. data/lua-hooks/ext/luajit/src/lj_crecord.h +1 -1
  112. data/lua-hooks/ext/luajit/src/lj_ctype.c +10 -8
  113. data/lua-hooks/ext/luajit/src/lj_ctype.h +1 -1
  114. data/lua-hooks/ext/luajit/src/lj_debug.c +1 -1
  115. data/lua-hooks/ext/luajit/src/lj_debug.h +1 -1
  116. data/lua-hooks/ext/luajit/src/lj_def.h +1 -1
  117. data/lua-hooks/ext/luajit/src/lj_dispatch.c +1 -1
  118. data/lua-hooks/ext/luajit/src/lj_dispatch.h +21 -4
  119. data/lua-hooks/ext/luajit/src/lj_emit_arm.h +1 -1
  120. data/lua-hooks/ext/luajit/src/lj_emit_mips.h +7 -5
  121. data/lua-hooks/ext/luajit/src/lj_emit_ppc.h +1 -1
  122. data/lua-hooks/ext/luajit/src/lj_emit_x86.h +1 -1
  123. data/lua-hooks/ext/luajit/src/lj_err.c +69 -31
  124. data/lua-hooks/ext/luajit/src/lj_err.h +1 -1
  125. data/lua-hooks/ext/luajit/src/lj_errmsg.h +1 -1
  126. data/lua-hooks/ext/luajit/src/lj_ff.h +1 -1
  127. data/lua-hooks/ext/luajit/src/lj_ffrecord.c +10 -40
  128. data/lua-hooks/ext/luajit/src/lj_ffrecord.h +1 -1
  129. data/lua-hooks/ext/luajit/src/lj_frame.h +12 -1
  130. data/lua-hooks/ext/luajit/src/lj_func.c +1 -1
  131. data/lua-hooks/ext/luajit/src/lj_func.h +1 -1
  132. data/lua-hooks/ext/luajit/src/lj_gc.c +2 -2
  133. data/lua-hooks/ext/luajit/src/lj_gc.h +1 -1
  134. data/lua-hooks/ext/luajit/src/lj_gdbjit.c +1 -1
  135. data/lua-hooks/ext/luajit/src/lj_gdbjit.h +1 -1
  136. data/lua-hooks/ext/luajit/src/lj_ir.c +31 -15
  137. data/lua-hooks/ext/luajit/src/lj_ir.h +1 -1
  138. data/lua-hooks/ext/luajit/src/lj_ircall.h +29 -1
  139. data/lua-hooks/ext/luajit/src/lj_iropt.h +2 -1
  140. data/lua-hooks/ext/luajit/src/lj_jit.h +2 -1
  141. data/lua-hooks/ext/luajit/src/lj_lex.c +28 -1
  142. data/lua-hooks/ext/luajit/src/lj_lex.h +1 -1
  143. data/lua-hooks/ext/luajit/src/lj_lib.c +1 -1
  144. data/lua-hooks/ext/luajit/src/lj_lib.h +1 -1
  145. data/lua-hooks/ext/luajit/src/lj_load.c +1 -1
  146. data/lua-hooks/ext/luajit/src/lj_mcode.c +1 -1
  147. data/lua-hooks/ext/luajit/src/lj_mcode.h +1 -1
  148. data/lua-hooks/ext/luajit/src/lj_meta.c +8 -8
  149. data/lua-hooks/ext/luajit/src/lj_meta.h +1 -1
  150. data/lua-hooks/ext/luajit/src/lj_obj.c +1 -1
  151. data/lua-hooks/ext/luajit/src/lj_obj.h +1 -1
  152. data/lua-hooks/ext/luajit/src/lj_opt_dce.c +1 -1
  153. data/lua-hooks/ext/luajit/src/lj_opt_fold.c +1 -1
  154. data/lua-hooks/ext/luajit/src/lj_opt_loop.c +1 -1
  155. data/lua-hooks/ext/luajit/src/lj_opt_mem.c +1 -1
  156. data/lua-hooks/ext/luajit/src/lj_opt_narrow.c +1 -1
  157. data/lua-hooks/ext/luajit/src/lj_opt_sink.c +1 -1
  158. data/lua-hooks/ext/luajit/src/lj_opt_split.c +10 -5
  159. data/lua-hooks/ext/luajit/src/lj_parse.c +1 -1
  160. data/lua-hooks/ext/luajit/src/lj_parse.h +1 -1
  161. data/lua-hooks/ext/luajit/src/lj_profile.c +1 -1
  162. data/lua-hooks/ext/luajit/src/lj_profile.h +1 -1
  163. data/lua-hooks/ext/luajit/src/lj_record.c +13 -5
  164. data/lua-hooks/ext/luajit/src/lj_record.h +1 -1
  165. data/lua-hooks/ext/luajit/src/lj_snap.c +20 -23
  166. data/lua-hooks/ext/luajit/src/lj_snap.h +1 -1
  167. data/lua-hooks/ext/luajit/src/lj_state.c +1 -1
  168. data/lua-hooks/ext/luajit/src/lj_state.h +1 -1
  169. data/lua-hooks/ext/luajit/src/lj_str.c +1 -1
  170. data/lua-hooks/ext/luajit/src/lj_str.h +1 -1
  171. data/lua-hooks/ext/luajit/src/lj_strfmt.c +12 -98
  172. data/lua-hooks/ext/luajit/src/lj_strfmt.h +4 -4
  173. data/lua-hooks/ext/luajit/src/lj_strfmt_num.c +591 -0
  174. data/lua-hooks/ext/luajit/src/lj_strscan.c +1 -1
  175. data/lua-hooks/ext/luajit/src/lj_strscan.h +1 -1
  176. data/lua-hooks/ext/luajit/src/lj_tab.c +1 -1
  177. data/lua-hooks/ext/luajit/src/lj_tab.h +1 -1
  178. data/lua-hooks/ext/luajit/src/lj_target.h +1 -1
  179. data/lua-hooks/ext/luajit/src/lj_target_arm.h +1 -1
  180. data/lua-hooks/ext/luajit/src/lj_target_arm64.h +1 -1
  181. data/lua-hooks/ext/luajit/src/lj_target_mips.h +30 -2
  182. data/lua-hooks/ext/luajit/src/lj_target_ppc.h +1 -1
  183. data/lua-hooks/ext/luajit/src/lj_target_x86.h +1 -1
  184. data/lua-hooks/ext/luajit/src/lj_trace.c +7 -2
  185. data/lua-hooks/ext/luajit/src/lj_trace.h +1 -1
  186. data/lua-hooks/ext/luajit/src/lj_traceerr.h +1 -3
  187. data/lua-hooks/ext/luajit/src/lj_udata.c +1 -1
  188. data/lua-hooks/ext/luajit/src/lj_udata.h +1 -1
  189. data/lua-hooks/ext/luajit/src/lj_vm.h +5 -3
  190. data/lua-hooks/ext/luajit/src/lj_vmevent.c +1 -1
  191. data/lua-hooks/ext/luajit/src/lj_vmevent.h +1 -1
  192. data/lua-hooks/ext/luajit/src/lj_vmmath.c +15 -15
  193. data/lua-hooks/ext/luajit/src/ljamalg.c +2 -1
  194. data/lua-hooks/ext/luajit/src/lua.h +1 -0
  195. data/lua-hooks/ext/luajit/src/luaconf.h +2 -2
  196. data/lua-hooks/ext/luajit/src/luajit.c +1 -1
  197. data/lua-hooks/ext/luajit/src/luajit.h +4 -4
  198. data/lua-hooks/ext/luajit/src/lualib.h +1 -1
  199. data/lua-hooks/ext/luajit/src/msvcbuild.bat +1 -1
  200. data/lua-hooks/ext/luajit/src/ps4build.bat +26 -6
  201. data/lua-hooks/ext/luajit/src/vm_arm.dasc +17 -9
  202. data/lua-hooks/ext/luajit/src/vm_arm64.dasc +1 -1
  203. data/lua-hooks/ext/luajit/src/vm_mips.dasc +1562 -656
  204. data/lua-hooks/ext/luajit/src/vm_ppc.dasc +3 -7
  205. data/lua-hooks/ext/luajit/src/vm_x64.dasc +10 -2
  206. data/lua-hooks/ext/luajit/src/vm_x86.dasc +5 -8
  207. data/lua-hooks/ext/luautf8/module.mk +2 -0
  208. data/lua-hooks/ext/module.mk +15 -0
  209. data/lua-hooks/ext/modules.h +17 -0
  210. data/lua-hooks/ext/perf/luacpu.c +1 -1
  211. data/lua-hooks/ext/perf/lualoadavg.c +1 -1
  212. data/lua-hooks/ext/perf/luameminfo.c +1 -1
  213. data/lua-hooks/ext/perf/luaoslib.c +124 -2
  214. data/lua-hooks/ext/perf/module.mk +5 -0
  215. data/lua-hooks/ext/sha1/luasha1.c +4 -2
  216. data/lua-hooks/ext/sha1/module.mk +5 -0
  217. data/lua-hooks/ext/sha2/luasha256.c +4 -2
  218. data/lua-hooks/ext/sha2/module.mk +5 -0
  219. data/lua-hooks/ext/sysutils/lua_utils.c +56 -0
  220. data/lua-hooks/ext/sysutils/module.mk +2 -0
  221. data/lua-hooks/lib/boot.lua +2 -1
  222. data/lua-hooks/lib/hooks/module.mk +31 -0
  223. data/lua-hooks/lib/hooks/xss/module.mk +4 -0
  224. data/lua-hooks/lib/lexers/module.mk +10 -0
  225. data/lua-hooks/lib/module.mk +38 -0
  226. data/lua-hooks/lib/schema/module.mk +3 -0
  227. data/lua-hooks/options.mk +59 -0
  228. metadata +21 -2
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** MIPS IR assembler (SSA IR -> machine code).
3
- ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
3
+ ** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
4
4
  */
5
5
 
6
6
  /* -- Register allocator extensions --------------------------------------- */
@@ -228,27 +228,39 @@ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args)
228
228
  {
229
229
  uint32_t n, nargs = CCI_XNARGS(ci);
230
230
  int32_t ofs = 16;
231
+ #if LJ_SOFTFP
232
+ Reg gpr = REGARG_FIRSTGPR;
233
+ #else
231
234
  Reg gpr, fpr = REGARG_FIRSTFPR;
235
+ #endif
232
236
  if ((void *)ci->func)
233
- emit_call(as, (void *)ci->func);
237
+ emit_call(as, (void *)ci->func, 1);
238
+ #if !LJ_SOFTFP
234
239
  for (gpr = REGARG_FIRSTGPR; gpr <= REGARG_LASTGPR; gpr++)
235
240
  as->cost[gpr] = REGCOST(~0u, ASMREF_L);
236
241
  gpr = REGARG_FIRSTGPR;
242
+ #endif
237
243
  for (n = 0; n < nargs; n++) { /* Setup args. */
238
244
  IRRef ref = args[n];
239
245
  if (ref) {
240
246
  IRIns *ir = IR(ref);
247
+ #if !LJ_SOFTFP
241
248
  if (irt_isfp(ir->t) && fpr <= REGARG_LASTFPR &&
242
249
  !(ci->flags & CCI_VARARG)) {
243
250
  lua_assert(rset_test(as->freeset, fpr)); /* Already evicted. */
244
251
  ra_leftov(as, fpr, ref);
245
252
  fpr += 2;
246
253
  gpr += irt_isnum(ir->t) ? 2 : 1;
247
- } else {
254
+ } else
255
+ #endif
256
+ {
257
+ #if !LJ_SOFTFP
248
258
  fpr = REGARG_LASTFPR+1;
259
+ #endif
249
260
  if (irt_isnum(ir->t)) gpr = (gpr+1) & ~1;
250
261
  if (gpr <= REGARG_LASTGPR) {
251
262
  lua_assert(rset_test(as->freeset, gpr)); /* Already evicted. */
263
+ #if !LJ_SOFTFP
252
264
  if (irt_isfp(ir->t)) {
253
265
  RegSet of = as->freeset;
254
266
  Reg r;
@@ -265,19 +277,23 @@ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args)
265
277
  emit_tg(as, MIPSI_MFC1, gpr, r);
266
278
  gpr++;
267
279
  }
268
- } else {
280
+ } else
281
+ #endif
282
+ {
269
283
  ra_leftov(as, gpr, ref);
270
284
  gpr++;
271
285
  }
272
286
  } else {
273
- Reg r = ra_alloc1z(as, ref, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR);
287
+ Reg r = ra_alloc1z(as, ref, !LJ_SOFTFP && irt_isfp(ir->t) ? RSET_FPR : RSET_GPR);
274
288
  if (irt_isnum(ir->t)) ofs = (ofs + 4) & ~4;
275
289
  emit_spstore(as, ir, r, ofs);
276
290
  ofs += irt_isnum(ir->t) ? 8 : 4;
277
291
  }
278
292
  }
279
293
  } else {
294
+ #if !LJ_SOFTFP
280
295
  fpr = REGARG_LASTFPR+1;
296
+ #endif
281
297
  if (gpr <= REGARG_LASTGPR)
282
298
  gpr++;
283
299
  else
@@ -291,9 +307,11 @@ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args)
291
307
  static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci)
292
308
  {
293
309
  RegSet drop = RSET_SCRATCH;
294
- int hiop = ((ir+1)->o == IR_HIOP);
310
+ int hiop = ((ir+1)->o == IR_HIOP && !irt_isnil((ir+1)->t));
311
+ #if !LJ_SOFTFP
295
312
  if ((ci->flags & CCI_NOFPRCLOBBER))
296
313
  drop &= ~RSET_FPR;
314
+ #endif
297
315
  if (ra_hasreg(ir->r))
298
316
  rset_clear(drop, ir->r); /* Dest reg handled below. */
299
317
  if (hiop && ra_hasreg((ir+1)->r))
@@ -301,7 +319,7 @@ static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci)
301
319
  ra_evictset(as, drop); /* Evictions must be performed first. */
302
320
  if (ra_used(ir)) {
303
321
  lua_assert(!irt_ispri(ir->t));
304
- if (irt_isfp(ir->t)) {
322
+ if (!LJ_SOFTFP && irt_isfp(ir->t)) {
305
323
  if ((ci->flags & CCI_CASTU64)) {
306
324
  int32_t ofs = sps_scale(ir->s);
307
325
  Reg dest = ir->r;
@@ -353,6 +371,7 @@ static void asm_callx(ASMState *as, IRIns *ir)
353
371
  asm_gencall(as, &ci, args);
354
372
  }
355
373
 
374
+ #if !LJ_SOFTFP
356
375
  static void asm_callround(ASMState *as, IRIns *ir, IRCallID id)
357
376
  {
358
377
  /* The modified regs must match with the *.dasc implementation. */
@@ -361,9 +380,10 @@ static void asm_callround(ASMState *as, IRIns *ir, IRCallID id)
361
380
  if (ra_hasreg(ir->r)) rset_clear(drop, ir->r);
362
381
  ra_evictset(as, drop);
363
382
  ra_destreg(as, ir, RID_FPRET);
364
- emit_call(as, (void *)lj_ir_callinfo[id].func);
383
+ emit_call(as, (void *)lj_ir_callinfo[id].func, 0);
365
384
  ra_leftov(as, REGARG_FIRSTFPR, ir->op1);
366
385
  }
386
+ #endif
367
387
 
368
388
  /* -- Returns ------------------------------------------------------------- */
369
389
 
@@ -385,6 +405,7 @@ static void asm_retf(ASMState *as, IRIns *ir)
385
405
 
386
406
  /* -- Type conversions ---------------------------------------------------- */
387
407
 
408
+ #if !LJ_SOFTFP
388
409
  static void asm_tointg(ASMState *as, IRIns *ir, Reg left)
389
410
  {
390
411
  Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left));
@@ -406,15 +427,23 @@ static void asm_tobit(ASMState *as, IRIns *ir)
406
427
  emit_tg(as, MIPSI_MFC1, dest, tmp);
407
428
  emit_fgh(as, MIPSI_ADD_D, tmp, left, right);
408
429
  }
430
+ #endif
409
431
 
410
432
  static void asm_conv(ASMState *as, IRIns *ir)
411
433
  {
412
434
  IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK);
435
+ #if !LJ_SOFTFP
413
436
  int stfp = (st == IRT_NUM || st == IRT_FLOAT);
437
+ #endif
414
438
  IRRef lref = ir->op1;
415
- lua_assert(irt_type(ir->t) != st);
416
439
  lua_assert(!(irt_isint64(ir->t) ||
417
440
  (st == IRT_I64 || st == IRT_U64))); /* Handled by SPLIT. */
441
+ #if LJ_SOFTFP
442
+ /* FP conversions are handled by SPLIT. */
443
+ lua_assert(!irt_isfp(ir->t) && !(st == IRT_NUM || st == IRT_FLOAT));
444
+ /* Can't check for same types: SPLIT uses CONV int.int + BXOR for sfp NEG. */
445
+ #else
446
+ lua_assert(irt_type(ir->t) != st);
418
447
  if (irt_isfp(ir->t)) {
419
448
  Reg dest = ra_dest(as, ir, RSET_FPR);
420
449
  if (stfp) { /* FP to FP conversion. */
@@ -477,7 +506,9 @@ static void asm_conv(ASMState *as, IRIns *ir)
477
506
  tmp, left);
478
507
  }
479
508
  }
480
- } else {
509
+ } else
510
+ #endif
511
+ {
481
512
  Reg dest = ra_dest(as, ir, RSET_GPR);
482
513
  if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */
483
514
  Reg left = ra_alloc1(as, ir->op1, RSET_GPR);
@@ -505,16 +536,42 @@ static void asm_strto(ASMState *as, IRIns *ir)
505
536
  {
506
537
  const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num];
507
538
  IRRef args[2];
539
+ int32_t ofs = 0;
540
+ #if LJ_SOFTFP
541
+ ra_evictset(as, RSET_SCRATCH);
542
+ if (ra_used(ir)) {
543
+ if (ra_hasspill(ir->s) && ra_hasspill((ir+1)->s) &&
544
+ (ir->s & 1) == LJ_BE && (ir->s ^ 1) == (ir+1)->s) {
545
+ int i;
546
+ for (i = 0; i < 2; i++) {
547
+ Reg r = (ir+i)->r;
548
+ if (ra_hasreg(r)) {
549
+ ra_free(as, r);
550
+ ra_modified(as, r);
551
+ emit_spload(as, ir+i, r, sps_scale((ir+i)->s));
552
+ }
553
+ }
554
+ ofs = sps_scale(ir->s & ~1);
555
+ } else {
556
+ Reg rhi = ra_dest(as, ir+1, RSET_GPR);
557
+ Reg rlo = ra_dest(as, ir, rset_exclude(RSET_GPR, rhi));
558
+ emit_tsi(as, MIPSI_LW, rhi, RID_SP, ofs+(LJ_BE?0:4));
559
+ emit_tsi(as, MIPSI_LW, rlo, RID_SP, ofs+(LJ_BE?4:0));
560
+ }
561
+ }
562
+ #else
508
563
  RegSet drop = RSET_SCRATCH;
509
564
  if (ra_hasreg(ir->r)) rset_set(drop, ir->r); /* Spill dest reg (if any). */
510
565
  ra_evictset(as, drop);
566
+ ofs = sps_scale(ir->s);
567
+ #endif
511
568
  asm_guard(as, MIPSI_BEQ, RID_RET, RID_ZERO); /* Test return status. */
512
569
  args[0] = ir->op1; /* GCstr *str */
513
570
  args[1] = ASMREF_TMP1; /* TValue *n */
514
571
  asm_gencall(as, ci, args);
515
572
  /* Store the result to the spill slot or temp slots. */
516
573
  emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1),
517
- RID_SP, sps_scale(ir->s));
574
+ RID_SP, ofs);
518
575
  }
519
576
 
520
577
  /* -- Memory references --------------------------------------------------- */
@@ -532,12 +589,15 @@ static void asm_tvptr(ASMState *as, Reg dest, IRRef ref)
532
589
  /* Otherwise use g->tmptv to hold the TValue. */
533
590
  RegSet allow = rset_exclude(RSET_GPR, dest);
534
591
  Reg type;
535
- emit_tsi(as, MIPSI_ADDIU, dest, RID_JGL, offsetof(global_State, tmptv)-32768);
592
+ emit_tsi(as, MIPSI_ADDIU, dest, RID_JGL, (int32_t)(offsetof(global_State, tmptv)-32768));
536
593
  if (!irt_ispri(ir->t)) {
537
594
  Reg src = ra_alloc1(as, ref, allow);
538
595
  emit_setgl(as, src, tmptv.gcr);
539
596
  }
540
- type = ra_allock(as, irt_toitype(ir->t), allow);
597
+ if (LJ_SOFTFP && (ir+1)->o == IR_HIOP)
598
+ type = ra_alloc1(as, ref+1, allow);
599
+ else
600
+ type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow);
541
601
  emit_setgl(as, type, tmptv.it);
542
602
  }
543
603
  }
@@ -585,15 +645,37 @@ static void asm_href(ASMState *as, IRIns *ir, IROp merge)
585
645
  MCLabel l_end, l_loop, l_next;
586
646
 
587
647
  rset_clear(allow, tab);
648
+ #if LJ_SOFTFP
649
+ if (!irref_isk(refkey)) {
650
+ key = ra_alloc1(as, refkey, allow);
651
+ rset_clear(allow, key);
652
+ if (irkey[1].o == IR_HIOP) {
653
+ if (ra_hasreg((irkey+1)->r)) {
654
+ tmpnum = (irkey+1)->r;
655
+ type = RID_TMP;
656
+ tmp1 = ra_scratch(as, allow);
657
+ rset_clear(allow, tmp1);
658
+ ra_noweak(as, tmpnum);
659
+ } else {
660
+ type = tmpnum = ra_allocref(as, refkey+1, allow);
661
+ }
662
+ rset_clear(allow, tmpnum);
663
+ } else {
664
+ type = ra_allock(as, (int32_t)irt_toitype(irkey->t), allow);
665
+ rset_clear(allow, type);
666
+ }
667
+ }
668
+ #else
588
669
  if (irt_isnum(kt)) {
589
670
  key = ra_alloc1(as, refkey, RSET_FPR);
590
671
  tmpnum = ra_scratch(as, rset_exclude(RSET_FPR, key));
591
672
  } else if (!irt_ispri(kt)) {
592
673
  key = ra_alloc1(as, refkey, allow);
593
674
  rset_clear(allow, key);
594
- type = ra_allock(as, irt_toitype(irkey->t), allow);
675
+ type = ra_allock(as, (int32_t)irt_toitype(irkey->t), allow);
595
676
  rset_clear(allow, type);
596
677
  }
678
+ #endif
597
679
  tmp2 = ra_scratch(as, allow);
598
680
  rset_clear(allow, tmp2);
599
681
 
@@ -615,7 +697,7 @@ static void asm_href(ASMState *as, IRIns *ir, IROp merge)
615
697
  emit_ti(as, MIPSI_LI, RID_TMP, as->snapno);
616
698
  l_end = asm_exitstub_addr(as);
617
699
  }
618
- if (irt_isnum(kt)) {
700
+ if (!LJ_SOFTFP && irt_isnum(kt)) {
619
701
  emit_branch(as, MIPSI_BC1T, 0, 0, l_end);
620
702
  emit_fgh(as, MIPSI_C_EQ_D, 0, tmpnum, key);
621
703
  *--as->mcp = MIPSI_NOP; /* Avoid NaN comparison overhead. */
@@ -660,7 +742,7 @@ static void asm_href(ASMState *as, IRIns *ir, IROp merge)
660
742
  emit_dst(as, MIPSI_XOR, tmp1, tmp1, tmp2);
661
743
  emit_rotr(as, tmp1, tmp1, dest, (-HASH_ROT2-HASH_ROT1)&31);
662
744
  emit_dst(as, MIPSI_SUBU, tmp2, tmp2, dest);
663
- if (irt_isnum(kt)) {
745
+ if (LJ_SOFTFP ? (irkey[1].o == IR_HIOP) : irt_isnum(kt)) {
664
746
  emit_dst(as, MIPSI_XOR, tmp2, tmp2, tmp1);
665
747
  if ((as->flags & JIT_F_MIPS32R2)) {
666
748
  emit_dta(as, MIPSI_ROTR, dest, tmp1, (-HASH_ROT1)&31);
@@ -670,8 +752,13 @@ static void asm_href(ASMState *as, IRIns *ir, IROp merge)
670
752
  emit_dta(as, MIPSI_SRL, dest, tmp1, (-HASH_ROT1)&31);
671
753
  }
672
754
  emit_dst(as, MIPSI_ADDU, tmp1, tmp1, tmp1);
755
+ #if LJ_SOFTFP
756
+ emit_ds(as, MIPSI_MOVE, tmp1, type);
757
+ emit_ds(as, MIPSI_MOVE, tmp2, key);
758
+ #else
673
759
  emit_tg(as, MIPSI_MFC1, tmp2, key);
674
760
  emit_tg(as, MIPSI_MFC1, tmp1, key+1);
761
+ #endif
675
762
  } else {
676
763
  emit_dst(as, MIPSI_XOR, tmp2, key, tmp1);
677
764
  emit_rotr(as, dest, tmp1, tmp2, (-HASH_ROT1)&31);
@@ -795,8 +882,8 @@ static MIPSIns asm_fxloadins(IRIns *ir)
795
882
  case IRT_U8: return MIPSI_LBU;
796
883
  case IRT_I16: return MIPSI_LH;
797
884
  case IRT_U16: return MIPSI_LHU;
798
- case IRT_NUM: return MIPSI_LDC1;
799
- case IRT_FLOAT: return MIPSI_LWC1;
885
+ case IRT_NUM: lua_assert(!LJ_SOFTFP); return MIPSI_LDC1;
886
+ case IRT_FLOAT: if (!LJ_SOFTFP) return MIPSI_LWC1;
800
887
  default: return MIPSI_LW;
801
888
  }
802
889
  }
@@ -806,8 +893,8 @@ static MIPSIns asm_fxstoreins(IRIns *ir)
806
893
  switch (irt_type(ir->t)) {
807
894
  case IRT_I8: case IRT_U8: return MIPSI_SB;
808
895
  case IRT_I16: case IRT_U16: return MIPSI_SH;
809
- case IRT_NUM: return MIPSI_SDC1;
810
- case IRT_FLOAT: return MIPSI_SWC1;
896
+ case IRT_NUM: lua_assert(!LJ_SOFTFP); return MIPSI_SDC1;
897
+ case IRT_FLOAT: if (!LJ_SOFTFP) return MIPSI_SWC1;
811
898
  default: return MIPSI_SW;
812
899
  }
813
900
  }
@@ -845,7 +932,8 @@ static void asm_fstore(ASMState *as, IRIns *ir)
845
932
 
846
933
  static void asm_xload(ASMState *as, IRIns *ir)
847
934
  {
848
- Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR);
935
+ Reg dest = ra_dest(as, ir,
936
+ (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR);
849
937
  lua_assert(!(ir->op2 & IRXLOAD_UNALIGNED));
850
938
  asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR, 0);
851
939
  }
@@ -853,7 +941,8 @@ static void asm_xload(ASMState *as, IRIns *ir)
853
941
  static void asm_xstore_(ASMState *as, IRIns *ir, int32_t ofs)
854
942
  {
855
943
  if (ir->r != RID_SINK) {
856
- Reg src = ra_alloc1z(as, ir->op2, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR);
944
+ Reg src = ra_alloc1z(as, ir->op2,
945
+ (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR);
857
946
  asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1,
858
947
  rset_exclude(RSET_GPR, src), ofs);
859
948
  }
@@ -863,25 +952,34 @@ static void asm_xstore_(ASMState *as, IRIns *ir, int32_t ofs)
863
952
 
864
953
  static void asm_ahuvload(ASMState *as, IRIns *ir)
865
954
  {
866
- IRType1 t = ir->t;
955
+ int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP);
956
+ IRType t = hiop ? IRT_NUM : irt_type(ir->t);
867
957
  Reg dest = RID_NONE, type = RID_TMP, idx;
868
958
  RegSet allow = RSET_GPR;
869
959
  int32_t ofs = 0;
960
+ if (hiop && ra_used(ir+1)) {
961
+ type = ra_dest(as, ir+1, allow);
962
+ rset_clear(allow, type);
963
+ }
870
964
  if (ra_used(ir)) {
871
- lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t));
872
- dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR);
965
+ lua_assert((LJ_SOFTFP ? 0 : irt_isnum(ir->t)) ||
966
+ irt_isint(ir->t) || irt_isaddr(ir->t));
967
+ dest = ra_dest(as, ir, (!LJ_SOFTFP && t == IRT_NUM) ? RSET_FPR : allow);
873
968
  rset_clear(allow, dest);
874
969
  }
875
970
  idx = asm_fuseahuref(as, ir->op1, &ofs, allow);
876
971
  rset_clear(allow, idx);
877
- if (irt_isnum(t)) {
878
- asm_guard(as, MIPSI_BEQ, type, RID_ZERO);
879
- emit_tsi(as, MIPSI_SLTIU, type, type, (int32_t)LJ_TISNUM);
880
- if (ra_hasreg(dest))
881
- emit_hsi(as, MIPSI_LDC1, dest, idx, ofs);
972
+ if (t == IRT_NUM) {
973
+ asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO);
974
+ emit_tsi(as, MIPSI_SLTIU, RID_TMP, type, (int32_t)LJ_TISNUM);
882
975
  } else {
883
- asm_guard(as, MIPSI_BNE, type, ra_allock(as, irt_toitype(t), allow));
884
- if (ra_hasreg(dest)) emit_tsi(as, MIPSI_LW, dest, idx, ofs+(LJ_BE?4:0));
976
+ asm_guard(as, MIPSI_BNE, type, ra_allock(as, irt_toitype_(t), allow));
977
+ }
978
+ if (ra_hasreg(dest)) {
979
+ if (!LJ_SOFTFP && t == IRT_NUM)
980
+ emit_hsi(as, MIPSI_LDC1, dest, idx, ofs);
981
+ else
982
+ emit_tsi(as, MIPSI_LW, dest, idx, ofs+(LJ_BE?4:0));
885
983
  }
886
984
  emit_tsi(as, MIPSI_LW, type, idx, ofs+(LJ_BE?0:4));
887
985
  }
@@ -893,18 +991,22 @@ static void asm_ahustore(ASMState *as, IRIns *ir)
893
991
  int32_t ofs = 0;
894
992
  if (ir->r == RID_SINK)
895
993
  return;
896
- if (irt_isnum(ir->t)) {
994
+ if (!LJ_SOFTFP && irt_isnum(ir->t)) {
897
995
  src = ra_alloc1(as, ir->op2, RSET_FPR);
898
996
  } else {
997
+ int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP);
899
998
  if (!irt_ispri(ir->t)) {
900
999
  src = ra_alloc1(as, ir->op2, allow);
901
1000
  rset_clear(allow, src);
902
1001
  }
903
- type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow);
1002
+ if (hiop)
1003
+ type = ra_alloc1(as, (ir+1)->op2, allow);
1004
+ else
1005
+ type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow);
904
1006
  rset_clear(allow, type);
905
1007
  }
906
1008
  idx = asm_fuseahuref(as, ir->op1, &ofs, allow);
907
- if (irt_isnum(ir->t)) {
1009
+ if (!LJ_SOFTFP && irt_isnum(ir->t)) {
908
1010
  emit_hsi(as, MIPSI_SDC1, src, idx, ofs);
909
1011
  } else {
910
1012
  if (ra_hasreg(src))
@@ -916,35 +1018,45 @@ static void asm_ahustore(ASMState *as, IRIns *ir)
916
1018
  static void asm_sload(ASMState *as, IRIns *ir)
917
1019
  {
918
1020
  int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0);
919
- IRType1 t = ir->t;
1021
+ int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP);
1022
+ IRType t = hiop ? IRT_NUM : irt_type(ir->t);
920
1023
  Reg dest = RID_NONE, type = RID_NONE, base;
921
1024
  RegSet allow = RSET_GPR;
922
1025
  lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */
923
- lua_assert(irt_isguard(t) || !(ir->op2 & IRSLOAD_TYPECHECK));
924
- lua_assert(!irt_isint(t) || (ir->op2 & (IRSLOAD_CONVERT|IRSLOAD_FRAME)));
925
- if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(t) && irt_isint(t)) {
1026
+ lua_assert(irt_isguard(ir->t) || !(ir->op2 & IRSLOAD_TYPECHECK));
1027
+ #if LJ_SOFTFP
1028
+ lua_assert(!(ir->op2 & IRSLOAD_CONVERT)); /* Handled by LJ_SOFTFP SPLIT. */
1029
+ if (hiop && ra_used(ir+1)) {
1030
+ type = ra_dest(as, ir+1, allow);
1031
+ rset_clear(allow, type);
1032
+ }
1033
+ #else
1034
+ if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(ir->t) && t == IRT_INT) {
926
1035
  dest = ra_scratch(as, RSET_FPR);
927
1036
  asm_tointg(as, ir, dest);
928
- t.irt = IRT_NUM; /* Continue with a regular number type check. */
929
- } else if (ra_used(ir)) {
930
- lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t));
931
- dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR);
1037
+ t = IRT_NUM; /* Continue with a regular number type check. */
1038
+ } else
1039
+ #endif
1040
+ if (ra_used(ir)) {
1041
+ lua_assert((LJ_SOFTFP ? 0 : irt_isnum(ir->t)) ||
1042
+ irt_isint(ir->t) || irt_isaddr(ir->t));
1043
+ dest = ra_dest(as, ir, (!LJ_SOFTFP && t == IRT_NUM) ? RSET_FPR : allow);
932
1044
  rset_clear(allow, dest);
933
1045
  base = ra_alloc1(as, REF_BASE, allow);
934
1046
  rset_clear(allow, base);
935
- if ((ir->op2 & IRSLOAD_CONVERT)) {
936
- if (irt_isint(t)) {
1047
+ if (!LJ_SOFTFP && (ir->op2 & IRSLOAD_CONVERT)) {
1048
+ if (t == IRT_INT) {
937
1049
  Reg tmp = ra_scratch(as, RSET_FPR);
938
1050
  emit_tg(as, MIPSI_MFC1, dest, tmp);
939
1051
  emit_fg(as, MIPSI_TRUNC_W_D, tmp, tmp);
940
1052
  dest = tmp;
941
- t.irt = IRT_NUM; /* Check for original type. */
1053
+ t = IRT_NUM; /* Check for original type. */
942
1054
  } else {
943
1055
  Reg tmp = ra_scratch(as, RSET_GPR);
944
1056
  emit_fg(as, MIPSI_CVT_D_W, dest, dest);
945
1057
  emit_tg(as, MIPSI_MTC1, tmp, dest);
946
1058
  dest = tmp;
947
- t.irt = IRT_INT; /* Check for original type. */
1059
+ t = IRT_INT; /* Check for original type. */
948
1060
  }
949
1061
  }
950
1062
  goto dotypecheck;
@@ -952,22 +1064,32 @@ static void asm_sload(ASMState *as, IRIns *ir)
952
1064
  base = ra_alloc1(as, REF_BASE, allow);
953
1065
  rset_clear(allow, base);
954
1066
  dotypecheck:
955
- if (irt_isnum(t)) {
956
- if ((ir->op2 & IRSLOAD_TYPECHECK)) {
957
- asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO);
958
- emit_tsi(as, MIPSI_SLTIU, RID_TMP, RID_TMP, (int32_t)LJ_TISNUM);
959
- type = RID_TMP;
1067
+ if ((ir->op2 & IRSLOAD_TYPECHECK)) {
1068
+ if (ra_noreg(type)) {
1069
+ if (ofs < 256 && ra_hasreg(dest) && (dest & 1) == 0 &&
1070
+ rset_test((as->freeset & allow), dest+1)) {
1071
+ type = dest+1;
1072
+ ra_modified(as, type);
1073
+ } else {
1074
+ type = RID_TMP;
1075
+ }
960
1076
  }
961
- if (ra_hasreg(dest)) emit_hsi(as, MIPSI_LDC1, dest, base, ofs);
962
- } else {
963
- if ((ir->op2 & IRSLOAD_TYPECHECK)) {
964
- Reg ktype = ra_allock(as, irt_toitype(t), allow);
965
- asm_guard(as, MIPSI_BNE, RID_TMP, ktype);
966
- type = RID_TMP;
1077
+ if (t == IRT_NUM) {
1078
+ asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO);
1079
+ emit_tsi(as, MIPSI_SLTIU, RID_TMP, type, (int32_t)LJ_TISNUM);
1080
+ } else {
1081
+ Reg ktype = ra_allock(as, irt_toitype_(t), allow);
1082
+ asm_guard(as, MIPSI_BNE, type, ktype);
967
1083
  }
968
- if (ra_hasreg(dest)) emit_tsi(as, MIPSI_LW, dest, base, ofs ^ (LJ_BE?4:0));
969
1084
  }
970
- if (ra_hasreg(type)) emit_tsi(as, MIPSI_LW, type, base, ofs ^ (LJ_BE?0:4));
1085
+ if (ra_hasreg(dest)) {
1086
+ if (!LJ_SOFTFP && t == IRT_NUM)
1087
+ emit_hsi(as, MIPSI_LDC1, dest, base, ofs);
1088
+ else
1089
+ emit_tsi(as, MIPSI_LW, dest, base, ofs ^ (LJ_BE?4:0));
1090
+ }
1091
+ if (ra_hasreg(type))
1092
+ emit_tsi(as, MIPSI_LW, type, base, ofs ^ (LJ_BE?0:4));
971
1093
  }
972
1094
 
973
1095
  /* -- Allocations --------------------------------------------------------- */
@@ -1080,6 +1202,7 @@ static void asm_obar(ASMState *as, IRIns *ir)
1080
1202
 
1081
1203
  /* -- Arithmetic and logic operations ------------------------------------- */
1082
1204
 
1205
+ #if !LJ_SOFTFP
1083
1206
  static void asm_fparith(ASMState *as, IRIns *ir, MIPSIns mi)
1084
1207
  {
1085
1208
  Reg dest = ra_dest(as, ir, RSET_FPR);
@@ -1106,12 +1229,16 @@ static void asm_fpmath(ASMState *as, IRIns *ir)
1106
1229
  else
1107
1230
  asm_callid(as, ir, IRCALL_lj_vm_floor + ir->op2);
1108
1231
  }
1232
+ #endif
1109
1233
 
1110
1234
  static void asm_add(ASMState *as, IRIns *ir)
1111
1235
  {
1236
+ #if !LJ_SOFTFP
1112
1237
  if (irt_isnum(ir->t)) {
1113
1238
  asm_fparith(as, ir, MIPSI_ADD_D);
1114
- } else {
1239
+ } else
1240
+ #endif
1241
+ {
1115
1242
  Reg dest = ra_dest(as, ir, RSET_GPR);
1116
1243
  Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR);
1117
1244
  if (irref_isk(ir->op2)) {
@@ -1128,9 +1255,12 @@ static void asm_add(ASMState *as, IRIns *ir)
1128
1255
 
1129
1256
  static void asm_sub(ASMState *as, IRIns *ir)
1130
1257
  {
1258
+ #if !LJ_SOFTFP
1131
1259
  if (irt_isnum(ir->t)) {
1132
1260
  asm_fparith(as, ir, MIPSI_SUB_D);
1133
- } else {
1261
+ } else
1262
+ #endif
1263
+ {
1134
1264
  Reg dest = ra_dest(as, ir, RSET_GPR);
1135
1265
  Reg right, left = ra_alloc2(as, ir, RSET_GPR);
1136
1266
  right = (left >> 8); left &= 255;
@@ -1140,9 +1270,12 @@ static void asm_sub(ASMState *as, IRIns *ir)
1140
1270
 
1141
1271
  static void asm_mul(ASMState *as, IRIns *ir)
1142
1272
  {
1273
+ #if !LJ_SOFTFP
1143
1274
  if (irt_isnum(ir->t)) {
1144
1275
  asm_fparith(as, ir, MIPSI_MUL_D);
1145
- } else {
1276
+ } else
1277
+ #endif
1278
+ {
1146
1279
  Reg dest = ra_dest(as, ir, RSET_GPR);
1147
1280
  Reg right, left = ra_alloc2(as, ir, RSET_GPR);
1148
1281
  right = (left >> 8); left &= 255;
@@ -1156,9 +1289,12 @@ static void asm_mul(ASMState *as, IRIns *ir)
1156
1289
 
1157
1290
  static void asm_neg(ASMState *as, IRIns *ir)
1158
1291
  {
1292
+ #if !LJ_SOFTFP
1159
1293
  if (irt_isnum(ir->t)) {
1160
1294
  asm_fpunary(as, ir, MIPSI_NEG_D);
1161
- } else {
1295
+ } else
1296
+ #endif
1297
+ {
1162
1298
  Reg dest = ra_dest(as, ir, RSET_GPR);
1163
1299
  Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR);
1164
1300
  emit_dst(as, MIPSI_SUBU, dest, RID_ZERO, left);
@@ -1396,9 +1532,25 @@ static void asm_bror(ASMState *as, IRIns *ir)
1396
1532
  }
1397
1533
  }
1398
1534
 
1535
+ #if LJ_SOFTFP
1536
+ static void asm_sfpmin_max(ASMState *as, IRIns *ir)
1537
+ {
1538
+ CCallInfo ci = lj_ir_callinfo[(IROp)ir->o == IR_MIN ? IRCALL_lj_vm_sfmin : IRCALL_lj_vm_sfmax];
1539
+ IRRef args[4];
1540
+ args[0^LJ_BE] = ir->op1;
1541
+ args[1^LJ_BE] = (ir+1)->op1;
1542
+ args[2^LJ_BE] = ir->op2;
1543
+ args[3^LJ_BE] = (ir+1)->op2;
1544
+ asm_setupresult(as, ir, &ci);
1545
+ emit_call(as, (void *)ci.func, 0);
1546
+ ci.func = NULL;
1547
+ asm_gencall(as, &ci, args);
1548
+ }
1549
+ #endif
1550
+
1399
1551
  static void asm_min_max(ASMState *as, IRIns *ir, int ismax)
1400
1552
  {
1401
- if (irt_isnum(ir->t)) {
1553
+ if (!LJ_SOFTFP && irt_isnum(ir->t)) {
1402
1554
  Reg dest = ra_dest(as, ir, RSET_FPR);
1403
1555
  Reg right, left = ra_alloc2(as, ir, RSET_FPR);
1404
1556
  right = (left >> 8); left &= 255;
@@ -1429,11 +1581,72 @@ static void asm_min_max(ASMState *as, IRIns *ir, int ismax)
1429
1581
 
1430
1582
  /* -- Comparisons --------------------------------------------------------- */
1431
1583
 
1584
+ #if LJ_SOFTFP
1585
+ /* SFP comparisons. */
1586
+ static void asm_sfpcomp(ASMState *as, IRIns *ir)
1587
+ {
1588
+ const CCallInfo *ci = &lj_ir_callinfo[IRCALL_softfp_cmp];
1589
+ RegSet drop = RSET_SCRATCH;
1590
+ Reg r;
1591
+ IRRef args[4];
1592
+ args[LJ_LE ? 0 : 1] = ir->op1; args[LJ_LE ? 1 : 0] = (ir+1)->op1;
1593
+ args[LJ_LE ? 2 : 3] = ir->op2; args[LJ_LE ? 3 : 2] = (ir+1)->op2;
1594
+
1595
+ for (r = REGARG_FIRSTGPR; r <= REGARG_FIRSTGPR+3; r++) {
1596
+ if (!rset_test(as->freeset, r) &&
1597
+ regcost_ref(as->cost[r]) == args[r-REGARG_FIRSTGPR])
1598
+ rset_clear(drop, r);
1599
+ }
1600
+ ra_evictset(as, drop);
1601
+
1602
+ asm_setupresult(as, ir, ci);
1603
+
1604
+ switch ((IROp)ir->o) {
1605
+ case IR_LT:
1606
+ asm_guard(as, MIPSI_BGEZ, RID_RET, 0);
1607
+ break;
1608
+ case IR_ULT:
1609
+ asm_guard(as, MIPSI_BEQ, RID_RET, RID_TMP);
1610
+ emit_loadi(as, RID_TMP, 1);
1611
+ asm_guard(as, MIPSI_BEQ, RID_RET, RID_ZERO);
1612
+ break;
1613
+ case IR_GE:
1614
+ asm_guard(as, MIPSI_BEQ, RID_RET, RID_TMP);
1615
+ emit_loadi(as, RID_TMP, 2);
1616
+ asm_guard(as, MIPSI_BLTZ, RID_RET, 0);
1617
+ break;
1618
+ case IR_LE:
1619
+ asm_guard(as, MIPSI_BGTZ, RID_RET, 0);
1620
+ break;
1621
+ case IR_GT:
1622
+ asm_guard(as, MIPSI_BEQ, RID_RET, RID_TMP);
1623
+ emit_loadi(as, RID_TMP, 2);
1624
+ asm_guard(as, MIPSI_BLEZ, RID_RET, 0);
1625
+ break;
1626
+ case IR_UGE:
1627
+ asm_guard(as, MIPSI_BLTZ, RID_RET, 0);
1628
+ break;
1629
+ case IR_ULE:
1630
+ asm_guard(as, MIPSI_BEQ, RID_RET, RID_TMP);
1631
+ emit_loadi(as, RID_TMP, 1);
1632
+ break;
1633
+ case IR_UGT: case IR_ABC:
1634
+ asm_guard(as, MIPSI_BLEZ, RID_RET, 0);
1635
+ break;
1636
+ case IR_EQ: case IR_NE:
1637
+ asm_guard(as, (ir->o & 1) ? MIPSI_BEQ : MIPSI_BNE, RID_RET, RID_ZERO);
1638
+ default:
1639
+ break;
1640
+ }
1641
+ asm_gencall(as, ci, args);
1642
+ }
1643
+ #endif
1644
+
1432
1645
  static void asm_comp(ASMState *as, IRIns *ir)
1433
1646
  {
1434
1647
  /* ORDER IR: LT GE LE GT ULT UGE ULE UGT. */
1435
1648
  IROp op = ir->o;
1436
- if (irt_isnum(ir->t)) {
1649
+ if (!LJ_SOFTFP && irt_isnum(ir->t)) {
1437
1650
  Reg right, left = ra_alloc2(as, ir, RSET_FPR);
1438
1651
  right = (left >> 8); left &= 255;
1439
1652
  asm_guard(as, (op&1) ? MIPSI_BC1T : MIPSI_BC1F, 0, 0);
@@ -1466,9 +1679,9 @@ static void asm_comp(ASMState *as, IRIns *ir)
1466
1679
 
1467
1680
  static void asm_equal(ASMState *as, IRIns *ir)
1468
1681
  {
1469
- Reg right, left = ra_alloc2(as, ir, irt_isnum(ir->t) ? RSET_FPR : RSET_GPR);
1682
+ Reg right, left = ra_alloc2(as, ir, (!LJ_SOFTFP && irt_isnum(ir->t)) ? RSET_FPR : RSET_GPR);
1470
1683
  right = (left >> 8); left &= 255;
1471
- if (irt_isnum(ir->t)) {
1684
+ if (!LJ_SOFTFP && irt_isnum(ir->t)) {
1472
1685
  asm_guard(as, (ir->o & 1) ? MIPSI_BC1T : MIPSI_BC1F, 0, 0);
1473
1686
  emit_fgh(as, MIPSI_C_EQ_D, 0, left, right);
1474
1687
  } else {
@@ -1518,23 +1731,48 @@ static void asm_comp64eq(ASMState *as, IRIns *ir)
1518
1731
  /* Hiword op of a split 64 bit op. Previous op must be the loword op. */
1519
1732
  static void asm_hiop(ASMState *as, IRIns *ir)
1520
1733
  {
1521
- #if LJ_HASFFI
1734
+ #if LJ_HASFFI || LJ_SOFTFP
1522
1735
  /* HIOP is marked as a store because it needs its own DCE logic. */
1523
1736
  int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */
1524
1737
  if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1;
1525
1738
  if ((ir-1)->o == IR_CONV) { /* Conversions to/from 64 bit. */
1526
1739
  as->curins--; /* Always skip the CONV. */
1740
+ #if LJ_HASFFI && !LJ_SOFTFP
1527
1741
  if (usehi || uselo)
1528
1742
  asm_conv64(as, ir);
1529
1743
  return;
1744
+ #endif
1530
1745
  } else if ((ir-1)->o < IR_EQ) { /* 64 bit integer comparisons. ORDER IR. */
1531
1746
  as->curins--; /* Always skip the loword comparison. */
1747
+ #if LJ_SOFTFP
1748
+ if (!irt_isint(ir->t)) {
1749
+ asm_sfpcomp(as, ir-1);
1750
+ return;
1751
+ }
1752
+ #endif
1753
+ #if LJ_HASFFI
1532
1754
  asm_comp64(as, ir);
1755
+ #endif
1533
1756
  return;
1534
1757
  } else if ((ir-1)->o <= IR_NE) { /* 64 bit integer comparisons. ORDER IR. */
1535
1758
  as->curins--; /* Always skip the loword comparison. */
1759
+ #if LJ_SOFTFP
1760
+ if (!irt_isint(ir->t)) {
1761
+ asm_sfpcomp(as, ir-1);
1762
+ return;
1763
+ }
1764
+ #endif
1765
+ #if LJ_HASFFI
1536
1766
  asm_comp64eq(as, ir);
1767
+ #endif
1537
1768
  return;
1769
+ #if LJ_SOFTFP
1770
+ } else if ((ir-1)->o == IR_MIN || (ir-1)->o == IR_MAX) {
1771
+ as->curins--; /* Always skip the loword min/max. */
1772
+ if (uselo || usehi)
1773
+ asm_sfpmin_max(as, ir-1);
1774
+ return;
1775
+ #endif
1538
1776
  } else if ((ir-1)->o == IR_XSTORE) {
1539
1777
  as->curins--; /* Handle both stores here. */
1540
1778
  if ((ir-1)->r != RID_SINK) {
@@ -1545,14 +1783,27 @@ static void asm_hiop(ASMState *as, IRIns *ir)
1545
1783
  }
1546
1784
  if (!usehi) return; /* Skip unused hiword op for all remaining ops. */
1547
1785
  switch ((ir-1)->o) {
1786
+ #if LJ_HASFFI
1548
1787
  case IR_ADD: as->curins--; asm_add64(as, ir); break;
1549
1788
  case IR_SUB: as->curins--; asm_sub64(as, ir); break;
1550
1789
  case IR_NEG: as->curins--; asm_neg64(as, ir); break;
1790
+ #endif
1791
+ #if LJ_SOFTFP
1792
+ case IR_SLOAD: case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD:
1793
+ case IR_STRTO:
1794
+ if (!uselo)
1795
+ ra_allocref(as, ir->op1, RSET_GPR); /* Mark lo op as used. */
1796
+ break;
1797
+ #endif
1551
1798
  case IR_CALLN:
1799
+ case IR_CALLS:
1552
1800
  case IR_CALLXS:
1553
1801
  if (!uselo)
1554
1802
  ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */
1555
1803
  break;
1804
+ #if LJ_SOFTFP
1805
+ case IR_ASTORE: case IR_HSTORE: case IR_USTORE: case IR_TOSTR:
1806
+ #endif
1556
1807
  case IR_CNEWI:
1557
1808
  /* Nothing to do here. Handled by lo op itself. */
1558
1809
  break;
@@ -1619,8 +1870,19 @@ static void asm_stack_restore(ASMState *as, SnapShot *snap)
1619
1870
  if ((sn & SNAP_NORESTORE))
1620
1871
  continue;
1621
1872
  if (irt_isnum(ir->t)) {
1873
+ #if LJ_SOFTFP
1874
+ Reg tmp;
1875
+ RegSet allow = rset_exclude(RSET_GPR, RID_BASE);
1876
+ lua_assert(irref_isk(ref)); /* LJ_SOFTFP: must be a number constant. */
1877
+ tmp = ra_allock(as, (int32_t)ir_knum(ir)->u32.lo, allow);
1878
+ emit_tsi(as, MIPSI_SW, tmp, RID_BASE, ofs+(LJ_BE?4:0));
1879
+ if (rset_test(as->freeset, tmp+1)) allow = RID2RSET(tmp+1);
1880
+ tmp = ra_allock(as, (int32_t)ir_knum(ir)->u32.hi, allow);
1881
+ emit_tsi(as, MIPSI_SW, tmp, RID_BASE, ofs+(LJ_BE?0:4));
1882
+ #else
1622
1883
  Reg src = ra_alloc1(as, ref, RSET_FPR);
1623
1884
  emit_hsi(as, MIPSI_SDC1, src, RID_BASE, ofs);
1885
+ #endif
1624
1886
  } else {
1625
1887
  Reg type;
1626
1888
  RegSet allow = rset_exclude(RSET_GPR, RID_BASE);
@@ -1633,6 +1895,10 @@ static void asm_stack_restore(ASMState *as, SnapShot *snap)
1633
1895
  if ((sn & (SNAP_CONT|SNAP_FRAME))) {
1634
1896
  if (s == 0) continue; /* Do not overwrite link to previous frame. */
1635
1897
  type = ra_allock(as, (int32_t)(*flinks--), allow);
1898
+ #if LJ_SOFTFP
1899
+ } else if ((sn & SNAP_SOFTFPNUM)) {
1900
+ type = ra_alloc1(as, ref+1, rset_exclude(RSET_GPR, RID_BASE));
1901
+ #endif
1636
1902
  } else {
1637
1903
  type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow);
1638
1904
  }
@@ -1756,11 +2022,11 @@ static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci)
1756
2022
  int nslots = 4, ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR;
1757
2023
  asm_collectargs(as, ir, ci, args);
1758
2024
  for (i = 0; i < nargs; i++) {
1759
- if (args[i] && irt_isfp(IR(args[i])->t) &&
2025
+ if (!LJ_SOFTFP && args[i] && irt_isfp(IR(args[i])->t) &&
1760
2026
  nfpr > 0 && !(ci->flags & CCI_VARARG)) {
1761
2027
  nfpr--;
1762
2028
  ngpr -= irt_isnum(IR(args[i])->t) ? 2 : 1;
1763
- } else if (args[i] && irt_isnum(IR(args[i])->t)) {
2029
+ } else if (!LJ_SOFTFP && args[i] && irt_isnum(IR(args[i])->t)) {
1764
2030
  nfpr = 0;
1765
2031
  ngpr = ngpr & ~1;
1766
2032
  if (ngpr > 0) ngpr -= 2; else nslots = (nslots+3) & ~1;