immunio 1.2.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (291) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -5
  3. data/ext/immunio/Rakefile +14 -6
  4. data/lib/immunio/context.rb +2 -0
  5. data/lib/immunio/plugins/action_view.rb +7 -668
  6. data/lib/immunio/plugins/action_view/action_view.rb +22 -0
  7. data/lib/immunio/plugins/action_view/active_support_hash.rb +29 -0
  8. data/lib/immunio/plugins/action_view/cache_store.rb +24 -0
  9. data/lib/immunio/plugins/action_view/erubi.rb +38 -0
  10. data/lib/immunio/plugins/action_view/erubis.rb +39 -0
  11. data/lib/immunio/plugins/action_view/fragment_caching.rb +29 -0
  12. data/lib/immunio/plugins/action_view/haml.rb +46 -0
  13. data/lib/immunio/plugins/action_view/slim.rb +42 -0
  14. data/lib/immunio/plugins/action_view/template.rb +431 -0
  15. data/lib/immunio/plugins/action_view/template_rendering.rb +45 -0
  16. data/lib/immunio/plugins/http_tracker.rb +2 -0
  17. data/lib/immunio/plugins/io.rb +34 -0
  18. data/lib/immunio/version.rb +1 -1
  19. data/lua-hooks/Makefile +36 -9
  20. data/lua-hooks/ext/luajit/COPYRIGHT +1 -1
  21. data/lua-hooks/ext/luajit/Makefile +22 -15
  22. data/lua-hooks/ext/luajit/README +2 -2
  23. data/lua-hooks/ext/luajit/doc/bluequad-print.css +1 -1
  24. data/lua-hooks/ext/luajit/doc/bluequad.css +1 -1
  25. data/lua-hooks/ext/luajit/doc/changes.html +69 -3
  26. data/lua-hooks/ext/luajit/doc/contact.html +10 -3
  27. data/lua-hooks/ext/luajit/doc/ext_c_api.html +2 -2
  28. data/lua-hooks/ext/luajit/doc/ext_ffi.html +2 -2
  29. data/lua-hooks/ext/luajit/doc/ext_ffi_api.html +2 -2
  30. data/lua-hooks/ext/luajit/doc/ext_ffi_semantics.html +3 -4
  31. data/lua-hooks/ext/luajit/doc/ext_ffi_tutorial.html +2 -2
  32. data/lua-hooks/ext/luajit/doc/ext_jit.html +3 -3
  33. data/lua-hooks/ext/luajit/doc/ext_profiler.html +2 -2
  34. data/lua-hooks/ext/luajit/doc/extensions.html +47 -20
  35. data/lua-hooks/ext/luajit/doc/faq.html +2 -2
  36. data/lua-hooks/ext/luajit/doc/install.html +74 -45
  37. data/lua-hooks/ext/luajit/doc/luajit.html +5 -5
  38. data/lua-hooks/ext/luajit/doc/running.html +3 -3
  39. data/lua-hooks/ext/luajit/doc/status.html +13 -8
  40. data/lua-hooks/ext/luajit/dynasm/dasm_arm.h +1 -1
  41. data/lua-hooks/ext/luajit/dynasm/dasm_arm.lua +1 -1
  42. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.h +1 -1
  43. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.lua +1 -1
  44. data/lua-hooks/ext/luajit/dynasm/dasm_mips.h +8 -5
  45. data/lua-hooks/ext/luajit/dynasm/dasm_mips.lua +66 -11
  46. data/lua-hooks/ext/luajit/dynasm/dasm_mips64.lua +12 -0
  47. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.h +1 -1
  48. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.lua +1 -1
  49. data/lua-hooks/ext/luajit/dynasm/dasm_proto.h +1 -1
  50. data/lua-hooks/ext/luajit/dynasm/dasm_x64.lua +1 -1
  51. data/lua-hooks/ext/luajit/dynasm/dasm_x86.h +1 -1
  52. data/lua-hooks/ext/luajit/dynasm/dasm_x86.lua +5 -1
  53. data/lua-hooks/ext/luajit/dynasm/dynasm.lua +2 -2
  54. data/lua-hooks/ext/luajit/etc/luajit.1 +1 -1
  55. data/lua-hooks/ext/luajit/etc/luajit.pc +1 -1
  56. data/lua-hooks/ext/luajit/src/Makefile +15 -11
  57. data/lua-hooks/ext/luajit/src/Makefile.dep +16 -16
  58. data/lua-hooks/ext/luajit/src/host/buildvm.c +2 -2
  59. data/lua-hooks/ext/luajit/src/host/buildvm.h +1 -1
  60. data/lua-hooks/ext/luajit/src/host/buildvm_asm.c +9 -4
  61. data/lua-hooks/ext/luajit/src/host/buildvm_fold.c +2 -2
  62. data/lua-hooks/ext/luajit/src/host/buildvm_lib.c +1 -1
  63. data/lua-hooks/ext/luajit/src/host/buildvm_libbc.h +14 -3
  64. data/lua-hooks/ext/luajit/src/host/buildvm_peobj.c +27 -3
  65. data/lua-hooks/ext/luajit/src/host/genlibbc.lua +1 -1
  66. data/lua-hooks/ext/luajit/src/host/genminilua.lua +6 -5
  67. data/lua-hooks/ext/luajit/src/host/minilua.c +1 -1
  68. data/lua-hooks/ext/luajit/src/jit/bc.lua +1 -1
  69. data/lua-hooks/ext/luajit/src/jit/bcsave.lua +8 -8
  70. data/lua-hooks/ext/luajit/src/jit/dis_arm.lua +2 -2
  71. data/lua-hooks/ext/luajit/src/jit/dis_arm64.lua +1216 -0
  72. data/lua-hooks/ext/luajit/src/jit/dis_arm64be.lua +12 -0
  73. data/lua-hooks/ext/luajit/src/jit/dis_mips.lua +35 -20
  74. data/lua-hooks/ext/luajit/src/jit/dis_mips64.lua +17 -0
  75. data/lua-hooks/ext/luajit/src/jit/dis_mips64el.lua +17 -0
  76. data/lua-hooks/ext/luajit/src/jit/dis_mipsel.lua +1 -1
  77. data/lua-hooks/ext/luajit/src/jit/dis_ppc.lua +2 -2
  78. data/lua-hooks/ext/luajit/src/jit/dis_x64.lua +1 -1
  79. data/lua-hooks/ext/luajit/src/jit/dis_x86.lua +7 -4
  80. data/lua-hooks/ext/luajit/src/jit/dump.lua +17 -12
  81. data/lua-hooks/ext/luajit/src/jit/p.lua +3 -2
  82. data/lua-hooks/ext/luajit/src/jit/v.lua +2 -2
  83. data/lua-hooks/ext/luajit/src/jit/zone.lua +1 -1
  84. data/lua-hooks/ext/luajit/src/lauxlib.h +14 -20
  85. data/lua-hooks/ext/luajit/src/lib_aux.c +38 -27
  86. data/lua-hooks/ext/luajit/src/lib_base.c +12 -5
  87. data/lua-hooks/ext/luajit/src/lib_bit.c +1 -1
  88. data/lua-hooks/ext/luajit/src/lib_debug.c +5 -5
  89. data/lua-hooks/ext/luajit/src/lib_ffi.c +2 -2
  90. data/lua-hooks/ext/luajit/src/lib_init.c +16 -16
  91. data/lua-hooks/ext/luajit/src/lib_io.c +6 -7
  92. data/lua-hooks/ext/luajit/src/lib_jit.c +14 -4
  93. data/lua-hooks/ext/luajit/src/lib_math.c +1 -5
  94. data/lua-hooks/ext/luajit/src/lib_os.c +1 -1
  95. data/lua-hooks/ext/luajit/src/lib_package.c +14 -23
  96. data/lua-hooks/ext/luajit/src/lib_string.c +1 -5
  97. data/lua-hooks/ext/luajit/src/lib_table.c +21 -1
  98. data/lua-hooks/ext/luajit/src/lj.supp +3 -3
  99. data/lua-hooks/ext/luajit/src/lj_alloc.c +174 -83
  100. data/lua-hooks/ext/luajit/src/lj_api.c +97 -18
  101. data/lua-hooks/ext/luajit/src/lj_arch.h +54 -22
  102. data/lua-hooks/ext/luajit/src/lj_asm.c +172 -53
  103. data/lua-hooks/ext/luajit/src/lj_asm.h +1 -1
  104. data/lua-hooks/ext/luajit/src/lj_asm_arm.h +19 -16
  105. data/lua-hooks/ext/luajit/src/lj_asm_arm64.h +2022 -0
  106. data/lua-hooks/ext/luajit/src/lj_asm_mips.h +564 -158
  107. data/lua-hooks/ext/luajit/src/lj_asm_ppc.h +19 -18
  108. data/lua-hooks/ext/luajit/src/lj_asm_x86.h +578 -92
  109. data/lua-hooks/ext/luajit/src/lj_bc.c +1 -1
  110. data/lua-hooks/ext/luajit/src/lj_bc.h +1 -1
  111. data/lua-hooks/ext/luajit/src/lj_bcdump.h +1 -1
  112. data/lua-hooks/ext/luajit/src/lj_bcread.c +1 -1
  113. data/lua-hooks/ext/luajit/src/lj_bcwrite.c +1 -1
  114. data/lua-hooks/ext/luajit/src/lj_buf.c +1 -1
  115. data/lua-hooks/ext/luajit/src/lj_buf.h +1 -1
  116. data/lua-hooks/ext/luajit/src/lj_carith.c +1 -1
  117. data/lua-hooks/ext/luajit/src/lj_carith.h +1 -1
  118. data/lua-hooks/ext/luajit/src/lj_ccall.c +172 -7
  119. data/lua-hooks/ext/luajit/src/lj_ccall.h +21 -5
  120. data/lua-hooks/ext/luajit/src/lj_ccallback.c +71 -17
  121. data/lua-hooks/ext/luajit/src/lj_ccallback.h +1 -1
  122. data/lua-hooks/ext/luajit/src/lj_cconv.c +4 -2
  123. data/lua-hooks/ext/luajit/src/lj_cconv.h +1 -1
  124. data/lua-hooks/ext/luajit/src/lj_cdata.c +7 -5
  125. data/lua-hooks/ext/luajit/src/lj_cdata.h +1 -1
  126. data/lua-hooks/ext/luajit/src/lj_clib.c +5 -5
  127. data/lua-hooks/ext/luajit/src/lj_clib.h +1 -1
  128. data/lua-hooks/ext/luajit/src/lj_cparse.c +11 -6
  129. data/lua-hooks/ext/luajit/src/lj_cparse.h +1 -1
  130. data/lua-hooks/ext/luajit/src/lj_crecord.c +70 -14
  131. data/lua-hooks/ext/luajit/src/lj_crecord.h +1 -1
  132. data/lua-hooks/ext/luajit/src/lj_ctype.c +1 -1
  133. data/lua-hooks/ext/luajit/src/lj_ctype.h +8 -8
  134. data/lua-hooks/ext/luajit/src/lj_debug.c +1 -1
  135. data/lua-hooks/ext/luajit/src/lj_debug.h +1 -1
  136. data/lua-hooks/ext/luajit/src/lj_def.h +6 -9
  137. data/lua-hooks/ext/luajit/src/lj_dispatch.c +3 -3
  138. data/lua-hooks/ext/luajit/src/lj_dispatch.h +2 -1
  139. data/lua-hooks/ext/luajit/src/lj_emit_arm.h +5 -4
  140. data/lua-hooks/ext/luajit/src/lj_emit_arm64.h +419 -0
  141. data/lua-hooks/ext/luajit/src/lj_emit_mips.h +100 -20
  142. data/lua-hooks/ext/luajit/src/lj_emit_ppc.h +4 -4
  143. data/lua-hooks/ext/luajit/src/lj_emit_x86.h +116 -25
  144. data/lua-hooks/ext/luajit/src/lj_err.c +34 -13
  145. data/lua-hooks/ext/luajit/src/lj_err.h +1 -1
  146. data/lua-hooks/ext/luajit/src/lj_errmsg.h +1 -1
  147. data/lua-hooks/ext/luajit/src/lj_ff.h +1 -1
  148. data/lua-hooks/ext/luajit/src/lj_ffrecord.c +58 -49
  149. data/lua-hooks/ext/luajit/src/lj_ffrecord.h +1 -1
  150. data/lua-hooks/ext/luajit/src/lj_frame.h +33 -6
  151. data/lua-hooks/ext/luajit/src/lj_func.c +4 -2
  152. data/lua-hooks/ext/luajit/src/lj_func.h +1 -1
  153. data/lua-hooks/ext/luajit/src/lj_gc.c +16 -7
  154. data/lua-hooks/ext/luajit/src/lj_gc.h +1 -1
  155. data/lua-hooks/ext/luajit/src/lj_gdbjit.c +31 -1
  156. data/lua-hooks/ext/luajit/src/lj_gdbjit.h +1 -1
  157. data/lua-hooks/ext/luajit/src/lj_ir.c +69 -96
  158. data/lua-hooks/ext/luajit/src/lj_ir.h +29 -18
  159. data/lua-hooks/ext/luajit/src/lj_ircall.h +24 -30
  160. data/lua-hooks/ext/luajit/src/lj_iropt.h +9 -9
  161. data/lua-hooks/ext/luajit/src/lj_jit.h +67 -9
  162. data/lua-hooks/ext/luajit/src/lj_lex.c +1 -1
  163. data/lua-hooks/ext/luajit/src/lj_lex.h +1 -1
  164. data/lua-hooks/ext/luajit/src/lj_lib.c +1 -1
  165. data/lua-hooks/ext/luajit/src/lj_lib.h +1 -1
  166. data/lua-hooks/ext/luajit/src/lj_load.c +1 -1
  167. data/lua-hooks/ext/luajit/src/lj_mcode.c +11 -10
  168. data/lua-hooks/ext/luajit/src/lj_mcode.h +1 -1
  169. data/lua-hooks/ext/luajit/src/lj_meta.c +1 -1
  170. data/lua-hooks/ext/luajit/src/lj_meta.h +1 -1
  171. data/lua-hooks/ext/luajit/src/lj_obj.c +1 -1
  172. data/lua-hooks/ext/luajit/src/lj_obj.h +7 -3
  173. data/lua-hooks/ext/luajit/src/lj_opt_dce.c +1 -1
  174. data/lua-hooks/ext/luajit/src/lj_opt_fold.c +84 -17
  175. data/lua-hooks/ext/luajit/src/lj_opt_loop.c +1 -1
  176. data/lua-hooks/ext/luajit/src/lj_opt_mem.c +3 -3
  177. data/lua-hooks/ext/luajit/src/lj_opt_narrow.c +24 -22
  178. data/lua-hooks/ext/luajit/src/lj_opt_sink.c +11 -6
  179. data/lua-hooks/ext/luajit/src/lj_opt_split.c +11 -2
  180. data/lua-hooks/ext/luajit/src/lj_parse.c +9 -7
  181. data/lua-hooks/ext/luajit/src/lj_parse.h +1 -1
  182. data/lua-hooks/ext/luajit/src/lj_profile.c +1 -1
  183. data/lua-hooks/ext/luajit/src/lj_profile.h +1 -1
  184. data/lua-hooks/ext/luajit/src/lj_record.c +201 -117
  185. data/lua-hooks/ext/luajit/src/lj_record.h +1 -1
  186. data/lua-hooks/ext/luajit/src/lj_snap.c +72 -26
  187. data/lua-hooks/ext/luajit/src/lj_snap.h +1 -1
  188. data/lua-hooks/ext/luajit/src/lj_state.c +6 -6
  189. data/lua-hooks/ext/luajit/src/lj_state.h +2 -2
  190. data/lua-hooks/ext/luajit/src/lj_str.c +1 -1
  191. data/lua-hooks/ext/luajit/src/lj_str.h +1 -1
  192. data/lua-hooks/ext/luajit/src/lj_strfmt.c +7 -3
  193. data/lua-hooks/ext/luajit/src/lj_strfmt.h +1 -1
  194. data/lua-hooks/ext/luajit/src/lj_strfmt_num.c +4 -3
  195. data/lua-hooks/ext/luajit/src/lj_strscan.c +1 -1
  196. data/lua-hooks/ext/luajit/src/lj_strscan.h +1 -1
  197. data/lua-hooks/ext/luajit/src/lj_tab.c +1 -2
  198. data/lua-hooks/ext/luajit/src/lj_tab.h +1 -1
  199. data/lua-hooks/ext/luajit/src/lj_target.h +3 -3
  200. data/lua-hooks/ext/luajit/src/lj_target_arm.h +1 -1
  201. data/lua-hooks/ext/luajit/src/lj_target_arm64.h +239 -7
  202. data/lua-hooks/ext/luajit/src/lj_target_mips.h +111 -22
  203. data/lua-hooks/ext/luajit/src/lj_target_ppc.h +1 -1
  204. data/lua-hooks/ext/luajit/src/lj_target_x86.h +21 -4
  205. data/lua-hooks/ext/luajit/src/lj_trace.c +63 -18
  206. data/lua-hooks/ext/luajit/src/lj_trace.h +2 -1
  207. data/lua-hooks/ext/luajit/src/lj_traceerr.h +1 -1
  208. data/lua-hooks/ext/luajit/src/lj_udata.c +1 -1
  209. data/lua-hooks/ext/luajit/src/lj_udata.h +1 -1
  210. data/lua-hooks/ext/luajit/src/lj_vm.h +5 -1
  211. data/lua-hooks/ext/luajit/src/lj_vmevent.c +1 -1
  212. data/lua-hooks/ext/luajit/src/lj_vmevent.h +1 -1
  213. data/lua-hooks/ext/luajit/src/lj_vmmath.c +1 -1
  214. data/lua-hooks/ext/luajit/src/ljamalg.c +1 -1
  215. data/lua-hooks/ext/luajit/src/lua.h +9 -1
  216. data/lua-hooks/ext/luajit/src/luaconf.h +3 -7
  217. data/lua-hooks/ext/luajit/src/luajit.c +69 -54
  218. data/lua-hooks/ext/luajit/src/luajit.h +4 -4
  219. data/lua-hooks/ext/luajit/src/lualib.h +1 -1
  220. data/lua-hooks/ext/luajit/src/msvcbuild.bat +12 -4
  221. data/lua-hooks/ext/luajit/src/vm_arm.dasc +1 -1
  222. data/lua-hooks/ext/luajit/src/vm_arm64.dasc +255 -32
  223. data/lua-hooks/ext/luajit/src/vm_mips.dasc +26 -23
  224. data/lua-hooks/ext/luajit/src/vm_mips64.dasc +5062 -0
  225. data/lua-hooks/ext/luajit/src/vm_ppc.dasc +1 -1
  226. data/lua-hooks/ext/luajit/src/vm_x64.dasc +24 -25
  227. data/lua-hooks/ext/luajit/src/vm_x86.dasc +77 -4
  228. data/lua-hooks/libluahooks.darwin.a +0 -0
  229. data/lua-hooks/libluahooks.linux.a +0 -0
  230. data/lua-hooks/options.mk +1 -1
  231. metadata +37 -77
  232. data/lua-hooks/ext/all.c +0 -69
  233. data/lua-hooks/ext/libinjection/COPYING +0 -37
  234. data/lua-hooks/ext/libinjection/libinjection.h +0 -65
  235. data/lua-hooks/ext/libinjection/libinjection_html5.c +0 -847
  236. data/lua-hooks/ext/libinjection/libinjection_html5.h +0 -54
  237. data/lua-hooks/ext/libinjection/libinjection_sqli.c +0 -2301
  238. data/lua-hooks/ext/libinjection/libinjection_sqli.h +0 -295
  239. data/lua-hooks/ext/libinjection/libinjection_sqli_data.h +0 -9349
  240. data/lua-hooks/ext/libinjection/libinjection_xss.c +0 -531
  241. data/lua-hooks/ext/libinjection/libinjection_xss.h +0 -21
  242. data/lua-hooks/ext/libinjection/lualib.c +0 -145
  243. data/lua-hooks/ext/libinjection/module.mk +0 -5
  244. data/lua-hooks/ext/lpeg/HISTORY +0 -96
  245. data/lua-hooks/ext/lpeg/lpcap.c +0 -537
  246. data/lua-hooks/ext/lpeg/lpcap.h +0 -56
  247. data/lua-hooks/ext/lpeg/lpcode.c +0 -1014
  248. data/lua-hooks/ext/lpeg/lpcode.h +0 -40
  249. data/lua-hooks/ext/lpeg/lpeg-128.gif +0 -0
  250. data/lua-hooks/ext/lpeg/lpeg.html +0 -1445
  251. data/lua-hooks/ext/lpeg/lpprint.c +0 -244
  252. data/lua-hooks/ext/lpeg/lpprint.h +0 -36
  253. data/lua-hooks/ext/lpeg/lptree.c +0 -1303
  254. data/lua-hooks/ext/lpeg/lptree.h +0 -82
  255. data/lua-hooks/ext/lpeg/lptypes.h +0 -149
  256. data/lua-hooks/ext/lpeg/lpvm.c +0 -364
  257. data/lua-hooks/ext/lpeg/lpvm.h +0 -58
  258. data/lua-hooks/ext/lpeg/makefile +0 -55
  259. data/lua-hooks/ext/lpeg/module.mk +0 -6
  260. data/lua-hooks/ext/lpeg/re.html +0 -498
  261. data/lua-hooks/ext/lua-cmsgpack/.gitignore +0 -13
  262. data/lua-hooks/ext/lua-cmsgpack/CMakeLists.txt +0 -45
  263. data/lua-hooks/ext/lua-cmsgpack/README.md +0 -115
  264. data/lua-hooks/ext/lua-cmsgpack/lua_cmsgpack.c +0 -970
  265. data/lua-hooks/ext/lua-cmsgpack/module.mk +0 -2
  266. data/lua-hooks/ext/lua-cmsgpack/test.lua +0 -570
  267. data/lua-hooks/ext/lua-snapshot/LICENSE +0 -7
  268. data/lua-hooks/ext/lua-snapshot/Makefile +0 -12
  269. data/lua-hooks/ext/lua-snapshot/README.md +0 -18
  270. data/lua-hooks/ext/lua-snapshot/dump.lua +0 -15
  271. data/lua-hooks/ext/lua-snapshot/module.mk +0 -2
  272. data/lua-hooks/ext/lua-snapshot/snapshot.c +0 -462
  273. data/lua-hooks/ext/luautf8/README.md +0 -152
  274. data/lua-hooks/ext/luautf8/lutf8lib.c +0 -1274
  275. data/lua-hooks/ext/luautf8/module.mk +0 -2
  276. data/lua-hooks/ext/luautf8/unidata.h +0 -3064
  277. data/lua-hooks/ext/module.mk +0 -15
  278. data/lua-hooks/ext/modules.h +0 -17
  279. data/lua-hooks/ext/perf/luacpu.c +0 -114
  280. data/lua-hooks/ext/perf/lualoadavg.c +0 -40
  281. data/lua-hooks/ext/perf/luameminfo.c +0 -38
  282. data/lua-hooks/ext/perf/luaoslib.c +0 -203
  283. data/lua-hooks/ext/perf/module.mk +0 -5
  284. data/lua-hooks/ext/sha1/luasha1.c +0 -74
  285. data/lua-hooks/ext/sha1/module.mk +0 -5
  286. data/lua-hooks/ext/sha1/sha1.c +0 -145
  287. data/lua-hooks/ext/sha2/luasha256.c +0 -77
  288. data/lua-hooks/ext/sha2/module.mk +0 -5
  289. data/lua-hooks/ext/sha2/sha256.c +0 -196
  290. data/lua-hooks/ext/sysutils/lua_utils.c +0 -56
  291. data/lua-hooks/ext/sysutils/module.mk +0 -2
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Machine code management.
3
- ** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
3
+ ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
4
4
  */
5
5
 
6
6
  #define lj_mcode_c
@@ -204,8 +204,8 @@ static void mcode_protect(jit_State *J, int prot)
204
204
 
205
205
  /* -- MCode area allocation ----------------------------------------------- */
206
206
 
207
- #if LJ_TARGET_X64
208
- #define mcode_validptr(p) ((p) && (uintptr_t)(p) < (uintptr_t)1<<47)
207
+ #if LJ_64
208
+ #define mcode_validptr(p) (p)
209
209
  #else
210
210
  #define mcode_validptr(p) ((p) && (uintptr_t)(p) < 0xffff0000)
211
211
  #endif
@@ -221,8 +221,8 @@ static void *mcode_alloc(jit_State *J, size_t sz)
221
221
  */
222
222
  #if LJ_TARGET_MIPS
223
223
  /* Use the middle of the 256MB-aligned region. */
224
- uintptr_t target = ((uintptr_t)(void *)lj_vm_exit_handler & 0xf0000000u) +
225
- 0x08000000u;
224
+ uintptr_t target = ((uintptr_t)(void *)lj_vm_exit_handler &
225
+ ~(uintptr_t)0x0fffffffu) + 0x08000000u;
226
226
  #else
227
227
  uintptr_t target = (uintptr_t)(void *)lj_vm_exit_handler & ~(uintptr_t)0xffff;
228
228
  #endif
@@ -230,7 +230,8 @@ static void *mcode_alloc(jit_State *J, size_t sz)
230
230
  /* First try a contiguous area below the last one. */
231
231
  uintptr_t hint = J->mcarea ? (uintptr_t)J->mcarea - sz : 0;
232
232
  int i;
233
- for (i = 0; i < 32; i++) { /* 32 attempts ought to be enough ... */
233
+ /* Limit probing iterations, depending on the available pool size. */
234
+ for (i = 0; i < LJ_TARGET_JUMPRANGE; i++) {
234
235
  if (mcode_validptr(hint)) {
235
236
  void *p = mcode_alloc_at(J, hint, sz, MCPROT_GEN);
236
237
 
@@ -239,11 +240,11 @@ static void *mcode_alloc(jit_State *J, size_t sz)
239
240
  return p;
240
241
  if (p) mcode_free(J, p, sz); /* Free badly placed area. */
241
242
  }
242
- /* Next try probing pseudo-random addresses. */
243
+ /* Next try probing 64K-aligned pseudo-random addresses. */
243
244
  do {
244
- hint = (0x78fb ^ LJ_PRNG_BITS(J, 15)) << 16; /* 64K aligned. */
245
- } while (!(hint + sz < range));
246
- hint = target + hint - (range>>1);
245
+ hint = LJ_PRNG_BITS(J, LJ_TARGET_JUMPRANGE-16) << 16;
246
+ } while (!(hint + sz < range+range));
247
+ hint = target + hint - range;
247
248
  }
248
249
  lj_trace_err(J, LJ_TRERR_MCODEAL); /* Give up. OS probably ignores hints? */
249
250
  return NULL;
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Machine code management.
3
- ** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
3
+ ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
4
4
  */
5
5
 
6
6
  #ifndef _LJ_MCODE_H
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Metamethod handling.
3
- ** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
3
+ ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
4
4
  **
5
5
  ** Portions taken verbatim or adapted from the Lua interpreter.
6
6
  ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Metamethod handling.
3
- ** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
3
+ ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
4
4
  */
5
5
 
6
6
  #ifndef _LJ_META_H
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Miscellaneous object handling.
3
- ** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
3
+ ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
4
4
  */
5
5
 
6
6
  #define lj_obj_c
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** LuaJIT VM tags, values and objects.
3
- ** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
3
+ ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
4
4
  **
5
5
  ** Portions taken verbatim or adapted from the Lua interpreter.
6
6
  ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@@ -843,12 +843,16 @@ static LJ_AINLINE void setlightudV(TValue *o, void *p)
843
843
  #endif
844
844
 
845
845
  #if LJ_FR2
846
- #define setcont(o, f) ((o)->u64 = (uint64_t)(uintptr_t)(void *)(f))
846
+ #define contptr(f) ((void *)(f))
847
+ #define setcont(o, f) ((o)->u64 = (uint64_t)(uintptr_t)contptr(f))
847
848
  #elif LJ_64
849
+ #define contptr(f) \
850
+ ((void *)(uintptr_t)(uint32_t)((intptr_t)(f) - (intptr_t)lj_vm_asm_begin))
848
851
  #define setcont(o, f) \
849
852
  ((o)->u64 = (uint64_t)(void *)(f) - (uint64_t)lj_vm_asm_begin)
850
853
  #else
851
- #define setcont(o, f) setlightudV((o), (void *)(f))
854
+ #define contptr(f) ((void *)(f))
855
+ #define setcont(o, f) setlightudV((o), contptr(f))
852
856
  #endif
853
857
 
854
858
  #define tvchecklive(L, o) \
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** DCE: Dead Code Elimination. Pre-LOOP only -- ASM already performs DCE.
3
- ** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
3
+ ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
4
4
  */
5
5
 
6
6
  #define lj_opt_dce_c
@@ -2,7 +2,7 @@
2
2
  ** FOLD: Constant Folding, Algebraic Simplifications and Reassociation.
3
3
  ** ABCelim: Array Bounds Check Elimination.
4
4
  ** CSE: Common-Subexpression Elimination.
5
- ** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
5
+ ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
6
6
  */
7
7
 
8
8
  #define lj_opt_fold_c
@@ -136,8 +136,8 @@
136
136
  /* Some local macros to save typing. Undef'd at the end. */
137
137
  #define IR(ref) (&J->cur.ir[(ref)])
138
138
  #define fins (&J->fold.ins)
139
- #define fleft (&J->fold.left)
140
- #define fright (&J->fold.right)
139
+ #define fleft (J->fold.left)
140
+ #define fright (J->fold.right)
141
141
  #define knumleft (ir_knum(fleft)->n)
142
142
  #define knumright (ir_knum(fright)->n)
143
143
 
@@ -173,8 +173,6 @@ LJFOLD(ADD KNUM KNUM)
173
173
  LJFOLD(SUB KNUM KNUM)
174
174
  LJFOLD(MUL KNUM KNUM)
175
175
  LJFOLD(DIV KNUM KNUM)
176
- LJFOLD(NEG KNUM KNUM)
177
- LJFOLD(ABS KNUM KNUM)
178
176
  LJFOLD(ATAN2 KNUM KNUM)
179
177
  LJFOLD(LDEXP KNUM KNUM)
180
178
  LJFOLD(MIN KNUM KNUM)
@@ -187,6 +185,15 @@ LJFOLDF(kfold_numarith)
187
185
  return lj_ir_knum(J, y);
188
186
  }
189
187
 
188
+ LJFOLD(NEG KNUM FLOAD)
189
+ LJFOLD(ABS KNUM FLOAD)
190
+ LJFOLDF(kfold_numabsneg)
191
+ {
192
+ lua_Number a = knumleft;
193
+ lua_Number y = lj_vm_foldarith(a, a, fins->o - IR_ADD);
194
+ return lj_ir_knum(J, y);
195
+ }
196
+
190
197
  LJFOLD(LDEXP KNUM KINT)
191
198
  LJFOLDF(kfold_ldexp)
192
199
  {
@@ -347,6 +354,11 @@ static uint64_t kfold_int64arith(uint64_t k1, uint64_t k2, IROp op)
347
354
  case IR_BAND: k1 &= k2; break;
348
355
  case IR_BOR: k1 |= k2; break;
349
356
  case IR_BXOR: k1 ^= k2; break;
357
+ case IR_BSHL: k1 <<= (k2 & 63); break;
358
+ case IR_BSHR: k1 = (int32_t)((uint32_t)k1 >> (k2 & 63)); break;
359
+ case IR_BSAR: k1 >>= (k2 & 63); break;
360
+ case IR_BROL: k1 = (int32_t)lj_rol((uint32_t)k1, (k2 & 63)); break;
361
+ case IR_BROR: k1 = (int32_t)lj_ror((uint32_t)k1, (k2 & 63)); break;
350
362
  #endif
351
363
  default: UNUSED(k2); lua_assert(0); break;
352
364
  }
@@ -436,14 +448,14 @@ LJFOLDF(kfold_int64comp)
436
448
  #if LJ_HASFFI
437
449
  uint64_t a = ir_k64(fleft)->u64, b = ir_k64(fright)->u64;
438
450
  switch ((IROp)fins->o) {
439
- case IR_LT: return CONDFOLD(a < b);
440
- case IR_GE: return CONDFOLD(a >= b);
441
- case IR_LE: return CONDFOLD(a <= b);
442
- case IR_GT: return CONDFOLD(a > b);
443
- case IR_ULT: return CONDFOLD((uint64_t)a < (uint64_t)b);
444
- case IR_UGE: return CONDFOLD((uint64_t)a >= (uint64_t)b);
445
- case IR_ULE: return CONDFOLD((uint64_t)a <= (uint64_t)b);
446
- case IR_UGT: return CONDFOLD((uint64_t)a > (uint64_t)b);
451
+ case IR_LT: return CONDFOLD((int64_t)a < (int64_t)b);
452
+ case IR_GE: return CONDFOLD((int64_t)a >= (int64_t)b);
453
+ case IR_LE: return CONDFOLD((int64_t)a <= (int64_t)b);
454
+ case IR_GT: return CONDFOLD((int64_t)a > (int64_t)b);
455
+ case IR_ULT: return CONDFOLD(a < b);
456
+ case IR_UGE: return CONDFOLD(a >= b);
457
+ case IR_ULE: return CONDFOLD(a <= b);
458
+ case IR_UGT: return CONDFOLD(a > b);
447
459
  default: lua_assert(0); return FAILFOLD;
448
460
  }
449
461
  #else
@@ -502,7 +514,7 @@ LJFOLDF(kfold_strref_snew)
502
514
  PHIBARRIER(ir);
503
515
  fins->op2 = emitir(IRTI(IR_ADD), ir->op2, fins->op2); /* Clobbers fins! */
504
516
  fins->op1 = str;
505
- fins->ot = IRT(IR_STRREF, IRT_P32);
517
+ fins->ot = IRT(IR_STRREF, IRT_PGC);
506
518
  return RETRYFOLD;
507
519
  }
508
520
  }
@@ -911,13 +923,13 @@ LJFOLDF(shortcut_round)
911
923
  return NEXTFOLD;
912
924
  }
913
925
 
914
- LJFOLD(ABS ABS KNUM)
926
+ LJFOLD(ABS ABS FLOAD)
915
927
  LJFOLDF(shortcut_left)
916
928
  {
917
929
  return LEFTFOLD; /* f(g(x)) ==> g(x) */
918
930
  }
919
931
 
920
- LJFOLD(ABS NEG KNUM)
932
+ LJFOLD(ABS NEG FLOAD)
921
933
  LJFOLDF(shortcut_dropleft)
922
934
  {
923
935
  PHIBARRIER(fleft);
@@ -998,8 +1010,10 @@ LJFOLDF(simplify_nummuldiv_k)
998
1010
  if (n == 1.0) { /* x o 1 ==> x */
999
1011
  return LEFTFOLD;
1000
1012
  } else if (n == -1.0) { /* x o -1 ==> -x */
1013
+ IRRef op1 = fins->op1;
1014
+ fins->op2 = (IRRef1)lj_ir_ksimd(J, LJ_KSIMD_NEG); /* Modifies fins. */
1015
+ fins->op1 = op1;
1001
1016
  fins->o = IR_NEG;
1002
- fins->op2 = (IRRef1)lj_ir_knum_neg(J);
1003
1017
  return RETRYFOLD;
1004
1018
  } else if (fins->o == IR_MUL && n == 2.0) { /* x * 2 ==> x + x */
1005
1019
  fins->o = IR_ADD;
@@ -1651,6 +1665,14 @@ LJFOLDF(simplify_shiftk_andk)
1651
1665
  fins->op2 = (IRRef1)lj_ir_kint(J, k);
1652
1666
  fins->ot = IRTI(IR_BAND);
1653
1667
  return RETRYFOLD;
1668
+ } else if (irk->o == IR_KINT64) {
1669
+ uint64_t k = kfold_int64arith(ir_k64(irk)->u64, fright->i, (IROp)fins->o);
1670
+ IROpT ot = fleft->ot;
1671
+ fins->op1 = fleft->op1;
1672
+ fins->op1 = (IRRef1)lj_opt_fold(J);
1673
+ fins->op2 = (IRRef1)lj_ir_kint64(J, k);
1674
+ fins->ot = ot;
1675
+ return RETRYFOLD;
1654
1676
  }
1655
1677
  return NEXTFOLD;
1656
1678
  }
@@ -1666,6 +1688,47 @@ LJFOLDF(simplify_andk_shiftk)
1666
1688
  return NEXTFOLD;
1667
1689
  }
1668
1690
 
1691
+ LJFOLD(BAND BOR KINT)
1692
+ LJFOLD(BOR BAND KINT)
1693
+ LJFOLDF(simplify_andor_k)
1694
+ {
1695
+ IRIns *irk = IR(fleft->op2);
1696
+ PHIBARRIER(fleft);
1697
+ if (irk->o == IR_KINT) {
1698
+ int32_t k = kfold_intop(irk->i, fright->i, (IROp)fins->o);
1699
+ /* (i | k1) & k2 ==> i & k2, if (k1 & k2) == 0. */
1700
+ /* (i & k1) | k2 ==> i | k2, if (k1 | k2) == -1. */
1701
+ if (k == (fins->o == IR_BAND ? 0 : -1)) {
1702
+ fins->op1 = fleft->op1;
1703
+ return RETRYFOLD;
1704
+ }
1705
+ }
1706
+ return NEXTFOLD;
1707
+ }
1708
+
1709
+ LJFOLD(BAND BOR KINT64)
1710
+ LJFOLD(BOR BAND KINT64)
1711
+ LJFOLDF(simplify_andor_k64)
1712
+ {
1713
+ #if LJ_HASFFI
1714
+ IRIns *irk = IR(fleft->op2);
1715
+ PHIBARRIER(fleft);
1716
+ if (irk->o == IR_KINT64) {
1717
+ uint64_t k = kfold_int64arith(ir_k64(irk)->u64,
1718
+ ir_k64(fright)->u64, (IROp)fins->o);
1719
+ /* (i | k1) & k2 ==> i & k2, if (k1 & k2) == 0. */
1720
+ /* (i & k1) | k2 ==> i | k2, if (k1 | k2) == -1. */
1721
+ if (k == (fins->o == IR_BAND ? (uint64_t)0 : ~(uint64_t)0)) {
1722
+ fins->op1 = fleft->op1;
1723
+ return RETRYFOLD;
1724
+ }
1725
+ }
1726
+ return NEXTFOLD;
1727
+ #else
1728
+ UNUSED(J); lua_assert(0); return FAILFOLD;
1729
+ #endif
1730
+ }
1731
+
1669
1732
  /* -- Reassociation ------------------------------------------------------- */
1670
1733
 
1671
1734
  LJFOLD(ADD ADD KINT)
@@ -2393,10 +2456,14 @@ retry:
2393
2456
  if (fins->op1 >= J->cur.nk) {
2394
2457
  key += (uint32_t)IR(fins->op1)->o << 10;
2395
2458
  *fleft = *IR(fins->op1);
2459
+ if (fins->op1 < REF_TRUE)
2460
+ fleft[1] = IR(fins->op1)[1];
2396
2461
  }
2397
2462
  if (fins->op2 >= J->cur.nk) {
2398
2463
  key += (uint32_t)IR(fins->op2)->o;
2399
2464
  *fright = *IR(fins->op2);
2465
+ if (fins->op2 < REF_TRUE)
2466
+ fright[1] = IR(fins->op2)[1];
2400
2467
  } else {
2401
2468
  key += (fins->op2 & 0x3ffu); /* Literal mask. Must include IRCONV_*MASK. */
2402
2469
  }
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** LOOP: Loop Optimizations.
3
- ** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
3
+ ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
4
4
  */
5
5
 
6
6
  #define lj_opt_loop_c
@@ -3,7 +3,7 @@
3
3
  ** AA: Alias Analysis using high-level semantic disambiguation.
4
4
  ** FWD: Load Forwarding (L2L) + Store Forwarding (S2L).
5
5
  ** DSE: Dead-Store Elimination.
6
- ** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
6
+ ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
7
7
  */
8
8
 
9
9
  #define lj_opt_mem_c
@@ -22,8 +22,8 @@
22
22
  /* Some local macros to save typing. Undef'd at the end. */
23
23
  #define IR(ref) (&J->cur.ir[(ref)])
24
24
  #define fins (&J->fold.ins)
25
- #define fleft (&J->fold.left)
26
- #define fright (&J->fold.right)
25
+ #define fleft (J->fold.left)
26
+ #define fright (J->fold.right)
27
27
 
28
28
  /*
29
29
  ** Caveat #1: return value is not always a TRef -- only use with tref_ref().
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  ** NARROW: Narrowing of numbers to integers (double to int32_t).
3
3
  ** STRIPOV: Stripping of overflow checks.
4
- ** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
4
+ ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
5
5
  */
6
6
 
7
7
  #define lj_opt_narrow_c
@@ -517,18 +517,24 @@ static int numisint(lua_Number n)
517
517
  return (n == (lua_Number)lj_num2int(n));
518
518
  }
519
519
 
520
+ /* Convert string to number. Error out for non-numeric string values. */
521
+ static TRef conv_str_tonum(jit_State *J, TRef tr, TValue *o)
522
+ {
523
+ if (tref_isstr(tr)) {
524
+ tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0);
525
+ /* Would need an inverted STRTO for this rare and useless case. */
526
+ if (!lj_strscan_num(strV(o), o)) /* Convert in-place. Value used below. */
527
+ lj_trace_err(J, LJ_TRERR_BADTYPE); /* Punt if non-numeric. */
528
+ }
529
+ return tr;
530
+ }
531
+
520
532
  /* Narrowing of arithmetic operations. */
521
533
  TRef lj_opt_narrow_arith(jit_State *J, TRef rb, TRef rc,
522
534
  TValue *vb, TValue *vc, IROp op)
523
535
  {
524
- if (tref_isstr(rb)) {
525
- rb = emitir(IRTG(IR_STRTO, IRT_NUM), rb, 0);
526
- lj_strscan_num(strV(vb), vb);
527
- }
528
- if (tref_isstr(rc)) {
529
- rc = emitir(IRTG(IR_STRTO, IRT_NUM), rc, 0);
530
- lj_strscan_num(strV(vc), vc);
531
- }
536
+ rb = conv_str_tonum(J, rb, vb);
537
+ rc = conv_str_tonum(J, rc, vc);
532
538
  /* Must not narrow MUL in non-DUALNUM variant, because it loses -0. */
533
539
  if ((op >= IR_ADD && op <= (LJ_DUALNUM ? IR_MUL : IR_SUB)) &&
534
540
  tref_isinteger(rb) && tref_isinteger(rc) &&
@@ -543,24 +549,21 @@ TRef lj_opt_narrow_arith(jit_State *J, TRef rb, TRef rc,
543
549
  /* Narrowing of unary minus operator. */
544
550
  TRef lj_opt_narrow_unm(jit_State *J, TRef rc, TValue *vc)
545
551
  {
546
- if (tref_isstr(rc)) {
547
- rc = emitir(IRTG(IR_STRTO, IRT_NUM), rc, 0);
548
- lj_strscan_num(strV(vc), vc);
549
- }
552
+ rc = conv_str_tonum(J, rc, vc);
550
553
  if (tref_isinteger(rc)) {
551
554
  if ((uint32_t)numberVint(vc) != 0x80000000u)
552
555
  return emitir(IRTGI(IR_SUBOV), lj_ir_kint(J, 0), rc);
553
556
  rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT);
554
557
  }
555
- return emitir(IRTN(IR_NEG), rc, lj_ir_knum_neg(J));
558
+ return emitir(IRTN(IR_NEG), rc, lj_ir_ksimd(J, LJ_KSIMD_NEG));
556
559
  }
557
560
 
558
561
  /* Narrowing of modulo operator. */
559
- TRef lj_opt_narrow_mod(jit_State *J, TRef rb, TRef rc, TValue *vc)
562
+ TRef lj_opt_narrow_mod(jit_State *J, TRef rb, TRef rc, TValue *vb, TValue *vc)
560
563
  {
561
564
  TRef tmp;
562
- if (tvisstr(vc) && !lj_strscan_num(strV(vc), vc))
563
- lj_trace_err(J, LJ_TRERR_BADTYPE);
565
+ rb = conv_str_tonum(J, rb, vb);
566
+ rc = conv_str_tonum(J, rc, vc);
564
567
  if ((LJ_DUALNUM || (J->flags & JIT_F_OPT_NARROW)) &&
565
568
  tref_isinteger(rb) && tref_isinteger(rc) &&
566
569
  (tvisint(vc) ? intV(vc) != 0 : !tviszero(vc))) {
@@ -577,10 +580,11 @@ TRef lj_opt_narrow_mod(jit_State *J, TRef rb, TRef rc, TValue *vc)
577
580
  }
578
581
 
579
582
  /* Narrowing of power operator or math.pow. */
580
- TRef lj_opt_narrow_pow(jit_State *J, TRef rb, TRef rc, TValue *vc)
583
+ TRef lj_opt_narrow_pow(jit_State *J, TRef rb, TRef rc, TValue *vb, TValue *vc)
581
584
  {
582
- if (tvisstr(vc) && !lj_strscan_num(strV(vc), vc))
583
- lj_trace_err(J, LJ_TRERR_BADTYPE);
585
+ rb = conv_str_tonum(J, rb, vb);
586
+ rb = lj_ir_tonum(J, rb); /* Left arg is always treated as an FP number. */
587
+ rc = conv_str_tonum(J, rc, vc);
584
588
  /* Narrowing must be unconditional to preserve (-x)^i semantics. */
585
589
  if (tvisint(vc) || numisint(numV(vc))) {
586
590
  int checkrange = 0;
@@ -591,8 +595,6 @@ TRef lj_opt_narrow_pow(jit_State *J, TRef rb, TRef rc, TValue *vc)
591
595
  checkrange = 1;
592
596
  }
593
597
  if (!tref_isinteger(rc)) {
594
- if (tref_isstr(rc))
595
- rc = emitir(IRTG(IR_STRTO, IRT_NUM), rc, 0);
596
598
  /* Guarded conversion to integer! */
597
599
  rc = emitir(IRTGI(IR_CONV), rc, IRCONV_INT_NUM|IRCONV_CHECK);
598
600
  }
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** SINK: Allocation Sinking and Store Sinking.
3
- ** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
3
+ ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
4
4
  */
5
5
 
6
6
  #define lj_opt_sink_c
@@ -153,10 +153,9 @@ static void sink_remark_phi(jit_State *J)
153
153
  remark = 0;
154
154
  for (ir = IR(J->cur.nins-1); ir->o == IR_PHI; ir--) {
155
155
  IRIns *irl = IR(ir->op1), *irr = IR(ir->op2);
156
- if (((irl->t.irt ^ irr->t.irt) & IRT_MARK))
157
- remark = 1;
158
- else if (irl->prev == irr->prev)
156
+ if (!((irl->t.irt ^ irr->t.irt) & IRT_MARK) && irl->prev == irr->prev)
159
157
  continue;
158
+ remark |= (~(irl->t.irt & irr->t.irt) & IRT_MARK);
160
159
  irt_setmark(IR(ir->op1)->t);
161
160
  irt_setmark(IR(ir->op2)->t);
162
161
  }
@@ -166,8 +165,8 @@ static void sink_remark_phi(jit_State *J)
166
165
  /* Sweep instructions and tag sunken allocations and stores. */
167
166
  static void sink_sweep_ins(jit_State *J)
168
167
  {
169
- IRIns *ir, *irfirst = IR(J->cur.nk);
170
- for (ir = IR(J->cur.nins-1) ; ir >= irfirst; ir--) {
168
+ IRIns *ir, *irbase = IR(REF_BASE);
169
+ for (ir = IR(J->cur.nins-1) ; ir >= irbase; ir--) {
171
170
  switch (ir->o) {
172
171
  case IR_ASTORE: case IR_HSTORE: case IR_FSTORE: case IR_XSTORE: {
173
172
  IRIns *ira = sink_checkalloc(J, ir);
@@ -217,6 +216,12 @@ static void sink_sweep_ins(jit_State *J)
217
216
  break;
218
217
  }
219
218
  }
219
+ for (ir = IR(J->cur.nk); ir < irbase; ir++) {
220
+ irt_clearmark(ir->t);
221
+ ir->prev = REGSP_INIT;
222
+ if (irt_is64(ir->t) && ir->o != IR_KNULL)
223
+ ir++;
224
+ }
220
225
  }
221
226
 
222
227
  /* Allocation sinking and store sinking.