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
  ** Trace recorder for C data operations.
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
  #define lj_ffrecord_c
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Trace recorder for C data operations.
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
  #ifndef _LJ_CRECORD_H
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** C type management.
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
  #include "lj_obj.h"
@@ -14,6 +14,7 @@
14
14
  #include "lj_strfmt.h"
15
15
  #include "lj_ctype.h"
16
16
  #include "lj_ccallback.h"
17
+ #include "lj_buf.h"
17
18
 
18
19
  /* -- C type definitions -------------------------------------------------- */
19
20
 
@@ -38,6 +39,8 @@
38
39
  _("uint64_t", UINT64) \
39
40
  _("intptr_t", INT_PSZ) \
40
41
  _("uintptr_t", UINT_PSZ) \
42
+ /* From POSIX. */ \
43
+ _("ssize_t", INT_PSZ) \
41
44
  /* End of typedef list. */
42
45
 
43
46
  /* Keywords (only the ones we actually care for). */
@@ -569,19 +572,18 @@ GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned)
569
572
  /* Convert complex to string with 'i' or 'I' suffix. */
570
573
  GCstr *lj_ctype_repr_complex(lua_State *L, void *sp, CTSize size)
571
574
  {
572
- char buf[2*STRFMT_MAXBUF_NUM+2+1], *p = buf;
575
+ SBuf *sb = lj_buf_tmp_(L);
573
576
  TValue re, im;
574
577
  if (size == 2*sizeof(double)) {
575
578
  re.n = *(double *)sp; im.n = ((double *)sp)[1];
576
579
  } else {
577
580
  re.n = (double)*(float *)sp; im.n = (double)((float *)sp)[1];
578
581
  }
579
- p = lj_strfmt_wnum(p, &re);
580
- if (!(im.u32.hi & 0x80000000u) || im.n != im.n) *p++ = '+';
581
- p = lj_strfmt_wnum(p, &im);
582
- *p = *(p-1) >= 'a' ? 'I' : 'i';
583
- p++;
584
- return lj_str_new(L, buf, p-buf);
582
+ lj_strfmt_putfnum(sb, STRFMT_G14, re.n);
583
+ if (!(im.u32.hi & 0x80000000u) || im.n != im.n) lj_buf_putchar(sb, '+');
584
+ lj_strfmt_putfnum(sb, STRFMT_G14, im.n);
585
+ lj_buf_putchar(sb, sbufP(sb)[-1] >= 'a' ? 'I' : 'i');
586
+ return lj_buf_str(L, sb);
585
587
  }
586
588
 
587
589
  /* -- C type state -------------------------------------------------------- */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** C type management.
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
  #ifndef _LJ_CTYPE_H
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Debugging and introspection.
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
  #define lj_debug_c
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Debugging and introspection.
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
  #ifndef _LJ_DEBUG_H
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** LuaJIT common internal definitions.
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
  #ifndef _LJ_DEF_H
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Instruction dispatch handling.
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
  #define lj_dispatch_c
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Instruction dispatch handling.
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
  #ifndef _LJ_DISPATCH_H
@@ -14,6 +14,22 @@
14
14
 
15
15
  #if LJ_TARGET_MIPS
16
16
  /* Need our own global offset table for the dreaded MIPS calling conventions. */
17
+
18
+ #ifndef _LJ_VM_H
19
+ LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b);
20
+ #endif
21
+
22
+ #if LJ_SOFTFP
23
+ #ifndef _LJ_IRCALL_H
24
+ extern double __adddf3(double a, double b);
25
+ extern double __subdf3(double a, double b);
26
+ extern double __muldf3(double a, double b);
27
+ extern double __divdf3(double a, double b);
28
+ #endif
29
+ #define SFGOTDEF(_) _(sqrt) _(__adddf3) _(__subdf3) _(__muldf3) _(__divdf3)
30
+ #else
31
+ #define SFGOTDEF(_)
32
+ #endif
17
33
  #if LJ_HASJIT
18
34
  #define JITGOTDEF(_) _(lj_trace_exit) _(lj_trace_hot)
19
35
  #else
@@ -28,18 +44,19 @@
28
44
  #define GOTDEF(_) \
29
45
  _(floor) _(ceil) _(trunc) _(log) _(log10) _(exp) _(sin) _(cos) _(tan) \
30
46
  _(asin) _(acos) _(atan) _(sinh) _(cosh) _(tanh) _(frexp) _(modf) _(atan2) \
31
- _(pow) _(fmod) _(ldexp) \
47
+ _(pow) _(fmod) _(ldexp) _(lj_vm_modi) \
32
48
  _(lj_dispatch_call) _(lj_dispatch_ins) _(lj_dispatch_stitch) \
33
49
  _(lj_dispatch_profile) _(lj_err_throw) \
34
50
  _(lj_ffh_coroutine_wrap_err) _(lj_func_closeuv) _(lj_func_newL_gc) \
35
51
  _(lj_gc_barrieruv) _(lj_gc_step) _(lj_gc_step_fixtop) _(lj_meta_arith) \
36
52
  _(lj_meta_call) _(lj_meta_cat) _(lj_meta_comp) _(lj_meta_equal) \
37
53
  _(lj_meta_for) _(lj_meta_istype) _(lj_meta_len) _(lj_meta_tget) \
38
- _(lj_meta_tset) _(lj_state_growstack) _(lj_strfmt_num) \
54
+ _(lj_meta_tset) _(lj_state_growstack) _(lj_strfmt_number) \
39
55
  _(lj_str_new) _(lj_tab_dup) _(lj_tab_get) _(lj_tab_getinth) _(lj_tab_len) \
40
56
  _(lj_tab_new) _(lj_tab_newkey) _(lj_tab_next) _(lj_tab_reasize) \
41
57
  _(lj_tab_setinth) _(lj_buf_putstr_reverse) _(lj_buf_putstr_lower) \
42
- _(lj_buf_putstr_upper) _(lj_buf_tostr) JITGOTDEF(_) FFIGOTDEF(_)
58
+ _(lj_buf_putstr_upper) _(lj_buf_tostr) \
59
+ JITGOTDEF(_) FFIGOTDEF(_) SFGOTDEF(_)
43
60
 
44
61
  enum {
45
62
  #define GOTENUM(name) LJ_GOT_##name,
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** ARM instruction emitter.
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
  /* -- Constant encoding --------------------------------------------------- */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** MIPS instruction emitter.
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
  /* -- Emit basic instructions --------------------------------------------- */
@@ -152,16 +152,18 @@ static void emit_jmp(ASMState *as, MCode *target)
152
152
  emit_branch(as, MIPSI_B, RID_ZERO, RID_ZERO, (target));
153
153
  }
154
154
 
155
- static void emit_call(ASMState *as, void *target)
155
+ static void emit_call(ASMState *as, void *target, int needcfa)
156
156
  {
157
157
  MCode *p = as->mcp;
158
158
  *--p = MIPSI_NOP;
159
- if ((((uintptr_t)target ^ (uintptr_t)p) >> 28) == 0)
159
+ if ((((uintptr_t)target ^ (uintptr_t)p) >> 28) == 0) {
160
160
  *--p = MIPSI_JAL | (((uintptr_t)target >>2) & 0x03ffffffu);
161
- else /* Target out of range: need indirect call. */
161
+ } else { /* Target out of range: need indirect call. */
162
162
  *--p = MIPSI_JALR | MIPSF_S(RID_CFUNCADDR);
163
+ needcfa = 1;
164
+ }
163
165
  as->mcp = p;
164
- ra_allockreg(as, i32ptr(target), RID_CFUNCADDR);
166
+ if (needcfa) ra_allockreg(as, i32ptr(target), RID_CFUNCADDR);
165
167
  }
166
168
 
167
169
  /* -- Emit generic operations --------------------------------------------- */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** PPC instruction emitter.
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
  /* -- Emit basic instructions --------------------------------------------- */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** x86/x64 instruction emitter.
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
  /* -- Emit basic instructions --------------------------------------------- */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Error handling.
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
  #define lj_err_c
@@ -183,20 +183,13 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode)
183
183
 
184
184
  /* -- External frame unwinding -------------------------------------------- */
185
185
 
186
- #if defined(__GNUC__) && !LJ_NO_UNWIND && !LJ_TARGET_WINDOWS
186
+ #if defined(__GNUC__) && !LJ_NO_UNWIND && !LJ_ABI_WIN
187
187
 
188
188
  /*
189
189
  ** We have to use our own definitions instead of the mandatory (!) unwind.h,
190
190
  ** since various OS, distros and compilers mess up the header installation.
191
191
  */
192
192
 
193
- typedef struct _Unwind_Exception
194
- {
195
- uint64_t exclass;
196
- void (*excleanup)(int, struct _Unwind_Exception *);
197
- uintptr_t p1, p2;
198
- } __attribute__((__aligned__)) _Unwind_Exception;
199
-
200
193
  typedef struct _Unwind_Context _Unwind_Context;
201
194
 
202
195
  #define _URC_OK 0
@@ -206,8 +199,20 @@ typedef struct _Unwind_Context _Unwind_Context;
206
199
  #define _URC_CONTINUE_UNWIND 8
207
200
  #define _URC_FAILURE 9
208
201
 
202
+ #define LJ_UEXCLASS 0x4c55414a49543200ULL /* LUAJIT2\0 */
203
+ #define LJ_UEXCLASS_MAKE(c) (LJ_UEXCLASS | (uint64_t)(c))
204
+ #define LJ_UEXCLASS_CHECK(cl) (((cl) ^ LJ_UEXCLASS) <= 0xff)
205
+ #define LJ_UEXCLASS_ERRCODE(cl) ((int)((cl) & 0xff))
206
+
209
207
  #if !LJ_TARGET_ARM
210
208
 
209
+ typedef struct _Unwind_Exception
210
+ {
211
+ uint64_t exclass;
212
+ void (*excleanup)(int, struct _Unwind_Exception *);
213
+ uintptr_t p1, p2;
214
+ } __attribute__((__aligned__)) _Unwind_Exception;
215
+
211
216
  extern uintptr_t _Unwind_GetCFA(_Unwind_Context *);
212
217
  extern void _Unwind_SetGR(_Unwind_Context *, int, uintptr_t);
213
218
  extern void _Unwind_SetIP(_Unwind_Context *, uintptr_t);
@@ -219,11 +224,6 @@ extern int _Unwind_RaiseException(_Unwind_Exception *);
219
224
  #define _UA_HANDLER_FRAME 4
220
225
  #define _UA_FORCE_UNWIND 8
221
226
 
222
- #define LJ_UEXCLASS 0x4c55414a49543200ULL /* LUAJIT2\0 */
223
- #define LJ_UEXCLASS_MAKE(c) (LJ_UEXCLASS | (uint64_t)(c))
224
- #define LJ_UEXCLASS_CHECK(cl) (((cl) ^ LJ_UEXCLASS) <= 0xff)
225
- #define LJ_UEXCLASS_ERRCODE(cl) ((int)((cl) & 0xff))
226
-
227
227
  /* DWARF2 personality handler referenced from interpreter .eh_frame. */
228
228
  LJ_FUNCA int lj_err_unwind_dwarf(int version, int actions,
229
229
  uint64_t uexclass, _Unwind_Exception *uex, _Unwind_Context *ctx)
@@ -302,10 +302,23 @@ static void err_raise_ext(int errcode)
302
302
  }
303
303
  #endif
304
304
 
305
- #else
305
+ #else /* LJ_TARGET_ARM */
306
+
307
+ #define _US_VIRTUAL_UNWIND_FRAME 0
308
+ #define _US_UNWIND_FRAME_STARTING 1
309
+ #define _US_ACTION_MASK 3
310
+ #define _US_FORCE_UNWIND 8
311
+
312
+ typedef struct _Unwind_Control_Block _Unwind_Control_Block;
313
+ typedef struct _Unwind_Context _Unwind_Context;
306
314
 
307
- extern void _Unwind_DeleteException(void *);
308
- extern int __gnu_unwind_frame (void *, _Unwind_Context *);
315
+ struct _Unwind_Control_Block {
316
+ uint64_t exclass;
317
+ uint32_t misc[20];
318
+ };
319
+
320
+ extern int _Unwind_RaiseException(_Unwind_Control_Block *);
321
+ extern int __gnu_unwind_frame(_Unwind_Control_Block *, _Unwind_Context *);
309
322
  extern int _Unwind_VRS_Set(_Unwind_Context *, int, uint32_t, int, void *);
310
323
  extern int _Unwind_VRS_Get(_Unwind_Context *, int, uint32_t, int, void *);
311
324
 
@@ -321,35 +334,58 @@ static inline void _Unwind_SetGR(_Unwind_Context *ctx, int r, uint32_t v)
321
334
  _Unwind_VRS_Set(ctx, 0, r, 0, &v);
322
335
  }
323
336
 
324
- #define _US_VIRTUAL_UNWIND_FRAME 0
325
- #define _US_UNWIND_FRAME_STARTING 1
326
- #define _US_ACTION_MASK 3
327
- #define _US_FORCE_UNWIND 8
337
+ extern void lj_vm_unwind_ext(void);
328
338
 
329
339
  /* ARM unwinder personality handler referenced from interpreter .ARM.extab. */
330
- LJ_FUNCA int lj_err_unwind_arm(int state, void *ucb, _Unwind_Context *ctx)
340
+ LJ_FUNCA int lj_err_unwind_arm(int state, _Unwind_Control_Block *ucb,
341
+ _Unwind_Context *ctx)
331
342
  {
332
343
  void *cf = (void *)_Unwind_GetGR(ctx, 13);
333
344
  lua_State *L = cframe_L(cf);
334
- if ((state & _US_ACTION_MASK) == _US_VIRTUAL_UNWIND_FRAME) {
335
- setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP));
345
+ int errcode;
346
+
347
+ switch ((state & _US_ACTION_MASK)) {
348
+ case _US_VIRTUAL_UNWIND_FRAME:
349
+ if ((state & _US_FORCE_UNWIND)) break;
336
350
  return _URC_HANDLER_FOUND;
337
- }
338
- if ((state&(_US_ACTION_MASK|_US_FORCE_UNWIND)) == _US_UNWIND_FRAME_STARTING) {
339
- _Unwind_DeleteException(ucb);
340
- _Unwind_SetGR(ctx, 15, (uint32_t)(void *)lj_err_throw);
341
- _Unwind_SetGR(ctx, 0, (uint32_t)L);
342
- _Unwind_SetGR(ctx, 1, (uint32_t)LUA_ERRRUN);
351
+ case _US_UNWIND_FRAME_STARTING:
352
+ if (LJ_UEXCLASS_CHECK(ucb->exclass)) {
353
+ errcode = LJ_UEXCLASS_ERRCODE(ucb->exclass);
354
+ } else {
355
+ errcode = LUA_ERRRUN;
356
+ setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP));
357
+ }
358
+ cf = err_unwind(L, cf, errcode);
359
+ if ((state & _US_FORCE_UNWIND) || cf == NULL) break;
360
+ _Unwind_SetGR(ctx, 15, (uint32_t)lj_vm_unwind_ext);
361
+ _Unwind_SetGR(ctx, 0, (uint32_t)ucb);
362
+ _Unwind_SetGR(ctx, 1, (uint32_t)errcode);
363
+ _Unwind_SetGR(ctx, 2, cframe_unwind_ff(cf) ?
364
+ (uint32_t)lj_vm_unwind_ff_eh :
365
+ (uint32_t)lj_vm_unwind_c_eh);
343
366
  return _URC_INSTALL_CONTEXT;
367
+ default:
368
+ return _URC_FAILURE;
344
369
  }
345
370
  if (__gnu_unwind_frame(ucb, ctx) != _URC_OK)
346
371
  return _URC_FAILURE;
347
372
  return _URC_CONTINUE_UNWIND;
348
373
  }
349
374
 
375
+ #if LJ_UNWIND_EXT
376
+ static __thread _Unwind_Control_Block static_uex;
377
+
378
+ static void err_raise_ext(int errcode)
379
+ {
380
+ memset(&static_uex, 0, sizeof(static_uex));
381
+ static_uex.exclass = LJ_UEXCLASS_MAKE(errcode);
382
+ _Unwind_RaiseException(&static_uex);
383
+ }
350
384
  #endif
351
385
 
352
- #elif LJ_TARGET_X64 && LJ_TARGET_WINDOWS
386
+ #endif /* LJ_TARGET_ARM */
387
+
388
+ #elif LJ_TARGET_X64 && LJ_ABI_WIN
353
389
 
354
390
  /*
355
391
  ** Someone in Redmond owes me several days of my life. A lot of this is
@@ -414,7 +450,9 @@ LJ_FUNCA EXCEPTION_DISPOSITION lj_err_unwind_win64(EXCEPTION_RECORD *rec,
414
450
  if (cf2) { /* We catch it, so start unwinding the upper frames. */
415
451
  if (rec->ExceptionCode == LJ_MSVC_EXCODE ||
416
452
  rec->ExceptionCode == LJ_GCC_EXCODE) {
453
+ #if LJ_TARGET_WINDOWS
417
454
  __DestructExceptionObject(rec, 1);
455
+ #endif
418
456
  setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP));
419
457
  } else if (!LJ_EXCODE_CHECK(rec->ExceptionCode)) {
420
458
  /* Don't catch access violations etc. */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Error handling.
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
  #ifndef _LJ_ERR_H
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** VM error messages.
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
  /* This file may be included multiple times with different ERRDEF macros. */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Fast function IDs.
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
  #ifndef _LJ_FF_H
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Fast function call recorder.
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
  #define lj_ffrecord_c
@@ -96,18 +96,10 @@ static ptrdiff_t results_wanted(jit_State *J)
96
96
  return -1;
97
97
  }
98
98
 
99
- #ifdef LUAJIT_TRACE_STITCHING
100
- /* This feature is disabled for now due to a design mistake. Sorry.
101
- **
102
- ** It causes unpredictable behavior and crashes when a full trace flush
103
- ** happens with a stitching continuation still in the stack somewhere.
104
- */
105
-
106
99
  /* Trace stitching: add continuation below frame to start a new trace. */
107
100
  static void recff_stitch(jit_State *J)
108
101
  {
109
102
  ASMFunction cont = lj_cont_stitch;
110
- TraceNo traceno = J->cur.traceno;
111
103
  lua_State *L = J->L;
112
104
  TValue *base = L->base;
113
105
  const BCIns *pc = frame_pc(base-1);
@@ -120,7 +112,7 @@ static void recff_stitch(jit_State *J)
120
112
  setframe_ftsz(base+1, ((char *)(base+1) - (char *)pframe) + FRAME_CONT);
121
113
  setcont(base, cont);
122
114
  setframe_pc(base, pc);
123
- if (LJ_DUALNUM) setintV(base-1, traceno); else base[-1].u64 = traceno;
115
+ setnilV(base-1); /* Incorrect, but rec_check_slots() won't run anymore. */
124
116
  L->base += 2;
125
117
  L->top += 2;
126
118
 
@@ -132,7 +124,9 @@ static void recff_stitch(jit_State *J)
132
124
  trcont = lj_ir_kptr(J, (void *)cont);
133
125
  #endif
134
126
  J->base[0] = trcont | TREF_CONT;
135
- J->base[-1] = LJ_DUALNUM ? lj_ir_kint(J,traceno) : lj_ir_knum_u64(J,traceno);
127
+ J->ktracep = lj_ir_k64_reserve(J);
128
+ lua_assert(irt_toitype_(IRT_P64) == LJ_TTRACE);
129
+ J->base[-1] = emitir(IRT(IR_XLOAD, IRT_P64), lj_ir_kptr(J, &J->ktracep->gcr), 0);
136
130
  J->base += 2;
137
131
  J->baseslot += 2;
138
132
  J->framedepth++;
@@ -181,31 +175,6 @@ static void LJ_FASTCALL recff_nyi(jit_State *J, RecordFFData *rd)
181
175
 
182
176
  /* Must stop the trace for classic C functions with arbitrary side-effects. */
183
177
  #define recff_c recff_nyi
184
- #else
185
- /* Fallback handler for fast functions that are not recorded (yet). */
186
- static void LJ_FASTCALL recff_nyi(jit_State *J, RecordFFData *rd)
187
- {
188
- setfuncV(J->L, &J->errinfo, J->fn);
189
- lj_trace_err_info(J, LJ_TRERR_NYIFF);
190
- UNUSED(rd);
191
- }
192
-
193
- /* Throw error for unsupported variant of fast function. */
194
- LJ_NORET static void recff_nyiu(jit_State *J, RecordFFData *rd)
195
- {
196
- setfuncV(J->L, &J->errinfo, J->fn);
197
- lj_trace_err_info(J, LJ_TRERR_NYIFFU);
198
- UNUSED(rd);
199
- }
200
-
201
- /* Must abort the trace for classic C functions with arbitrary side-effects. */
202
- static void LJ_FASTCALL recff_c(jit_State *J, RecordFFData *rd)
203
- {
204
- setfuncV(J->L, &J->errinfo, J->fn);
205
- lj_trace_err_info(J, LJ_TRERR_NYICF);
206
- UNUSED(rd);
207
- }
208
- #endif
209
178
 
210
179
  /* Emit BUFHDR for the global temporary buffer. */
211
180
  static TRef recff_bufhdr(jit_State *J)
@@ -466,11 +435,12 @@ static void LJ_FASTCALL recff_ipairs_aux(jit_State *J, RecordFFData *rd)
466
435
 
467
436
  static void LJ_FASTCALL recff_xpairs(jit_State *J, RecordFFData *rd)
468
437
  {
469
- if (!(LJ_52 && recff_metacall(J, rd, MM_ipairs))) {
470
- TRef tab = J->base[0];
471
- if (tref_istab(tab)) {
438
+ TRef tr = J->base[0];
439
+ if (!((LJ_52 || (LJ_HASFFI && tref_iscdata(tr))) &&
440
+ recff_metacall(J, rd, MM_pairs + rd->data))) {
441
+ if (tref_istab(tr)) {
472
442
  J->base[0] = lj_ir_kfunc(J, funcV(&J->fn->c.upvalue[0]));
473
- J->base[1] = tab;
443
+ J->base[1] = tr;
474
444
  J->base[2] = rd->data ? lj_ir_kint(J, 0) : TREF_NIL;
475
445
  rd->nres = 3;
476
446
  } /* else: Interpreter will throw. */