immunio 0.15.4 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (454) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +0 -27
  3. data/ext/immunio/Rakefile +9 -0
  4. data/lib/immunio/plugins/active_record.rb +1 -1
  5. data/lib/immunio/plugins/active_record_relation.rb +1 -1
  6. data/lib/immunio/plugins/environment_reporter.rb +20 -0
  7. data/lib/immunio/rufus_lua_ext/ref.rb +1 -3
  8. data/lib/immunio/version.rb +1 -1
  9. data/lib/immunio/vm.rb +1 -2
  10. data/lua-hooks/Makefile +97 -0
  11. data/lua-hooks/ext/all.c +41 -52
  12. data/lua-hooks/ext/all.o +0 -0
  13. data/lua-hooks/ext/libinjection/libinjection_html5.o +0 -0
  14. data/lua-hooks/ext/libinjection/libinjection_sqli.o +0 -0
  15. data/lua-hooks/ext/libinjection/libinjection_xss.o +0 -0
  16. data/lua-hooks/ext/libinjection/lualib.c +2 -2
  17. data/lua-hooks/ext/lpeg/lpcap.c +2 -2
  18. data/lua-hooks/ext/lpeg/lpcap.o +0 -0
  19. data/lua-hooks/ext/lpeg/lpcode.c +2 -2
  20. data/lua-hooks/ext/lpeg/lpcode.h +1 -1
  21. data/lua-hooks/ext/lpeg/lpcode.o +0 -0
  22. data/lua-hooks/ext/lpeg/lpprint.o +0 -0
  23. data/lua-hooks/ext/lpeg/lptree.c +2 -2
  24. data/lua-hooks/ext/lpeg/lptypes.h +1 -1
  25. data/lua-hooks/ext/lpeg/lpvm.c +2 -2
  26. data/lua-hooks/ext/lpeg/lpvm.o +0 -0
  27. data/lua-hooks/ext/lua-cmsgpack/lua_cmsgpack.c +16 -3
  28. data/lua-hooks/ext/lua-snapshot/snapshot.c +14 -7
  29. data/lua-hooks/ext/luajit/COPYRIGHT +56 -0
  30. data/lua-hooks/ext/luajit/Makefile +159 -0
  31. data/lua-hooks/ext/luajit/README +16 -0
  32. data/lua-hooks/ext/luajit/doc/bluequad-print.css +166 -0
  33. data/lua-hooks/ext/luajit/doc/bluequad.css +325 -0
  34. data/lua-hooks/ext/luajit/doc/changes.html +804 -0
  35. data/lua-hooks/ext/luajit/doc/contact.html +104 -0
  36. data/lua-hooks/ext/luajit/doc/ext_c_api.html +189 -0
  37. data/lua-hooks/ext/luajit/doc/ext_ffi.html +332 -0
  38. data/lua-hooks/ext/luajit/doc/ext_ffi_api.html +570 -0
  39. data/lua-hooks/ext/luajit/doc/ext_ffi_semantics.html +1261 -0
  40. data/lua-hooks/ext/luajit/doc/ext_ffi_tutorial.html +603 -0
  41. data/lua-hooks/ext/luajit/doc/ext_jit.html +201 -0
  42. data/lua-hooks/ext/luajit/doc/ext_profiler.html +365 -0
  43. data/lua-hooks/ext/luajit/doc/extensions.html +448 -0
  44. data/lua-hooks/ext/luajit/doc/faq.html +186 -0
  45. data/lua-hooks/ext/luajit/doc/img/contact.png +0 -0
  46. data/lua-hooks/ext/luajit/doc/install.html +659 -0
  47. data/lua-hooks/ext/luajit/doc/luajit.html +236 -0
  48. data/lua-hooks/ext/luajit/doc/running.html +309 -0
  49. data/lua-hooks/ext/luajit/doc/status.html +118 -0
  50. data/lua-hooks/ext/luajit/dynasm/dasm_arm.h +456 -0
  51. data/lua-hooks/ext/luajit/dynasm/dasm_arm.lua +1125 -0
  52. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.h +518 -0
  53. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.lua +1166 -0
  54. data/lua-hooks/ext/luajit/dynasm/dasm_mips.h +416 -0
  55. data/lua-hooks/ext/luajit/dynasm/dasm_mips.lua +953 -0
  56. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.h +419 -0
  57. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.lua +1919 -0
  58. data/lua-hooks/ext/luajit/dynasm/dasm_proto.h +83 -0
  59. data/lua-hooks/ext/luajit/dynasm/dasm_x64.lua +12 -0
  60. data/lua-hooks/ext/luajit/dynasm/dasm_x86.h +471 -0
  61. data/lua-hooks/ext/luajit/dynasm/dasm_x86.lua +1945 -0
  62. data/lua-hooks/ext/luajit/dynasm/dynasm.lua +1094 -0
  63. data/lua-hooks/ext/luajit/etc/luajit.1 +88 -0
  64. data/lua-hooks/ext/luajit/etc/luajit.pc +25 -0
  65. data/lua-hooks/ext/luajit/src/Makefile +697 -0
  66. data/lua-hooks/ext/luajit/src/Makefile.dep +244 -0
  67. data/lua-hooks/ext/luajit/src/host/README +4 -0
  68. data/lua-hooks/ext/luajit/src/host/buildvm +0 -0
  69. data/lua-hooks/ext/luajit/src/host/buildvm.c +518 -0
  70. data/lua-hooks/ext/luajit/src/host/buildvm.h +105 -0
  71. data/lua-hooks/ext/luajit/src/host/buildvm.o +0 -0
  72. data/lua-hooks/ext/luajit/src/host/buildvm_arch.h +7449 -0
  73. data/lua-hooks/ext/luajit/src/host/buildvm_asm.c +345 -0
  74. data/lua-hooks/ext/luajit/src/host/buildvm_asm.o +0 -0
  75. data/lua-hooks/ext/luajit/src/host/buildvm_fold.c +229 -0
  76. data/lua-hooks/ext/luajit/src/host/buildvm_fold.o +0 -0
  77. data/lua-hooks/ext/luajit/src/host/buildvm_lib.c +457 -0
  78. data/lua-hooks/ext/luajit/src/host/buildvm_lib.o +0 -0
  79. data/lua-hooks/ext/luajit/src/host/buildvm_libbc.h +45 -0
  80. data/lua-hooks/ext/luajit/src/host/buildvm_peobj.c +368 -0
  81. data/lua-hooks/ext/luajit/src/host/buildvm_peobj.o +0 -0
  82. data/lua-hooks/ext/luajit/src/host/genlibbc.lua +197 -0
  83. data/lua-hooks/ext/luajit/src/host/genminilua.lua +428 -0
  84. data/lua-hooks/ext/luajit/src/host/minilua +0 -0
  85. data/lua-hooks/ext/luajit/src/host/minilua.c +7770 -0
  86. data/lua-hooks/ext/luajit/src/host/minilua.o +0 -0
  87. data/lua-hooks/ext/luajit/src/jit/bc.lua +190 -0
  88. data/lua-hooks/ext/luajit/src/jit/bcsave.lua +661 -0
  89. data/lua-hooks/ext/luajit/src/jit/dis_arm.lua +689 -0
  90. data/lua-hooks/ext/luajit/src/jit/dis_mips.lua +428 -0
  91. data/lua-hooks/ext/luajit/src/jit/dis_mipsel.lua +17 -0
  92. data/lua-hooks/ext/luajit/src/jit/dis_ppc.lua +591 -0
  93. data/lua-hooks/ext/luajit/src/jit/dis_x64.lua +17 -0
  94. data/lua-hooks/ext/luajit/src/jit/dis_x86.lua +838 -0
  95. data/lua-hooks/ext/luajit/src/jit/dump.lua +706 -0
  96. data/lua-hooks/ext/luajit/src/jit/p.lua +310 -0
  97. data/lua-hooks/ext/luajit/src/jit/v.lua +170 -0
  98. data/lua-hooks/ext/luajit/src/jit/vmdef.lua +362 -0
  99. data/lua-hooks/ext/luajit/src/jit/zone.lua +45 -0
  100. data/lua-hooks/ext/{lua → luajit/src}/lauxlib.h +10 -17
  101. data/lua-hooks/ext/luajit/src/lib_aux.c +356 -0
  102. data/lua-hooks/ext/luajit/src/lib_aux.o +0 -0
  103. data/lua-hooks/ext/luajit/src/lib_aux_dyn.o +0 -0
  104. data/lua-hooks/ext/luajit/src/lib_base.c +664 -0
  105. data/lua-hooks/ext/luajit/src/lib_base.o +0 -0
  106. data/lua-hooks/ext/luajit/src/lib_base_dyn.o +0 -0
  107. data/lua-hooks/ext/luajit/src/lib_bit.c +180 -0
  108. data/lua-hooks/ext/luajit/src/lib_bit.o +0 -0
  109. data/lua-hooks/ext/luajit/src/lib_bit_dyn.o +0 -0
  110. data/lua-hooks/ext/luajit/src/lib_debug.c +405 -0
  111. data/lua-hooks/ext/luajit/src/lib_debug.o +0 -0
  112. data/lua-hooks/ext/luajit/src/lib_debug_dyn.o +0 -0
  113. data/lua-hooks/ext/luajit/src/lib_ffi.c +872 -0
  114. data/lua-hooks/ext/luajit/src/lib_ffi.o +0 -0
  115. data/lua-hooks/ext/luajit/src/lib_ffi_dyn.o +0 -0
  116. data/lua-hooks/ext/luajit/src/lib_init.c +55 -0
  117. data/lua-hooks/ext/luajit/src/lib_init.o +0 -0
  118. data/lua-hooks/ext/luajit/src/lib_init_dyn.o +0 -0
  119. data/lua-hooks/ext/luajit/src/lib_io.c +541 -0
  120. data/lua-hooks/ext/luajit/src/lib_io.o +0 -0
  121. data/lua-hooks/ext/luajit/src/lib_io_dyn.o +0 -0
  122. data/lua-hooks/ext/luajit/src/lib_jit.c +767 -0
  123. data/lua-hooks/ext/luajit/src/lib_jit.o +0 -0
  124. data/lua-hooks/ext/luajit/src/lib_jit_dyn.o +0 -0
  125. data/lua-hooks/ext/luajit/src/lib_math.c +230 -0
  126. data/lua-hooks/ext/luajit/src/lib_math.o +0 -0
  127. data/lua-hooks/ext/luajit/src/lib_math_dyn.o +0 -0
  128. data/lua-hooks/ext/luajit/src/lib_os.c +292 -0
  129. data/lua-hooks/ext/luajit/src/lib_os.o +0 -0
  130. data/lua-hooks/ext/luajit/src/lib_os_dyn.o +0 -0
  131. data/lua-hooks/ext/luajit/src/lib_package.c +610 -0
  132. data/lua-hooks/ext/luajit/src/lib_package.o +0 -0
  133. data/lua-hooks/ext/luajit/src/lib_package_dyn.o +0 -0
  134. data/lua-hooks/ext/luajit/src/lib_string.c +752 -0
  135. data/lua-hooks/ext/luajit/src/lib_string.o +0 -0
  136. data/lua-hooks/ext/luajit/src/lib_string_dyn.o +0 -0
  137. data/lua-hooks/ext/luajit/src/lib_table.c +307 -0
  138. data/lua-hooks/ext/luajit/src/lib_table.o +0 -0
  139. data/lua-hooks/ext/luajit/src/lib_table_dyn.o +0 -0
  140. data/lua-hooks/ext/luajit/src/libluajit.a +0 -0
  141. data/lua-hooks/ext/luajit/src/libluajit.so +0 -0
  142. data/lua-hooks/ext/luajit/src/lj.supp +26 -0
  143. data/lua-hooks/ext/luajit/src/lj_alloc.c +1398 -0
  144. data/lua-hooks/ext/luajit/src/lj_alloc.h +17 -0
  145. data/lua-hooks/ext/luajit/src/lj_alloc.o +0 -0
  146. data/lua-hooks/ext/luajit/src/lj_alloc_dyn.o +0 -0
  147. data/lua-hooks/ext/luajit/src/lj_api.c +1210 -0
  148. data/lua-hooks/ext/luajit/src/lj_api.o +0 -0
  149. data/lua-hooks/ext/luajit/src/lj_api_dyn.o +0 -0
  150. data/lua-hooks/ext/luajit/src/lj_arch.h +509 -0
  151. data/lua-hooks/ext/luajit/src/lj_asm.c +2278 -0
  152. data/lua-hooks/ext/luajit/src/lj_asm.h +17 -0
  153. data/lua-hooks/ext/luajit/src/lj_asm.o +0 -0
  154. data/lua-hooks/ext/luajit/src/lj_asm_arm.h +2217 -0
  155. data/lua-hooks/ext/luajit/src/lj_asm_dyn.o +0 -0
  156. data/lua-hooks/ext/luajit/src/lj_asm_mips.h +1833 -0
  157. data/lua-hooks/ext/luajit/src/lj_asm_ppc.h +2015 -0
  158. data/lua-hooks/ext/luajit/src/lj_asm_x86.h +2634 -0
  159. data/lua-hooks/ext/luajit/src/lj_bc.c +14 -0
  160. data/lua-hooks/ext/luajit/src/lj_bc.h +265 -0
  161. data/lua-hooks/ext/luajit/src/lj_bc.o +0 -0
  162. data/lua-hooks/ext/luajit/src/lj_bc_dyn.o +0 -0
  163. data/lua-hooks/ext/luajit/src/lj_bcdef.h +220 -0
  164. data/lua-hooks/ext/luajit/src/lj_bcdump.h +68 -0
  165. data/lua-hooks/ext/luajit/src/lj_bcread.c +457 -0
  166. data/lua-hooks/ext/luajit/src/lj_bcread.o +0 -0
  167. data/lua-hooks/ext/luajit/src/lj_bcread_dyn.o +0 -0
  168. data/lua-hooks/ext/luajit/src/lj_bcwrite.c +361 -0
  169. data/lua-hooks/ext/luajit/src/lj_bcwrite.o +0 -0
  170. data/lua-hooks/ext/luajit/src/lj_bcwrite_dyn.o +0 -0
  171. data/lua-hooks/ext/luajit/src/lj_buf.c +234 -0
  172. data/lua-hooks/ext/luajit/src/lj_buf.h +105 -0
  173. data/lua-hooks/ext/luajit/src/lj_buf.o +0 -0
  174. data/lua-hooks/ext/luajit/src/lj_buf_dyn.o +0 -0
  175. data/lua-hooks/ext/luajit/src/lj_carith.c +429 -0
  176. data/lua-hooks/ext/luajit/src/lj_carith.h +37 -0
  177. data/lua-hooks/ext/luajit/src/lj_carith.o +0 -0
  178. data/lua-hooks/ext/luajit/src/lj_carith_dyn.o +0 -0
  179. data/lua-hooks/ext/luajit/src/lj_ccall.c +984 -0
  180. data/lua-hooks/ext/luajit/src/lj_ccall.h +178 -0
  181. data/lua-hooks/ext/luajit/src/lj_ccall.o +0 -0
  182. data/lua-hooks/ext/luajit/src/lj_ccall_dyn.o +0 -0
  183. data/lua-hooks/ext/luajit/src/lj_ccallback.c +712 -0
  184. data/lua-hooks/ext/luajit/src/lj_ccallback.h +25 -0
  185. data/lua-hooks/ext/luajit/src/lj_ccallback.o +0 -0
  186. data/lua-hooks/ext/luajit/src/lj_ccallback_dyn.o +0 -0
  187. data/lua-hooks/ext/luajit/src/lj_cconv.c +752 -0
  188. data/lua-hooks/ext/luajit/src/lj_cconv.h +70 -0
  189. data/lua-hooks/ext/luajit/src/lj_cconv.o +0 -0
  190. data/lua-hooks/ext/luajit/src/lj_cconv_dyn.o +0 -0
  191. data/lua-hooks/ext/luajit/src/lj_cdata.c +288 -0
  192. data/lua-hooks/ext/luajit/src/lj_cdata.h +76 -0
  193. data/lua-hooks/ext/luajit/src/lj_cdata.o +0 -0
  194. data/lua-hooks/ext/luajit/src/lj_cdata_dyn.o +0 -0
  195. data/lua-hooks/ext/luajit/src/lj_char.c +43 -0
  196. data/lua-hooks/ext/luajit/src/lj_char.h +42 -0
  197. data/lua-hooks/ext/luajit/src/lj_char.o +0 -0
  198. data/lua-hooks/ext/luajit/src/lj_char_dyn.o +0 -0
  199. data/lua-hooks/ext/luajit/src/lj_clib.c +418 -0
  200. data/lua-hooks/ext/luajit/src/lj_clib.h +29 -0
  201. data/lua-hooks/ext/luajit/src/lj_clib.o +0 -0
  202. data/lua-hooks/ext/luajit/src/lj_clib_dyn.o +0 -0
  203. data/lua-hooks/ext/luajit/src/lj_cparse.c +1862 -0
  204. data/lua-hooks/ext/luajit/src/lj_cparse.h +65 -0
  205. data/lua-hooks/ext/luajit/src/lj_cparse.o +0 -0
  206. data/lua-hooks/ext/luajit/src/lj_cparse_dyn.o +0 -0
  207. data/lua-hooks/ext/luajit/src/lj_crecord.c +1834 -0
  208. data/lua-hooks/ext/luajit/src/lj_crecord.h +38 -0
  209. data/lua-hooks/ext/luajit/src/lj_crecord.o +0 -0
  210. data/lua-hooks/ext/luajit/src/lj_crecord_dyn.o +0 -0
  211. data/lua-hooks/ext/luajit/src/lj_ctype.c +635 -0
  212. data/lua-hooks/ext/luajit/src/lj_ctype.h +461 -0
  213. data/lua-hooks/ext/luajit/src/lj_ctype.o +0 -0
  214. data/lua-hooks/ext/luajit/src/lj_ctype_dyn.o +0 -0
  215. data/lua-hooks/ext/luajit/src/lj_debug.c +699 -0
  216. data/lua-hooks/ext/luajit/src/lj_debug.h +65 -0
  217. data/lua-hooks/ext/luajit/src/lj_debug.o +0 -0
  218. data/lua-hooks/ext/luajit/src/lj_debug_dyn.o +0 -0
  219. data/lua-hooks/ext/luajit/src/lj_def.h +365 -0
  220. data/lua-hooks/ext/luajit/src/lj_dispatch.c +557 -0
  221. data/lua-hooks/ext/luajit/src/lj_dispatch.h +138 -0
  222. data/lua-hooks/ext/luajit/src/lj_dispatch.o +0 -0
  223. data/lua-hooks/ext/luajit/src/lj_dispatch_dyn.o +0 -0
  224. data/lua-hooks/ext/luajit/src/lj_emit_arm.h +356 -0
  225. data/lua-hooks/ext/luajit/src/lj_emit_mips.h +211 -0
  226. data/lua-hooks/ext/luajit/src/lj_emit_ppc.h +238 -0
  227. data/lua-hooks/ext/luajit/src/lj_emit_x86.h +462 -0
  228. data/lua-hooks/ext/luajit/src/lj_err.c +794 -0
  229. data/lua-hooks/ext/luajit/src/lj_err.h +41 -0
  230. data/lua-hooks/ext/luajit/src/lj_err.o +0 -0
  231. data/lua-hooks/ext/luajit/src/lj_err_dyn.o +0 -0
  232. data/lua-hooks/ext/luajit/src/lj_errmsg.h +190 -0
  233. data/lua-hooks/ext/luajit/src/lj_ff.h +18 -0
  234. data/lua-hooks/ext/luajit/src/lj_ffdef.h +209 -0
  235. data/lua-hooks/ext/luajit/src/lj_ffrecord.c +1247 -0
  236. data/lua-hooks/ext/luajit/src/lj_ffrecord.h +24 -0
  237. data/lua-hooks/ext/luajit/src/lj_ffrecord.o +0 -0
  238. data/lua-hooks/ext/luajit/src/lj_ffrecord_dyn.o +0 -0
  239. data/lua-hooks/ext/luajit/src/lj_folddef.h +1138 -0
  240. data/lua-hooks/ext/luajit/src/lj_frame.h +259 -0
  241. data/lua-hooks/ext/luajit/src/lj_func.c +185 -0
  242. data/lua-hooks/ext/luajit/src/lj_func.h +24 -0
  243. data/lua-hooks/ext/luajit/src/lj_func.o +0 -0
  244. data/lua-hooks/ext/luajit/src/lj_func_dyn.o +0 -0
  245. data/lua-hooks/ext/luajit/src/lj_gc.c +845 -0
  246. data/lua-hooks/ext/luajit/src/lj_gc.h +134 -0
  247. data/lua-hooks/ext/luajit/src/lj_gc.o +0 -0
  248. data/lua-hooks/ext/luajit/src/lj_gc_dyn.o +0 -0
  249. data/lua-hooks/ext/luajit/src/lj_gdbjit.c +787 -0
  250. data/lua-hooks/ext/luajit/src/lj_gdbjit.h +22 -0
  251. data/lua-hooks/ext/luajit/src/lj_gdbjit.o +0 -0
  252. data/lua-hooks/ext/luajit/src/lj_gdbjit_dyn.o +0 -0
  253. data/lua-hooks/ext/luajit/src/lj_ir.c +505 -0
  254. data/lua-hooks/ext/luajit/src/lj_ir.h +577 -0
  255. data/lua-hooks/ext/luajit/src/lj_ir.o +0 -0
  256. data/lua-hooks/ext/luajit/src/lj_ir_dyn.o +0 -0
  257. data/lua-hooks/ext/luajit/src/lj_ircall.h +321 -0
  258. data/lua-hooks/ext/luajit/src/lj_iropt.h +161 -0
  259. data/lua-hooks/ext/luajit/src/lj_jit.h +440 -0
  260. data/lua-hooks/ext/luajit/src/lj_lex.c +482 -0
  261. data/lua-hooks/ext/luajit/src/lj_lex.h +86 -0
  262. data/lua-hooks/ext/luajit/src/lj_lex.o +0 -0
  263. data/lua-hooks/ext/luajit/src/lj_lex_dyn.o +0 -0
  264. data/lua-hooks/ext/luajit/src/lj_lib.c +303 -0
  265. data/lua-hooks/ext/luajit/src/lj_lib.h +115 -0
  266. data/lua-hooks/ext/luajit/src/lj_lib.o +0 -0
  267. data/lua-hooks/ext/luajit/src/lj_lib_dyn.o +0 -0
  268. data/lua-hooks/ext/luajit/src/lj_libdef.h +414 -0
  269. data/lua-hooks/ext/luajit/src/lj_load.c +168 -0
  270. data/lua-hooks/ext/luajit/src/lj_load.o +0 -0
  271. data/lua-hooks/ext/luajit/src/lj_load_dyn.o +0 -0
  272. data/lua-hooks/ext/luajit/src/lj_mcode.c +386 -0
  273. data/lua-hooks/ext/luajit/src/lj_mcode.h +30 -0
  274. data/lua-hooks/ext/luajit/src/lj_mcode.o +0 -0
  275. data/lua-hooks/ext/luajit/src/lj_mcode_dyn.o +0 -0
  276. data/lua-hooks/ext/luajit/src/lj_meta.c +477 -0
  277. data/lua-hooks/ext/luajit/src/lj_meta.h +38 -0
  278. data/lua-hooks/ext/luajit/src/lj_meta.o +0 -0
  279. data/lua-hooks/ext/luajit/src/lj_meta_dyn.o +0 -0
  280. data/lua-hooks/ext/luajit/src/lj_obj.c +50 -0
  281. data/lua-hooks/ext/luajit/src/lj_obj.h +976 -0
  282. data/lua-hooks/ext/luajit/src/lj_obj.o +0 -0
  283. data/lua-hooks/ext/luajit/src/lj_obj_dyn.o +0 -0
  284. data/lua-hooks/ext/luajit/src/lj_opt_dce.c +78 -0
  285. data/lua-hooks/ext/luajit/src/lj_opt_dce.o +0 -0
  286. data/lua-hooks/ext/luajit/src/lj_opt_dce_dyn.o +0 -0
  287. data/lua-hooks/ext/luajit/src/lj_opt_fold.c +2488 -0
  288. data/lua-hooks/ext/luajit/src/lj_opt_fold.o +0 -0
  289. data/lua-hooks/ext/luajit/src/lj_opt_fold_dyn.o +0 -0
  290. data/lua-hooks/ext/luajit/src/lj_opt_loop.c +449 -0
  291. data/lua-hooks/ext/luajit/src/lj_opt_loop.o +0 -0
  292. data/lua-hooks/ext/luajit/src/lj_opt_loop_dyn.o +0 -0
  293. data/lua-hooks/ext/luajit/src/lj_opt_mem.c +935 -0
  294. data/lua-hooks/ext/luajit/src/lj_opt_mem.o +0 -0
  295. data/lua-hooks/ext/luajit/src/lj_opt_mem_dyn.o +0 -0
  296. data/lua-hooks/ext/luajit/src/lj_opt_narrow.c +652 -0
  297. data/lua-hooks/ext/luajit/src/lj_opt_narrow.o +0 -0
  298. data/lua-hooks/ext/luajit/src/lj_opt_narrow_dyn.o +0 -0
  299. data/lua-hooks/ext/luajit/src/lj_opt_sink.c +245 -0
  300. data/lua-hooks/ext/luajit/src/lj_opt_sink.o +0 -0
  301. data/lua-hooks/ext/luajit/src/lj_opt_sink_dyn.o +0 -0
  302. data/lua-hooks/ext/luajit/src/lj_opt_split.c +856 -0
  303. data/lua-hooks/ext/luajit/src/lj_opt_split.o +0 -0
  304. data/lua-hooks/ext/luajit/src/lj_opt_split_dyn.o +0 -0
  305. data/lua-hooks/ext/luajit/src/lj_parse.c +2725 -0
  306. data/lua-hooks/ext/luajit/src/lj_parse.h +18 -0
  307. data/lua-hooks/ext/luajit/src/lj_parse.o +0 -0
  308. data/lua-hooks/ext/luajit/src/lj_parse_dyn.o +0 -0
  309. data/lua-hooks/ext/luajit/src/lj_profile.c +368 -0
  310. data/lua-hooks/ext/luajit/src/lj_profile.h +21 -0
  311. data/lua-hooks/ext/luajit/src/lj_profile.o +0 -0
  312. data/lua-hooks/ext/luajit/src/lj_profile_dyn.o +0 -0
  313. data/lua-hooks/ext/luajit/src/lj_recdef.h +270 -0
  314. data/lua-hooks/ext/luajit/src/lj_record.c +2554 -0
  315. data/lua-hooks/ext/luajit/src/lj_record.h +45 -0
  316. data/lua-hooks/ext/luajit/src/lj_record.o +0 -0
  317. data/lua-hooks/ext/luajit/src/lj_record_dyn.o +0 -0
  318. data/lua-hooks/ext/luajit/src/lj_snap.c +870 -0
  319. data/lua-hooks/ext/luajit/src/lj_snap.h +34 -0
  320. data/lua-hooks/ext/luajit/src/lj_snap.o +0 -0
  321. data/lua-hooks/ext/luajit/src/lj_snap_dyn.o +0 -0
  322. data/lua-hooks/ext/luajit/src/lj_state.c +300 -0
  323. data/lua-hooks/ext/luajit/src/lj_state.h +35 -0
  324. data/lua-hooks/ext/luajit/src/lj_state.o +0 -0
  325. data/lua-hooks/ext/luajit/src/lj_state_dyn.o +0 -0
  326. data/lua-hooks/ext/luajit/src/lj_str.c +197 -0
  327. data/lua-hooks/ext/luajit/src/lj_str.h +27 -0
  328. data/lua-hooks/ext/luajit/src/lj_str.o +0 -0
  329. data/lua-hooks/ext/luajit/src/lj_str_dyn.o +0 -0
  330. data/lua-hooks/ext/luajit/src/lj_strfmt.c +554 -0
  331. data/lua-hooks/ext/luajit/src/lj_strfmt.h +125 -0
  332. data/lua-hooks/ext/luajit/src/lj_strfmt.o +0 -0
  333. data/lua-hooks/ext/luajit/src/lj_strfmt_dyn.o +0 -0
  334. data/lua-hooks/ext/luajit/src/lj_strscan.c +547 -0
  335. data/lua-hooks/ext/luajit/src/lj_strscan.h +39 -0
  336. data/lua-hooks/ext/luajit/src/lj_strscan.o +0 -0
  337. data/lua-hooks/ext/luajit/src/lj_strscan_dyn.o +0 -0
  338. data/lua-hooks/ext/luajit/src/lj_tab.c +666 -0
  339. data/lua-hooks/ext/luajit/src/lj_tab.h +73 -0
  340. data/lua-hooks/ext/luajit/src/lj_tab.o +0 -0
  341. data/lua-hooks/ext/luajit/src/lj_tab_dyn.o +0 -0
  342. data/lua-hooks/ext/luajit/src/lj_target.h +164 -0
  343. data/lua-hooks/ext/luajit/src/lj_target_arm.h +270 -0
  344. data/lua-hooks/ext/luajit/src/lj_target_arm64.h +97 -0
  345. data/lua-hooks/ext/luajit/src/lj_target_mips.h +260 -0
  346. data/lua-hooks/ext/luajit/src/lj_target_ppc.h +280 -0
  347. data/lua-hooks/ext/luajit/src/lj_target_x86.h +345 -0
  348. data/lua-hooks/ext/luajit/src/lj_trace.c +859 -0
  349. data/lua-hooks/ext/luajit/src/lj_trace.h +54 -0
  350. data/lua-hooks/ext/luajit/src/lj_trace.o +0 -0
  351. data/lua-hooks/ext/luajit/src/lj_trace_dyn.o +0 -0
  352. data/lua-hooks/ext/luajit/src/lj_traceerr.h +63 -0
  353. data/lua-hooks/ext/luajit/src/lj_udata.c +34 -0
  354. data/lua-hooks/ext/luajit/src/lj_udata.h +14 -0
  355. data/lua-hooks/ext/luajit/src/lj_udata.o +0 -0
  356. data/lua-hooks/ext/luajit/src/lj_udata_dyn.o +0 -0
  357. data/lua-hooks/ext/luajit/src/lj_vm.S +2730 -0
  358. data/lua-hooks/ext/luajit/src/lj_vm.h +114 -0
  359. data/lua-hooks/ext/luajit/src/lj_vm.o +0 -0
  360. data/lua-hooks/ext/luajit/src/lj_vm_dyn.o +0 -0
  361. data/lua-hooks/ext/luajit/src/lj_vmevent.c +58 -0
  362. data/lua-hooks/ext/luajit/src/lj_vmevent.h +59 -0
  363. data/lua-hooks/ext/luajit/src/lj_vmevent.o +0 -0
  364. data/lua-hooks/ext/luajit/src/lj_vmevent_dyn.o +0 -0
  365. data/lua-hooks/ext/luajit/src/lj_vmmath.c +152 -0
  366. data/lua-hooks/ext/luajit/src/lj_vmmath.o +0 -0
  367. data/lua-hooks/ext/luajit/src/lj_vmmath_dyn.o +0 -0
  368. data/lua-hooks/ext/luajit/src/ljamalg.c +96 -0
  369. data/lua-hooks/ext/{lua → luajit/src}/lua.h +12 -7
  370. data/lua-hooks/ext/luajit/src/lua.hpp +9 -0
  371. data/lua-hooks/ext/luajit/src/luaconf.h +156 -0
  372. data/lua-hooks/ext/luajit/src/luajit +0 -0
  373. data/lua-hooks/ext/luajit/src/luajit.c +570 -0
  374. data/lua-hooks/ext/luajit/src/luajit.h +79 -0
  375. data/lua-hooks/ext/luajit/src/luajit.o +0 -0
  376. data/lua-hooks/ext/luajit/src/lualib.h +43 -0
  377. data/lua-hooks/ext/luajit/src/msvcbuild.bat +114 -0
  378. data/lua-hooks/ext/luajit/src/ps4build.bat +103 -0
  379. data/lua-hooks/ext/luajit/src/psvitabuild.bat +93 -0
  380. data/lua-hooks/ext/luajit/src/vm_arm.dasc +4585 -0
  381. data/lua-hooks/ext/luajit/src/vm_arm64.dasc +3764 -0
  382. data/lua-hooks/ext/luajit/src/vm_mips.dasc +4355 -0
  383. data/lua-hooks/ext/luajit/src/vm_ppc.dasc +5252 -0
  384. data/lua-hooks/ext/luajit/src/vm_x64.dasc +4902 -0
  385. data/lua-hooks/ext/luajit/src/vm_x86.dasc +5710 -0
  386. data/lua-hooks/ext/luajit/src/xb1build.bat +101 -0
  387. data/lua-hooks/ext/luajit/src/xedkbuild.bat +92 -0
  388. data/lua-hooks/ext/luautf8/lutf8lib.c +3 -3
  389. data/lua-hooks/lib/boot.lua +37 -2
  390. metadata +372 -69
  391. data/lua-hooks/ext/bitop/README +0 -22
  392. data/lua-hooks/ext/bitop/bit.c +0 -189
  393. data/lua-hooks/ext/extconf.rb +0 -38
  394. data/lua-hooks/ext/lua/COPYRIGHT +0 -34
  395. data/lua-hooks/ext/lua/lapi.c +0 -1087
  396. data/lua-hooks/ext/lua/lapi.h +0 -16
  397. data/lua-hooks/ext/lua/lauxlib.c +0 -652
  398. data/lua-hooks/ext/lua/lbaselib.c +0 -659
  399. data/lua-hooks/ext/lua/lcode.c +0 -831
  400. data/lua-hooks/ext/lua/lcode.h +0 -76
  401. data/lua-hooks/ext/lua/ldblib.c +0 -398
  402. data/lua-hooks/ext/lua/ldebug.c +0 -638
  403. data/lua-hooks/ext/lua/ldebug.h +0 -33
  404. data/lua-hooks/ext/lua/ldo.c +0 -519
  405. data/lua-hooks/ext/lua/ldo.h +0 -57
  406. data/lua-hooks/ext/lua/ldump.c +0 -164
  407. data/lua-hooks/ext/lua/lfunc.c +0 -174
  408. data/lua-hooks/ext/lua/lfunc.h +0 -34
  409. data/lua-hooks/ext/lua/lgc.c +0 -710
  410. data/lua-hooks/ext/lua/lgc.h +0 -110
  411. data/lua-hooks/ext/lua/linit.c +0 -38
  412. data/lua-hooks/ext/lua/liolib.c +0 -556
  413. data/lua-hooks/ext/lua/llex.c +0 -463
  414. data/lua-hooks/ext/lua/llex.h +0 -81
  415. data/lua-hooks/ext/lua/llimits.h +0 -128
  416. data/lua-hooks/ext/lua/lmathlib.c +0 -263
  417. data/lua-hooks/ext/lua/lmem.c +0 -86
  418. data/lua-hooks/ext/lua/lmem.h +0 -49
  419. data/lua-hooks/ext/lua/loadlib.c +0 -705
  420. data/lua-hooks/ext/lua/loadlib_rel.c +0 -760
  421. data/lua-hooks/ext/lua/lobject.c +0 -214
  422. data/lua-hooks/ext/lua/lobject.h +0 -381
  423. data/lua-hooks/ext/lua/lopcodes.c +0 -102
  424. data/lua-hooks/ext/lua/lopcodes.h +0 -268
  425. data/lua-hooks/ext/lua/loslib.c +0 -243
  426. data/lua-hooks/ext/lua/lparser.c +0 -1339
  427. data/lua-hooks/ext/lua/lparser.h +0 -82
  428. data/lua-hooks/ext/lua/lstate.c +0 -214
  429. data/lua-hooks/ext/lua/lstate.h +0 -169
  430. data/lua-hooks/ext/lua/lstring.c +0 -111
  431. data/lua-hooks/ext/lua/lstring.h +0 -31
  432. data/lua-hooks/ext/lua/lstrlib.c +0 -871
  433. data/lua-hooks/ext/lua/ltable.c +0 -588
  434. data/lua-hooks/ext/lua/ltable.h +0 -40
  435. data/lua-hooks/ext/lua/ltablib.c +0 -287
  436. data/lua-hooks/ext/lua/ltm.c +0 -75
  437. data/lua-hooks/ext/lua/ltm.h +0 -54
  438. data/lua-hooks/ext/lua/lua.c +0 -392
  439. data/lua-hooks/ext/lua/lua.def +0 -131
  440. data/lua-hooks/ext/lua/lua.rc +0 -28
  441. data/lua-hooks/ext/lua/lua_dll.rc +0 -26
  442. data/lua-hooks/ext/lua/luac.c +0 -200
  443. data/lua-hooks/ext/lua/luac.rc +0 -1
  444. data/lua-hooks/ext/lua/luaconf.h +0 -763
  445. data/lua-hooks/ext/lua/luaconf.h.in +0 -724
  446. data/lua-hooks/ext/lua/luaconf.h.orig +0 -763
  447. data/lua-hooks/ext/lua/lualib.h +0 -53
  448. data/lua-hooks/ext/lua/lundump.c +0 -227
  449. data/lua-hooks/ext/lua/lundump.h +0 -36
  450. data/lua-hooks/ext/lua/lvm.c +0 -767
  451. data/lua-hooks/ext/lua/lvm.h +0 -36
  452. data/lua-hooks/ext/lua/lzio.c +0 -82
  453. data/lua-hooks/ext/lua/lzio.h +0 -67
  454. data/lua-hooks/ext/lua/print.c +0 -227
@@ -0,0 +1,22 @@
1
+ /*
2
+ ** Client for the GDB JIT API.
3
+ ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
4
+ */
5
+
6
+ #ifndef _LJ_GDBJIT_H
7
+ #define _LJ_GDBJIT_H
8
+
9
+ #include "lj_obj.h"
10
+ #include "lj_jit.h"
11
+
12
+ #if LJ_HASJIT && defined(LUAJIT_USE_GDBJIT)
13
+
14
+ LJ_FUNC void lj_gdbjit_addtrace(jit_State *J, GCtrace *T);
15
+ LJ_FUNC void lj_gdbjit_deltrace(jit_State *J, GCtrace *T);
16
+
17
+ #else
18
+ #define lj_gdbjit_addtrace(J, T) UNUSED(T)
19
+ #define lj_gdbjit_deltrace(J, T) UNUSED(T)
20
+ #endif
21
+
22
+ #endif
@@ -0,0 +1,505 @@
1
+ /*
2
+ ** SSA IR (Intermediate Representation) emitter.
3
+ ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
4
+ */
5
+
6
+ #define lj_ir_c
7
+ #define LUA_CORE
8
+
9
+ /* For pointers to libc/libm functions. */
10
+ #include <stdio.h>
11
+ #include <math.h>
12
+
13
+ #include "lj_obj.h"
14
+
15
+ #if LJ_HASJIT
16
+
17
+ #include "lj_gc.h"
18
+ #include "lj_buf.h"
19
+ #include "lj_str.h"
20
+ #include "lj_tab.h"
21
+ #include "lj_ir.h"
22
+ #include "lj_jit.h"
23
+ #include "lj_ircall.h"
24
+ #include "lj_iropt.h"
25
+ #include "lj_trace.h"
26
+ #if LJ_HASFFI
27
+ #include "lj_ctype.h"
28
+ #include "lj_cdata.h"
29
+ #include "lj_carith.h"
30
+ #endif
31
+ #include "lj_vm.h"
32
+ #include "lj_strscan.h"
33
+ #include "lj_strfmt.h"
34
+ #include "lj_lib.h"
35
+
36
+ /* Some local macros to save typing. Undef'd at the end. */
37
+ #define IR(ref) (&J->cur.ir[(ref)])
38
+ #define fins (&J->fold.ins)
39
+
40
+ /* Pass IR on to next optimization in chain (FOLD). */
41
+ #define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J))
42
+
43
+ /* -- IR tables ----------------------------------------------------------- */
44
+
45
+ /* IR instruction modes. */
46
+ LJ_DATADEF const uint8_t lj_ir_mode[IR__MAX+1] = {
47
+ IRDEF(IRMODE)
48
+ 0
49
+ };
50
+
51
+ /* IR type sizes. */
52
+ LJ_DATADEF const uint8_t lj_ir_type_size[IRT__MAX+1] = {
53
+ #define IRTSIZE(name, size) size,
54
+ IRTDEF(IRTSIZE)
55
+ #undef IRTSIZE
56
+ 0
57
+ };
58
+
59
+ /* C call info for CALL* instructions. */
60
+ LJ_DATADEF const CCallInfo lj_ir_callinfo[] = {
61
+ #define IRCALLCI(cond, name, nargs, kind, type, flags) \
62
+ { (ASMFunction)IRCALLCOND_##cond(name), \
63
+ (nargs)|(CCI_CALL_##kind)|(IRT_##type<<CCI_OTSHIFT)|(flags) },
64
+ IRCALLDEF(IRCALLCI)
65
+ #undef IRCALLCI
66
+ { NULL, 0 }
67
+ };
68
+
69
+ /* -- IR emitter ---------------------------------------------------------- */
70
+
71
+ /* Grow IR buffer at the top. */
72
+ void LJ_FASTCALL lj_ir_growtop(jit_State *J)
73
+ {
74
+ IRIns *baseir = J->irbuf + J->irbotlim;
75
+ MSize szins = J->irtoplim - J->irbotlim;
76
+ if (szins) {
77
+ baseir = (IRIns *)lj_mem_realloc(J->L, baseir, szins*sizeof(IRIns),
78
+ 2*szins*sizeof(IRIns));
79
+ J->irtoplim = J->irbotlim + 2*szins;
80
+ } else {
81
+ baseir = (IRIns *)lj_mem_realloc(J->L, NULL, 0, LJ_MIN_IRSZ*sizeof(IRIns));
82
+ J->irbotlim = REF_BASE - LJ_MIN_IRSZ/4;
83
+ J->irtoplim = J->irbotlim + LJ_MIN_IRSZ;
84
+ }
85
+ J->cur.ir = J->irbuf = baseir - J->irbotlim;
86
+ }
87
+
88
+ /* Grow IR buffer at the bottom or shift it up. */
89
+ static void lj_ir_growbot(jit_State *J)
90
+ {
91
+ IRIns *baseir = J->irbuf + J->irbotlim;
92
+ MSize szins = J->irtoplim - J->irbotlim;
93
+ lua_assert(szins != 0);
94
+ lua_assert(J->cur.nk == J->irbotlim);
95
+ if (J->cur.nins + (szins >> 1) < J->irtoplim) {
96
+ /* More than half of the buffer is free on top: shift up by a quarter. */
97
+ MSize ofs = szins >> 2;
98
+ memmove(baseir + ofs, baseir, (J->cur.nins - J->irbotlim)*sizeof(IRIns));
99
+ J->irbotlim -= ofs;
100
+ J->irtoplim -= ofs;
101
+ J->cur.ir = J->irbuf = baseir - J->irbotlim;
102
+ } else {
103
+ /* Double the buffer size, but split the growth amongst top/bottom. */
104
+ IRIns *newbase = lj_mem_newt(J->L, 2*szins*sizeof(IRIns), IRIns);
105
+ MSize ofs = szins >= 256 ? 128 : (szins >> 1); /* Limit bottom growth. */
106
+ memcpy(newbase + ofs, baseir, (J->cur.nins - J->irbotlim)*sizeof(IRIns));
107
+ lj_mem_free(G(J->L), baseir, szins*sizeof(IRIns));
108
+ J->irbotlim -= ofs;
109
+ J->irtoplim = J->irbotlim + 2*szins;
110
+ J->cur.ir = J->irbuf = newbase - J->irbotlim;
111
+ }
112
+ }
113
+
114
+ /* Emit IR without any optimizations. */
115
+ TRef LJ_FASTCALL lj_ir_emit(jit_State *J)
116
+ {
117
+ IRRef ref = lj_ir_nextins(J);
118
+ IRIns *ir = IR(ref);
119
+ IROp op = fins->o;
120
+ ir->prev = J->chain[op];
121
+ J->chain[op] = (IRRef1)ref;
122
+ ir->o = op;
123
+ ir->op1 = fins->op1;
124
+ ir->op2 = fins->op2;
125
+ J->guardemit.irt |= fins->t.irt;
126
+ return TREF(ref, irt_t((ir->t = fins->t)));
127
+ }
128
+
129
+ /* Emit call to a C function. */
130
+ TRef lj_ir_call(jit_State *J, IRCallID id, ...)
131
+ {
132
+ const CCallInfo *ci = &lj_ir_callinfo[id];
133
+ uint32_t n = CCI_NARGS(ci);
134
+ TRef tr = TREF_NIL;
135
+ va_list argp;
136
+ va_start(argp, id);
137
+ if ((ci->flags & CCI_L)) n--;
138
+ if (n > 0)
139
+ tr = va_arg(argp, IRRef);
140
+ while (n-- > 1)
141
+ tr = emitir(IRT(IR_CARG, IRT_NIL), tr, va_arg(argp, IRRef));
142
+ va_end(argp);
143
+ if (CCI_OP(ci) == IR_CALLS)
144
+ J->needsnap = 1; /* Need snapshot after call with side effect. */
145
+ return emitir(CCI_OPTYPE(ci), tr, id);
146
+ }
147
+
148
+ /* -- Interning of constants ---------------------------------------------- */
149
+
150
+ /*
151
+ ** IR instructions for constants are kept between J->cur.nk >= ref < REF_BIAS.
152
+ ** They are chained like all other instructions, but grow downwards.
153
+ ** The are interned (like strings in the VM) to facilitate reference
154
+ ** comparisons. The same constant must get the same reference.
155
+ */
156
+
157
+ /* Get ref of next IR constant and optionally grow IR.
158
+ ** Note: this may invalidate all IRIns *!
159
+ */
160
+ static LJ_AINLINE IRRef ir_nextk(jit_State *J)
161
+ {
162
+ IRRef ref = J->cur.nk;
163
+ if (LJ_UNLIKELY(ref <= J->irbotlim)) lj_ir_growbot(J);
164
+ J->cur.nk = --ref;
165
+ return ref;
166
+ }
167
+
168
+ /* Intern int32_t constant. */
169
+ TRef LJ_FASTCALL lj_ir_kint(jit_State *J, int32_t k)
170
+ {
171
+ IRIns *ir, *cir = J->cur.ir;
172
+ IRRef ref;
173
+ for (ref = J->chain[IR_KINT]; ref; ref = cir[ref].prev)
174
+ if (cir[ref].i == k)
175
+ goto found;
176
+ ref = ir_nextk(J);
177
+ ir = IR(ref);
178
+ ir->i = k;
179
+ ir->t.irt = IRT_INT;
180
+ ir->o = IR_KINT;
181
+ ir->prev = J->chain[IR_KINT];
182
+ J->chain[IR_KINT] = (IRRef1)ref;
183
+ found:
184
+ return TREF(ref, IRT_INT);
185
+ }
186
+
187
+ /* The MRef inside the KNUM/KINT64 IR instructions holds the address of the
188
+ ** 64 bit constant. The constants themselves are stored in a chained array
189
+ ** and shared across traces.
190
+ **
191
+ ** Rationale for choosing this data structure:
192
+ ** - The address of the constants is embedded in the generated machine code
193
+ ** and must never move. A resizable array or hash table wouldn't work.
194
+ ** - Most apps need very few non-32 bit integer constants (less than a dozen).
195
+ ** - Linear search is hard to beat in terms of speed and low complexity.
196
+ */
197
+ typedef struct K64Array {
198
+ MRef next; /* Pointer to next list. */
199
+ MSize numk; /* Number of used elements in this array. */
200
+ TValue k[LJ_MIN_K64SZ]; /* Array of constants. */
201
+ } K64Array;
202
+
203
+ /* Free all chained arrays. */
204
+ void lj_ir_k64_freeall(jit_State *J)
205
+ {
206
+ K64Array *k;
207
+ for (k = mref(J->k64, K64Array); k; ) {
208
+ K64Array *next = mref(k->next, K64Array);
209
+ lj_mem_free(J2G(J), k, sizeof(K64Array));
210
+ k = next;
211
+ }
212
+ }
213
+
214
+ /* Find 64 bit constant in chained array or add it. */
215
+ cTValue *lj_ir_k64_find(jit_State *J, uint64_t u64)
216
+ {
217
+ K64Array *k, *kp = NULL;
218
+ TValue *ntv;
219
+ MSize idx;
220
+ /* Search for the constant in the whole chain of arrays. */
221
+ for (k = mref(J->k64, K64Array); k; k = mref(k->next, K64Array)) {
222
+ kp = k; /* Remember previous element in list. */
223
+ for (idx = 0; idx < k->numk; idx++) { /* Search one array. */
224
+ TValue *tv = &k->k[idx];
225
+ if (tv->u64 == u64) /* Needed for +-0/NaN/absmask. */
226
+ return tv;
227
+ }
228
+ }
229
+ /* Constant was not found, need to add it. */
230
+ if (!(kp && kp->numk < LJ_MIN_K64SZ)) { /* Allocate a new array. */
231
+ K64Array *kn = lj_mem_newt(J->L, sizeof(K64Array), K64Array);
232
+ setmref(kn->next, NULL);
233
+ kn->numk = 0;
234
+ if (kp)
235
+ setmref(kp->next, kn); /* Chain to the end of the list. */
236
+ else
237
+ setmref(J->k64, kn); /* Link first array. */
238
+ kp = kn;
239
+ }
240
+ ntv = &kp->k[kp->numk++]; /* Add to current array. */
241
+ ntv->u64 = u64;
242
+ return ntv;
243
+ }
244
+
245
+ /* Intern 64 bit constant, given by its address. */
246
+ TRef lj_ir_k64(jit_State *J, IROp op, cTValue *tv)
247
+ {
248
+ IRIns *ir, *cir = J->cur.ir;
249
+ IRRef ref;
250
+ IRType t = op == IR_KNUM ? IRT_NUM : IRT_I64;
251
+ for (ref = J->chain[op]; ref; ref = cir[ref].prev)
252
+ if (ir_k64(&cir[ref]) == tv)
253
+ goto found;
254
+ ref = ir_nextk(J);
255
+ ir = IR(ref);
256
+ lua_assert(checkptrGC(tv));
257
+ setmref(ir->ptr, tv);
258
+ ir->t.irt = t;
259
+ ir->o = op;
260
+ ir->prev = J->chain[op];
261
+ J->chain[op] = (IRRef1)ref;
262
+ found:
263
+ return TREF(ref, t);
264
+ }
265
+
266
+ /* Intern FP constant, given by its 64 bit pattern. */
267
+ TRef lj_ir_knum_u64(jit_State *J, uint64_t u64)
268
+ {
269
+ return lj_ir_k64(J, IR_KNUM, lj_ir_k64_find(J, u64));
270
+ }
271
+
272
+ /* Intern 64 bit integer constant. */
273
+ TRef lj_ir_kint64(jit_State *J, uint64_t u64)
274
+ {
275
+ return lj_ir_k64(J, IR_KINT64, lj_ir_k64_find(J, u64));
276
+ }
277
+
278
+ /* Check whether a number is int and return it. -0 is NOT considered an int. */
279
+ static int numistrueint(lua_Number n, int32_t *kp)
280
+ {
281
+ int32_t k = lj_num2int(n);
282
+ if (n == (lua_Number)k) {
283
+ if (kp) *kp = k;
284
+ if (k == 0) { /* Special check for -0. */
285
+ TValue tv;
286
+ setnumV(&tv, n);
287
+ if (tv.u32.hi != 0)
288
+ return 0;
289
+ }
290
+ return 1;
291
+ }
292
+ return 0;
293
+ }
294
+
295
+ /* Intern number as int32_t constant if possible, otherwise as FP constant. */
296
+ TRef lj_ir_knumint(jit_State *J, lua_Number n)
297
+ {
298
+ int32_t k;
299
+ if (numistrueint(n, &k))
300
+ return lj_ir_kint(J, k);
301
+ else
302
+ return lj_ir_knum(J, n);
303
+ }
304
+
305
+ /* Intern GC object "constant". */
306
+ TRef lj_ir_kgc(jit_State *J, GCobj *o, IRType t)
307
+ {
308
+ IRIns *ir, *cir = J->cur.ir;
309
+ IRRef ref;
310
+ lua_assert(!LJ_GC64); /* TODO_GC64: major changes required. */
311
+ lua_assert(!isdead(J2G(J), o));
312
+ for (ref = J->chain[IR_KGC]; ref; ref = cir[ref].prev)
313
+ if (ir_kgc(&cir[ref]) == o)
314
+ goto found;
315
+ ref = ir_nextk(J);
316
+ ir = IR(ref);
317
+ /* NOBARRIER: Current trace is a GC root. */
318
+ setgcref(ir->gcr, o);
319
+ ir->t.irt = (uint8_t)t;
320
+ ir->o = IR_KGC;
321
+ ir->prev = J->chain[IR_KGC];
322
+ J->chain[IR_KGC] = (IRRef1)ref;
323
+ found:
324
+ return TREF(ref, t);
325
+ }
326
+
327
+ /* Intern 32 bit pointer constant. */
328
+ TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr)
329
+ {
330
+ IRIns *ir, *cir = J->cur.ir;
331
+ IRRef ref;
332
+ lua_assert((void *)(intptr_t)i32ptr(ptr) == ptr);
333
+ for (ref = J->chain[op]; ref; ref = cir[ref].prev)
334
+ if (mref(cir[ref].ptr, void) == ptr)
335
+ goto found;
336
+ ref = ir_nextk(J);
337
+ ir = IR(ref);
338
+ setmref(ir->ptr, ptr);
339
+ ir->t.irt = IRT_P32;
340
+ ir->o = op;
341
+ ir->prev = J->chain[op];
342
+ J->chain[op] = (IRRef1)ref;
343
+ found:
344
+ return TREF(ref, IRT_P32);
345
+ }
346
+
347
+ /* Intern typed NULL constant. */
348
+ TRef lj_ir_knull(jit_State *J, IRType t)
349
+ {
350
+ IRIns *ir, *cir = J->cur.ir;
351
+ IRRef ref;
352
+ for (ref = J->chain[IR_KNULL]; ref; ref = cir[ref].prev)
353
+ if (irt_t(cir[ref].t) == t)
354
+ goto found;
355
+ ref = ir_nextk(J);
356
+ ir = IR(ref);
357
+ ir->i = 0;
358
+ ir->t.irt = (uint8_t)t;
359
+ ir->o = IR_KNULL;
360
+ ir->prev = J->chain[IR_KNULL];
361
+ J->chain[IR_KNULL] = (IRRef1)ref;
362
+ found:
363
+ return TREF(ref, t);
364
+ }
365
+
366
+ /* Intern key slot. */
367
+ TRef lj_ir_kslot(jit_State *J, TRef key, IRRef slot)
368
+ {
369
+ IRIns *ir, *cir = J->cur.ir;
370
+ IRRef2 op12 = IRREF2((IRRef1)key, (IRRef1)slot);
371
+ IRRef ref;
372
+ /* Const part is not touched by CSE/DCE, so 0-65535 is ok for IRMlit here. */
373
+ lua_assert(tref_isk(key) && slot == (IRRef)(IRRef1)slot);
374
+ for (ref = J->chain[IR_KSLOT]; ref; ref = cir[ref].prev)
375
+ if (cir[ref].op12 == op12)
376
+ goto found;
377
+ ref = ir_nextk(J);
378
+ ir = IR(ref);
379
+ ir->op12 = op12;
380
+ ir->t.irt = IRT_P32;
381
+ ir->o = IR_KSLOT;
382
+ ir->prev = J->chain[IR_KSLOT];
383
+ J->chain[IR_KSLOT] = (IRRef1)ref;
384
+ found:
385
+ return TREF(ref, IRT_P32);
386
+ }
387
+
388
+ /* -- Access to IR constants ---------------------------------------------- */
389
+
390
+ /* Copy value of IR constant. */
391
+ void lj_ir_kvalue(lua_State *L, TValue *tv, const IRIns *ir)
392
+ {
393
+ UNUSED(L);
394
+ lua_assert(ir->o != IR_KSLOT); /* Common mistake. */
395
+ switch (ir->o) {
396
+ case IR_KPRI: setpriV(tv, irt_toitype(ir->t)); break;
397
+ case IR_KINT: setintV(tv, ir->i); break;
398
+ case IR_KGC: setgcV(L, tv, ir_kgc(ir), irt_toitype(ir->t)); break;
399
+ case IR_KPTR: case IR_KKPTR: case IR_KNULL:
400
+ setlightudV(tv, mref(ir->ptr, void));
401
+ break;
402
+ case IR_KNUM: setnumV(tv, ir_knum(ir)->n); break;
403
+ #if LJ_HASFFI
404
+ case IR_KINT64: {
405
+ GCcdata *cd = lj_cdata_new_(L, CTID_INT64, 8);
406
+ *(uint64_t *)cdataptr(cd) = ir_kint64(ir)->u64;
407
+ setcdataV(L, tv, cd);
408
+ break;
409
+ }
410
+ #endif
411
+ default: lua_assert(0); break;
412
+ }
413
+ }
414
+
415
+ /* -- Convert IR operand types -------------------------------------------- */
416
+
417
+ /* Convert from string to number. */
418
+ TRef LJ_FASTCALL lj_ir_tonumber(jit_State *J, TRef tr)
419
+ {
420
+ if (!tref_isnumber(tr)) {
421
+ if (tref_isstr(tr))
422
+ tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0);
423
+ else
424
+ lj_trace_err(J, LJ_TRERR_BADTYPE);
425
+ }
426
+ return tr;
427
+ }
428
+
429
+ /* Convert from integer or string to number. */
430
+ TRef LJ_FASTCALL lj_ir_tonum(jit_State *J, TRef tr)
431
+ {
432
+ if (!tref_isnum(tr)) {
433
+ if (tref_isinteger(tr))
434
+ tr = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT);
435
+ else if (tref_isstr(tr))
436
+ tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0);
437
+ else
438
+ lj_trace_err(J, LJ_TRERR_BADTYPE);
439
+ }
440
+ return tr;
441
+ }
442
+
443
+ /* Convert from integer or number to string. */
444
+ TRef LJ_FASTCALL lj_ir_tostr(jit_State *J, TRef tr)
445
+ {
446
+ if (!tref_isstr(tr)) {
447
+ if (!tref_isnumber(tr))
448
+ lj_trace_err(J, LJ_TRERR_BADTYPE);
449
+ tr = emitir(IRT(IR_TOSTR, IRT_STR), tr,
450
+ tref_isnum(tr) ? IRTOSTR_NUM : IRTOSTR_INT);
451
+ }
452
+ return tr;
453
+ }
454
+
455
+ /* -- Miscellaneous IR ops ------------------------------------------------ */
456
+
457
+ /* Evaluate numeric comparison. */
458
+ int lj_ir_numcmp(lua_Number a, lua_Number b, IROp op)
459
+ {
460
+ switch (op) {
461
+ case IR_EQ: return (a == b);
462
+ case IR_NE: return (a != b);
463
+ case IR_LT: return (a < b);
464
+ case IR_GE: return (a >= b);
465
+ case IR_LE: return (a <= b);
466
+ case IR_GT: return (a > b);
467
+ case IR_ULT: return !(a >= b);
468
+ case IR_UGE: return !(a < b);
469
+ case IR_ULE: return !(a > b);
470
+ case IR_UGT: return !(a <= b);
471
+ default: lua_assert(0); return 0;
472
+ }
473
+ }
474
+
475
+ /* Evaluate string comparison. */
476
+ int lj_ir_strcmp(GCstr *a, GCstr *b, IROp op)
477
+ {
478
+ int res = lj_str_cmp(a, b);
479
+ switch (op) {
480
+ case IR_LT: return (res < 0);
481
+ case IR_GE: return (res >= 0);
482
+ case IR_LE: return (res <= 0);
483
+ case IR_GT: return (res > 0);
484
+ default: lua_assert(0); return 0;
485
+ }
486
+ }
487
+
488
+ /* Rollback IR to previous state. */
489
+ void lj_ir_rollback(jit_State *J, IRRef ref)
490
+ {
491
+ IRRef nins = J->cur.nins;
492
+ while (nins > ref) {
493
+ IRIns *ir;
494
+ nins--;
495
+ ir = IR(nins);
496
+ J->chain[ir->o] = ir->prev;
497
+ }
498
+ J->cur.nins = nins;
499
+ }
500
+
501
+ #undef IR
502
+ #undef fins
503
+ #undef emitir
504
+
505
+ #endif