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,7 +1,7 @@
1
1
  /*
2
2
  ** LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/
3
3
  **
4
- ** Copyright (C) 2005-2016 Mike Pall. All rights reserved.
4
+ ** Copyright (C) 2005-2017 Mike Pall. All rights reserved.
5
5
  **
6
6
  ** Permission is hereby granted, free of charge, to any person obtaining
7
7
  ** a copy of this software and associated documentation files (the
@@ -30,10 +30,10 @@
30
30
 
31
31
  #include "lua.h"
32
32
 
33
- #define LUAJIT_VERSION "LuaJIT 2.1.0-beta2"
33
+ #define LUAJIT_VERSION "LuaJIT 2.1.0-beta3"
34
34
  #define LUAJIT_VERSION_NUM 20100 /* Version 2.1.0 = 02.01.00. */
35
- #define LUAJIT_VERSION_SYM luaJIT_version_2_1_0_beta2
36
- #define LUAJIT_COPYRIGHT "Copyright (C) 2005-2016 Mike Pall"
35
+ #define LUAJIT_VERSION_SYM luaJIT_version_2_1_0_beta3
36
+ #define LUAJIT_COPYRIGHT "Copyright (C) 2005-2017 Mike Pall"
37
37
  #define LUAJIT_URL "http://luajit.org/"
38
38
 
39
39
  /* Modes for luaJIT_setmode. */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Standard library header.
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 _LUALIB_H
@@ -1,5 +1,5 @@
1
1
  @rem Script to build LuaJIT with MSVC.
2
- @rem Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
2
+ @rem Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
3
3
  @rem
4
4
  @rem Either open a "Visual Studio .NET Command Prompt"
5
5
  @rem (Note that the Express Edition does not contain an x64 compiler)
@@ -14,12 +14,13 @@
14
14
  @if not defined INCLUDE goto :FAIL
15
15
 
16
16
  @setlocal
17
- @set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
17
+ @set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline
18
18
  @set LJLINK=link /nologo
19
19
  @set LJMT=mt /nologo
20
20
  @set LJLIB=lib /nologo /nodefaultlib
21
21
  @set DASMDIR=..\dynasm
22
22
  @set DASM=%DASMDIR%\dynasm.lua
23
+ @set DASC=vm_x86.dasc
23
24
  @set LJDLLNAME=lua51.dll
24
25
  @set LJLIBNAME=lua51.lib
25
26
  @set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c
@@ -39,7 +40,12 @@ if exist minilua.exe.manifest^
39
40
  @set LJARCH=x86
40
41
  @set LJCOMPILE=%LJCOMPILE% /arch:SSE2
41
42
  :X64
42
- minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc
43
+ @if "%1" neq "gc64" goto :NOGC64
44
+ @shift
45
+ @set DASC=vm_x64.dasc
46
+ @set LJCOMPILE=%LJCOMPILE% /DLUAJIT_ENABLE_GC64
47
+ :NOGC64
48
+ minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
43
49
  @if errorlevel 1 goto :BAD
44
50
 
45
51
  %LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c
@@ -67,7 +73,7 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
67
73
  @if "%1" neq "debug" goto :NODEBUG
68
74
  @shift
69
75
  @set LJCOMPILE=%LJCOMPILE% /Zi
70
- @set LJLINK=%LJLINK% /debug
76
+ @set LJLINK=%LJLINK% /debug /opt:ref /opt:icf /incremental:no
71
77
  :NODEBUG
72
78
  @if "%1"=="amalg" goto :AMALGDLL
73
79
  @if "%1"=="static" goto :STATIC
@@ -99,6 +105,8 @@ if exist luajit.exe.manifest^
99
105
  %LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe
100
106
 
101
107
  @del *.obj *.manifest minilua.exe buildvm.exe
108
+ @del host\buildvm_arch.h
109
+ @del lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h
102
110
  @echo.
103
111
  @echo === Successfully built LuaJIT for Windows/%LJARCH% ===
104
112
 
@@ -1,6 +1,6 @@
1
1
  |// Low-level VM code for ARM CPUs.
2
2
  |// Bytecode interpreter, fast functions and helper functions.
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
  |.arch arm
6
6
  |.section code_op, code_sub
@@ -1,6 +1,6 @@
1
1
  |// Low-level VM code for ARM64 CPUs.
2
2
  |// Bytecode interpreter, fast functions and helper functions.
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
  |.arch arm64
6
6
  |.section code_op, code_sub
@@ -151,6 +151,21 @@
151
151
  |.define FRAME_FUNC, #-16
152
152
  |.define FRAME_PC, #-8
153
153
  |
154
+ |// Endian-specific defines.
155
+ |.if ENDIAN_LE
156
+ |.define LO, 0
157
+ |.define OFS_RD, 2
158
+ |.define OFS_RB, 3
159
+ |.define OFS_RA, 1
160
+ |.define OFS_OP, 0
161
+ |.else
162
+ |.define LO, 4
163
+ |.define OFS_RD, 0
164
+ |.define OFS_RB, 0
165
+ |.define OFS_RA, 2
166
+ |.define OFS_OP, 3
167
+ |.endif
168
+ |
154
169
  |.macro decode_RA, dst, ins; ubfx dst, ins, #8, #8; .endmacro
155
170
  |.macro decode_RB, dst, ins; ubfx dst, ins, #24, #8; .endmacro
156
171
  |.macro decode_RC, dst, ins; ubfx dst, ins, #16, #8; .endmacro
@@ -236,12 +251,17 @@
236
251
  |.macro mov_false, reg; movn reg, #0x8000, lsl #32; .endmacro
237
252
  |.macro mov_true, reg; movn reg, #0x0001, lsl #48; .endmacro
238
253
  |
239
- #define GL_J(field) (GG_OFS(J) + (int)offsetof(jit_State, field))
254
+ #define GL_J(field) (GG_G2J + (int)offsetof(jit_State, field))
240
255
  |
241
256
  #define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto))
242
257
  |
243
258
  |.macro hotcheck, delta
244
- | NYI
259
+ | lsr CARG1, PC, #1
260
+ | and CARG1, CARG1, #126
261
+ | add CARG1, CARG1, #GG_G2DISP+GG_DISP2HOT
262
+ | ldrh CARG2w, [GL, CARG1]
263
+ | subs CARG2, CARG2, #delta
264
+ | strh CARG2w, [GL, CARG1]
245
265
  |.endmacro
246
266
  |
247
267
  |.macro hotloop
@@ -712,7 +732,7 @@ static void build_subroutines(BuildCtx *ctx)
712
732
  | cmp CRET1, #1
713
733
  | bhi ->vmeta_binop
714
734
  |4:
715
- | ldrh RBw, [PC, #2]
735
+ | ldrh RBw, [PC, # OFS_RD]
716
736
  | add PC, PC, #4
717
737
  | add RB, PC, RB, lsl #2
718
738
  | sub RB, RB, #0x20000
@@ -869,7 +889,7 @@ static void build_subroutines(BuildCtx *ctx)
869
889
  | bl extern lj_meta_for // (lua_State *L, TValue *base)
870
890
  | ldr INSw, [PC, #-4]
871
891
  |.if JIT
872
- | uxtb TMP0, INS
892
+ | uxtb TMP0w, INSw
873
893
  |.endif
874
894
  | decode_RA RA, INS
875
895
  | decode_RD RC, INS
@@ -1495,7 +1515,12 @@ static void build_subroutines(BuildCtx *ctx)
1495
1515
  | bne ->fff_fallback
1496
1516
  | checkint CARG1, ->fff_fallback
1497
1517
  | mov CARG3, #1
1498
- | mov CARG2, BASE // Points to stack. Little-endian.
1518
+ | // Point to the char inside the integer in the stack slot.
1519
+ |.if ENDIAN_LE
1520
+ | mov CARG2, BASE
1521
+ |.else
1522
+ | add CARG2, BASE, #7
1523
+ |.endif
1499
1524
  |->fff_newstr:
1500
1525
  | // CARG2 = str, CARG3 = len.
1501
1526
  | str BASE, L->base
@@ -1698,7 +1723,7 @@ static void build_subroutines(BuildCtx *ctx)
1698
1723
  | ands TMP0, PC, #FRAME_TYPE
1699
1724
  | and TMP1, PC, #~FRAME_TYPEP
1700
1725
  | bne >3
1701
- | ldrb RAw, [PC, #-3]
1726
+ | ldrb RAw, [PC, #-4+OFS_RA]
1702
1727
  | lsl RA, RA, #3
1703
1728
  | add TMP1, RA, #16
1704
1729
  |3:
@@ -1732,7 +1757,20 @@ static void build_subroutines(BuildCtx *ctx)
1732
1757
  |//-----------------------------------------------------------------------
1733
1758
  |
1734
1759
  |->vm_record: // Dispatch target for recording phase.
1735
- | NYI
1760
+ |.if JIT
1761
+ | ldrb CARG1w, GL->hookmask
1762
+ | tst CARG1, #HOOK_VMEVENT // No recording while in vmevent.
1763
+ | bne >5
1764
+ | // Decrement the hookcount for consistency, but always do the call.
1765
+ | ldr CARG2w, GL->hookcount
1766
+ | tst CARG1, #HOOK_ACTIVE
1767
+ | bne >1
1768
+ | sub CARG2w, CARG2w, #1
1769
+ | tst CARG1, #LUA_MASKLINE|LUA_MASKCOUNT
1770
+ | beq >1
1771
+ | str CARG2w, GL->hookcount
1772
+ | b >1
1773
+ |.endif
1736
1774
  |
1737
1775
  |->vm_rethook: // Dispatch target for return hooks.
1738
1776
  | ldrb TMP2w, GL->hookmask
@@ -1774,7 +1812,21 @@ static void build_subroutines(BuildCtx *ctx)
1774
1812
  | b <4
1775
1813
  |
1776
1814
  |->vm_hotloop: // Hot loop counter underflow.
1777
- | NYI
1815
+ |.if JIT
1816
+ | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Same as curr_topL(L).
1817
+ | add CARG1, GL, #GG_G2DISP+GG_DISP2J
1818
+ | and LFUNC:CARG3, CARG3, #LJ_GCVMASK
1819
+ | str PC, SAVE_PC
1820
+ | ldr CARG3, LFUNC:CARG3->pc
1821
+ | mov CARG2, PC
1822
+ | str L, [GL, #GL_J(L)]
1823
+ | ldrb CARG3w, [CARG3, #PC2PROTO(framesize)]
1824
+ | str BASE, L->base
1825
+ | add CARG3, BASE, CARG3, lsl #3
1826
+ | str CARG3, L->top
1827
+ | bl extern lj_trace_hot // (jit_State *J, const BCIns *pc)
1828
+ | b <3
1829
+ |.endif
1778
1830
  |
1779
1831
  |->vm_callhook: // Dispatch target for call hooks.
1780
1832
  | mov CARG2, PC
@@ -1804,7 +1856,54 @@ static void build_subroutines(BuildCtx *ctx)
1804
1856
  | br CRET1
1805
1857
  |
1806
1858
  |->cont_stitch: // Trace stitching.
1807
- | NYI
1859
+ |.if JIT
1860
+ | // RA = resultptr, CARG4 = meta base
1861
+ | ldr RBw, SAVE_MULTRES
1862
+ | ldr INSw, [PC, #-4]
1863
+ | ldr TRACE:CARG3, [CARG4, #-40] // Save previous trace.
1864
+ | subs RB, RB, #8
1865
+ | decode_RA RC, INS // Call base.
1866
+ | and CARG3, CARG3, #LJ_GCVMASK
1867
+ | beq >2
1868
+ |1: // Move results down.
1869
+ | ldr CARG1, [RA]
1870
+ | add RA, RA, #8
1871
+ | subs RB, RB, #8
1872
+ | str CARG1, [BASE, RC, lsl #3]
1873
+ | add RC, RC, #1
1874
+ | bne <1
1875
+ |2:
1876
+ | decode_RA RA, INS
1877
+ | decode_RB RB, INS
1878
+ | add RA, RA, RB
1879
+ |3:
1880
+ | cmp RA, RC
1881
+ | bhi >9 // More results wanted?
1882
+ |
1883
+ | ldrh RAw, TRACE:CARG3->traceno
1884
+ | ldrh RCw, TRACE:CARG3->link
1885
+ | cmp RCw, RAw
1886
+ | beq ->cont_nop // Blacklisted.
1887
+ | cmp RCw, #0
1888
+ | bne =>BC_JLOOP // Jump to stitched trace.
1889
+ |
1890
+ | // Stitch a new trace to the previous trace.
1891
+ | mov CARG1, #GL_J(exitno)
1892
+ | str RAw, [GL, CARG1]
1893
+ | mov CARG1, #GL_J(L)
1894
+ | str L, [GL, CARG1]
1895
+ | str BASE, L->base
1896
+ | add CARG1, GL, #GG_G2J
1897
+ | mov CARG2, PC
1898
+ | bl extern lj_dispatch_stitch // (jit_State *J, const BCIns *pc)
1899
+ | ldr BASE, L->base
1900
+ | b ->cont_nop
1901
+ |
1902
+ |9: // Fill up results with nil.
1903
+ | str TISNIL, [BASE, RC, lsl #3]
1904
+ | add RC, RC, #1
1905
+ | b <3
1906
+ |.endif
1808
1907
  |
1809
1908
  |->vm_profhook: // Dispatch target for profiler hook.
1810
1909
  #if LJ_HASPROFILE
@@ -1822,10 +1921,122 @@ static void build_subroutines(BuildCtx *ctx)
1822
1921
  |//-- Trace exit handler -------------------------------------------------
1823
1922
  |//-----------------------------------------------------------------------
1824
1923
  |
1924
+ |.macro savex_, a, b
1925
+ | stp d..a, d..b, [sp, #a*8]
1926
+ | stp x..a, x..b, [sp, #32*8+a*8]
1927
+ |.endmacro
1928
+ |
1825
1929
  |->vm_exit_handler:
1826
- | NYI
1930
+ |.if JIT
1931
+ | sub sp, sp, #(64*8)
1932
+ | savex_, 0, 1
1933
+ | savex_, 2, 3
1934
+ | savex_, 4, 5
1935
+ | savex_, 6, 7
1936
+ | savex_, 8, 9
1937
+ | savex_, 10, 11
1938
+ | savex_, 12, 13
1939
+ | savex_, 14, 15
1940
+ | savex_, 16, 17
1941
+ | savex_, 18, 19
1942
+ | savex_, 20, 21
1943
+ | savex_, 22, 23
1944
+ | savex_, 24, 25
1945
+ | savex_, 26, 27
1946
+ | savex_, 28, 29
1947
+ | stp d30, d31, [sp, #30*8]
1948
+ | ldr CARG1, [sp, #64*8] // Load original value of lr.
1949
+ | add CARG3, sp, #64*8 // Recompute original value of sp.
1950
+ | mv_vmstate CARG4w, EXIT
1951
+ | stp xzr, CARG3, [sp, #62*8] // Store 0/sp in RID_LR/RID_SP.
1952
+ | sub CARG1, CARG1, lr
1953
+ | ldr L, GL->cur_L
1954
+ | lsr CARG1, CARG1, #2
1955
+ | ldr BASE, GL->jit_base
1956
+ | sub CARG1, CARG1, #2
1957
+ | ldr CARG2w, [lr] // Load trace number.
1958
+ | st_vmstate CARG4w
1959
+ |.if ENDIAN_BE
1960
+ | rev32 CARG2, CARG2
1961
+ |.endif
1962
+ | str BASE, L->base
1963
+ | ubfx CARG2w, CARG2w, #5, #16
1964
+ | str CARG1w, [GL, #GL_J(exitno)]
1965
+ | str CARG2w, [GL, #GL_J(parent)]
1966
+ | str L, [GL, #GL_J(L)]
1967
+ | str xzr, GL->jit_base
1968
+ | add CARG1, GL, #GG_G2J
1969
+ | mov CARG2, sp
1970
+ | bl extern lj_trace_exit // (jit_State *J, ExitState *ex)
1971
+ | // Returns MULTRES (unscaled) or negated error code.
1972
+ | ldr CARG2, L->cframe
1973
+ | ldr BASE, L->base
1974
+ | and sp, CARG2, #CFRAME_RAWMASK
1975
+ | ldr PC, SAVE_PC // Get SAVE_PC.
1976
+ | str L, SAVE_L // Set SAVE_L (on-trace resume/yield).
1977
+ | b >1
1978
+ |.endif
1979
+ |
1827
1980
  |->vm_exit_interp:
1828
- | NYI
1981
+ | // CARG1 = MULTRES or negated error code, BASE, PC and GL set.
1982
+ |.if JIT
1983
+ | ldr L, SAVE_L
1984
+ |1:
1985
+ | cmp CARG1w, #0
1986
+ | blt >9 // Check for error from exit.
1987
+ | lsl RC, CARG1, #3
1988
+ | ldr LFUNC:CARG2, [BASE, FRAME_FUNC]
1989
+ | movz TISNUM, #(LJ_TISNUM>>1)&0xffff, lsl #48
1990
+ | movz TISNUMhi, #(LJ_TISNUM>>1)&0xffff, lsl #16
1991
+ | movn TISNIL, #0
1992
+ | and LFUNC:CARG2, CARG2, #LJ_GCVMASK
1993
+ | str RCw, SAVE_MULTRES
1994
+ | str BASE, L->base
1995
+ | ldr CARG2, LFUNC:CARG2->pc
1996
+ | str xzr, GL->jit_base
1997
+ | mv_vmstate CARG4w, INTERP
1998
+ | ldr KBASE, [CARG2, #PC2PROTO(k)]
1999
+ | // Modified copy of ins_next which handles function header dispatch, too.
2000
+ | ldrb RBw, [PC, # OFS_OP]
2001
+ | ldr INSw, [PC], #4
2002
+ | st_vmstate CARG4w
2003
+ | cmp RBw, #BC_FUNCC+2 // Fast function?
2004
+ | add TMP1, GL, INS, uxtb #3
2005
+ | bhs >4
2006
+ |2:
2007
+ | cmp RBw, #BC_FUNCF // Function header?
2008
+ | add TMP0, GL, RB, uxtb #3
2009
+ | ldr RB, [TMP0, #GG_G2DISP]
2010
+ | decode_RA RA, INS
2011
+ | lsr TMP0, INS, #16
2012
+ | csel RC, TMP0, RC, lo
2013
+ | blo >5
2014
+ | ldr CARG3, [BASE, FRAME_FUNC]
2015
+ | sub RC, RC, #8
2016
+ | add RA, BASE, RA, lsl #3 // Yes: RA = BASE+framesize*8, RC = nargs*8
2017
+ | and LFUNC:CARG3, CARG3, #LJ_GCVMASK
2018
+ |5:
2019
+ | br RB
2020
+ |
2021
+ |4: // Check frame below fast function.
2022
+ | ldr CARG1, [BASE, FRAME_PC]
2023
+ | ands CARG2, CARG1, #FRAME_TYPE
2024
+ | bne <2 // Trace stitching continuation?
2025
+ | // Otherwise set KBASE for Lua function below fast function.
2026
+ | ldr CARG3w, [CARG1, #-4]
2027
+ | decode_RA CARG1, CARG3
2028
+ | sub CARG2, BASE, CARG1, lsl #3
2029
+ | ldr LFUNC:CARG3, [CARG2, #-32]
2030
+ | and LFUNC:CARG3, CARG3, #LJ_GCVMASK
2031
+ | ldr CARG3, LFUNC:CARG3->pc
2032
+ | ldr KBASE, [CARG3, #PC2PROTO(k)]
2033
+ | b <2
2034
+ |
2035
+ |9: // Rethrow error from the right C frame.
2036
+ | neg CARG2, CARG1
2037
+ | mov CARG1, L
2038
+ | bl extern lj_err_throw // (lua_State *L, int errcode)
2039
+ |.endif
1829
2040
  |
1830
2041
  |//-----------------------------------------------------------------------
1831
2042
  |//-- Math helper functions ----------------------------------------------
@@ -1965,7 +2176,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
1965
2176
  case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT:
1966
2177
  | // RA = src1, RC = src2, JMP with RC = target
1967
2178
  | ldr CARG1, [BASE, RA, lsl #3]
1968
- | ldrh RBw, [PC, #2]
2179
+ | ldrh RBw, [PC, # OFS_RD]
1969
2180
  | ldr CARG2, [BASE, RC, lsl #3]
1970
2181
  | add PC, PC, #4
1971
2182
  | add RB, PC, RB, lsl #2
@@ -2022,7 +2233,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2022
2233
  | // RA = src1, RC = src2, JMP with RC = target
2023
2234
  | ldr CARG1, [BASE, RA, lsl #3]
2024
2235
  | add RC, BASE, RC, lsl #3
2025
- | ldrh RBw, [PC, #2]
2236
+ | ldrh RBw, [PC, # OFS_RD]
2026
2237
  | ldr CARG3, [RC]
2027
2238
  | add PC, PC, #4
2028
2239
  | add RB, PC, RB, lsl #2
@@ -2083,7 +2294,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2083
2294
  | // RA = src, RC = str_const (~), JMP with RC = target
2084
2295
  | ldr CARG1, [BASE, RA, lsl #3]
2085
2296
  | mvn RC, RC
2086
- | ldrh RBw, [PC, #2]
2297
+ | ldrh RBw, [PC, # OFS_RD]
2087
2298
  | ldr CARG2, [KBASE, RC, lsl #3]
2088
2299
  | add PC, PC, #4
2089
2300
  | movn TMP0, #~LJ_TSTR
@@ -2111,7 +2322,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2111
2322
  | // RA = src, RC = num_const (~), JMP with RC = target
2112
2323
  | ldr CARG1, [BASE, RA, lsl #3]
2113
2324
  | add RC, KBASE, RC, lsl #3
2114
- | ldrh RBw, [PC, #2]
2325
+ | ldrh RBw, [PC, # OFS_RD]
2115
2326
  | ldr CARG3, [RC]
2116
2327
  | add PC, PC, #4
2117
2328
  | add RB, PC, RB, lsl #2
@@ -2171,7 +2382,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2171
2382
  vk = op == BC_ISEQP;
2172
2383
  | // RA = src, RC = primitive_type (~), JMP with RC = target
2173
2384
  | ldr TMP0, [BASE, RA, lsl #3]
2174
- | ldrh RBw, [PC, #2]
2385
+ | ldrh RBw, [PC, # OFS_RD]
2175
2386
  | add PC, PC, #4
2176
2387
  | add RC, RC, #1
2177
2388
  | add RB, PC, RB, lsl #2
@@ -2196,7 +2407,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2196
2407
 
2197
2408
  case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF:
2198
2409
  | // RA = dst or unused, RC = src, JMP with RC = target
2199
- | ldrh RBw, [PC, #2]
2410
+ | ldrh RBw, [PC, # OFS_RD]
2200
2411
  | ldr TMP0, [BASE, RC, lsl #3]
2201
2412
  | add PC, PC, #4
2202
2413
  | mov_false TMP1
@@ -2443,7 +2654,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2443
2654
  | str PC, SAVE_PC
2444
2655
  | bl extern lj_meta_cat // (lua_State *L, TValue *top, int left)
2445
2656
  | // Returns NULL (finished) or TValue * (metamethod).
2446
- | ldrb RBw, [PC, #-1]
2657
+ | ldrb RBw, [PC, #-4+OFS_RB]
2447
2658
  | ldr BASE, L->base
2448
2659
  | cbnz CRET1, ->vmeta_binop
2449
2660
  | ldr TMP0, [BASE, RB, lsl #3]
@@ -3074,7 +3285,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
3074
3285
  | ins_callt
3075
3286
  |
3076
3287
  |5: // Tailcall to a fast function with a Lua frame below.
3077
- | ldrb RAw, [PC, #-3]
3288
+ | ldrb RAw, [PC, #-4+OFS_RA]
3078
3289
  | sub CARG1, BASE, RA, lsl #3
3079
3290
  | ldr LFUNC:CARG1, [CARG1, #-32]
3080
3291
  | and LFUNC:CARG1, CARG1, #LJ_GCVMASK
@@ -3115,8 +3326,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
3115
3326
  |.endif
3116
3327
  | add RA, BASE, RA, lsl #3
3117
3328
  | ldr TAB:RB, [RA, #-16]
3118
- | ldrh TMP3w, [PC, #2]
3119
- | ldr CARG1w, [RA, #-8] // Get index from control var.
3329
+ | ldrh TMP3w, [PC, # OFS_RD]
3330
+ | ldr CARG1w, [RA, #-8+LO] // Get index from control var.
3120
3331
  | add PC, PC, #4
3121
3332
  | add TMP3, PC, TMP3, lsl #2
3122
3333
  | and TAB:RB, RB, #LJ_GCVMASK
@@ -3135,7 +3346,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
3135
3346
  | stp CARG1, TMP0, [RA]
3136
3347
  | add CARG1, CARG1, #1
3137
3348
  |3:
3138
- | str CARG1w, [RA, #-8] // Update control var.
3349
+ | str CARG1w, [RA, #-8+LO] // Update control var.
3139
3350
  | mov PC, TMP3
3140
3351
  |4:
3141
3352
  | ins_next
@@ -3181,8 +3392,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
3181
3392
  |5: // Despecialize bytecode if any of the checks fail.
3182
3393
  | mov TMP0, #BC_JMP
3183
3394
  | mov TMP1, #BC_ITERC
3184
- | strb TMP0w, [PC, #-4]
3185
- | strb TMP1w, [RC]
3395
+ | strb TMP0w, [PC, #-4+OFS_OP]
3396
+ | strb TMP1w, [RC, # OFS_OP]
3186
3397
  | b <1
3187
3398
  break;
3188
3399
 
@@ -3387,7 +3598,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
3387
3598
  if (op == BC_FORI) {
3388
3599
  | csel PC, RC, PC, gt
3389
3600
  } else if (op == BC_JFORI) {
3390
- | ldrh RCw, [RC, #-2]
3601
+ | mov PC, RC
3602
+ | ldrh RCw, [RC, #-4+OFS_RD]
3391
3603
  } else if (op == BC_IFORL) {
3392
3604
  | csel PC, RC, PC, le
3393
3605
  }
@@ -3428,7 +3640,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
3428
3640
  if (op == BC_FORI) {
3429
3641
  | csel PC, RC, PC, hi
3430
3642
  } else if (op == BC_JFORI) {
3431
- | ldrh RCw, [RC, #-2]
3643
+ | ldrh RCw, [RC, #-4+OFS_RD]
3432
3644
  | bls =>BC_JLOOP
3433
3645
  } else if (op == BC_IFORL) {
3434
3646
  | csel PC, RC, PC, ls
@@ -3488,7 +3700,16 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
3488
3700
 
3489
3701
  case BC_JLOOP:
3490
3702
  |.if JIT
3491
- | NYI
3703
+ | // RA = base (ignored), RC = traceno
3704
+ | ldr CARG1, [GL, #GL_J(trace)]
3705
+ | mov CARG2w, #0 // Traces on ARM64 don't store the trace #, so use 0.
3706
+ | ldr TRACE:RC, [CARG1, RC, lsl #3]
3707
+ | st_vmstate CARG2w
3708
+ | ldr RA, TRACE:RC->mcode
3709
+ | str BASE, GL->jit_base
3710
+ | str L, GL->tmpbuf.L
3711
+ | sub sp, sp, #16 // See SPS_FIXED. Avoids sp adjust in every root trace.
3712
+ | br RA
3492
3713
  |.endif
3493
3714
  break;
3494
3715
 
@@ -3546,10 +3767,12 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
3546
3767
  case BC_IFUNCV:
3547
3768
  | // BASE = new base, RA = BASE+framesize*8, CARG3 = LFUNC, RC = nargs*8
3548
3769
  | ldr CARG1, L->maxstack
3770
+ | movn TMP0, #~LJ_TFUNC
3549
3771
  | add TMP2, BASE, RC
3772
+ | add LFUNC:CARG3, CARG3, TMP0, lsl #47
3550
3773
  | add RA, RA, RC
3551
3774
  | add TMP0, RC, #16+FRAME_VARG
3552
- | str LFUNC:CARG3, [TMP2], #8 // Store (untagged) copy of LFUNC.
3775
+ | str LFUNC:CARG3, [TMP2], #8 // Store (tagged) copy of LFUNC.
3553
3776
  | ldr KBASE, [PC, #-4+PC2PROTO(k)]
3554
3777
  | cmp RA, CARG1
3555
3778
  | str TMP0, [TMP2], #8 // Store delta + FRAME_VARG.
@@ -3736,8 +3959,8 @@ static void emit_asm_debug(BuildCtx *ctx)
3736
3959
  "\t.uleb128 0x1\n"
3737
3960
  "\t.sleb128 -8\n"
3738
3961
  "\t.byte 30\n" /* Return address is in lr. */
3739
- "\t.uleb128 1\n" /* augmentation length */
3740
- "\t.byte 0x1b\n" /* pcrel|sdata4 */
3962
+ "\t.uleb128 1\n" /* augmentation length */
3963
+ "\t.byte 0x1b\n" /* pcrel|sdata4 */
3741
3964
  "\t.byte 0xc\n\t.uleb128 31\n\t.uleb128 0\n" /* def_cfa sp */
3742
3965
  "\t.align 3\n"
3743
3966
  ".LECIE2:\n\n");
@@ -3748,7 +3971,7 @@ static void emit_asm_debug(BuildCtx *ctx)
3748
3971
  "\t.long .LASFDE3-.Lframe2\n"
3749
3972
  "\t.long lj_vm_ffi_call-.\n"
3750
3973
  "\t.long %d\n"
3751
- "\t.uleb128 0\n" /* augmentation length */
3974
+ "\t.uleb128 0\n" /* augmentation length */
3752
3975
  "\t.byte 0xe\n\t.uleb128 32\n" /* def_cfa_offset */
3753
3976
  "\t.byte 0x9d\n\t.uleb128 4\n" /* offset fp */
3754
3977
  "\t.byte 0x9e\n\t.uleb128 3\n" /* offset lr */