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
  ** Bytecode instruction modes.
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_bc_c
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Bytecode instruction format.
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_BC_H
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Bytecode dump definitions.
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_BCDUMP_H
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Bytecode reader.
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_bcread_c
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Bytecode writer.
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_bcwrite_c
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Buffer 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_buf_c
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** Buffer 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_BUF_H
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** C data arithmetic.
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
  #include "lj_obj.h"
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** C data arithmetic.
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_CARITH_H
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** FFI C call 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
  #include "lj_obj.h"
@@ -301,7 +301,7 @@
301
301
  unsigned int cl = ccall_classify_struct(cts, ctr); \
302
302
  if ((cl & 4)) { /* Combine float HFA from separate registers. */ \
303
303
  CTSize i = (cl >> 8) - 1; \
304
- do { ((uint32_t *)dp)[i] = cc->fpr[i].u32; } while (i--); \
304
+ do { ((uint32_t *)dp)[i] = cc->fpr[i].lo; } while (i--); \
305
305
  } else { \
306
306
  if (cl > 1) sp = (uint8_t *)&cc->fpr[0]; \
307
307
  memcpy(dp, sp, ctr->size); \
@@ -331,7 +331,7 @@
331
331
 
332
332
  #define CCALL_HANDLE_COMPLEXARG \
333
333
  /* Pass complex by value in separate (!) FPRs or on stack. */ \
334
- isfp = ctr->size == 2*sizeof(float) ? 2 : 1;
334
+ isfp = sz == 2*sizeof(float) ? 2 : 1;
335
335
 
336
336
  #define CCALL_HANDLE_REGARG \
337
337
  if (LJ_TARGET_IOS && isva) { \
@@ -359,6 +359,13 @@
359
359
  } \
360
360
  }
361
361
 
362
+ #if LJ_BE
363
+ #define CCALL_HANDLE_RET \
364
+ if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \
365
+ sp = (uint8_t *)&cc->fpr[0].f;
366
+ #endif
367
+
368
+
362
369
  #elif LJ_TARGET_PPC
363
370
  /* -- PPC calling conventions --------------------------------------------- */
364
371
 
@@ -407,8 +414,8 @@
407
414
  if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \
408
415
  ctr = ctype_get(cts, CTID_DOUBLE); /* FPRs always hold doubles. */
409
416
 
410
- #elif LJ_TARGET_MIPS
411
- /* -- MIPS calling conventions -------------------------------------------- */
417
+ #elif LJ_TARGET_MIPS32
418
+ /* -- MIPS o32 calling conventions ---------------------------------------- */
412
419
 
413
420
  #define CCALL_HANDLE_STRUCTRET \
414
421
  cc->retref = 1; /* Return all structs by reference. */ \
@@ -483,6 +490,78 @@
483
490
  sp = (uint8_t *)&cc->fpr[0].f;
484
491
  #endif
485
492
 
493
+ #elif LJ_TARGET_MIPS64
494
+ /* -- MIPS n64 calling conventions ---------------------------------------- */
495
+
496
+ #define CCALL_HANDLE_STRUCTRET \
497
+ cc->retref = !(sz <= 16); \
498
+ if (cc->retref) cc->gpr[ngpr++] = (GPRArg)dp;
499
+
500
+ #define CCALL_HANDLE_STRUCTRET2 \
501
+ ccall_copy_struct(cc, ctr, dp, sp, ccall_classify_struct(cts, ctr, ct));
502
+
503
+ #define CCALL_HANDLE_COMPLEXRET \
504
+ /* Complex values are returned in 1 or 2 FPRs. */ \
505
+ cc->retref = 0;
506
+
507
+ #if LJ_ABI_SOFTFP /* MIPS64 soft-float */
508
+
509
+ #define CCALL_HANDLE_COMPLEXRET2 \
510
+ if (ctr->size == 2*sizeof(float)) { /* Copy complex float from GPRs. */ \
511
+ ((intptr_t *)dp)[0] = cc->gpr[0]; \
512
+ } else { /* Copy complex double from GPRs. */ \
513
+ ((intptr_t *)dp)[0] = cc->gpr[0]; \
514
+ ((intptr_t *)dp)[1] = cc->gpr[1]; \
515
+ }
516
+
517
+ #define CCALL_HANDLE_COMPLEXARG \
518
+ /* Pass complex by value in 2 or 4 GPRs. */
519
+
520
+ /* Position of soft-float 'float' return value depends on endianess. */
521
+ #define CCALL_HANDLE_RET \
522
+ if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \
523
+ sp = (uint8_t *)cc->gpr + LJ_ENDIAN_SELECT(0, 4);
524
+
525
+ #else /* MIPS64 hard-float */
526
+
527
+ #define CCALL_HANDLE_COMPLEXRET2 \
528
+ if (ctr->size == 2*sizeof(float)) { /* Copy complex float from FPRs. */ \
529
+ ((float *)dp)[0] = cc->fpr[0].f; \
530
+ ((float *)dp)[1] = cc->fpr[1].f; \
531
+ } else { /* Copy complex double from FPRs. */ \
532
+ ((double *)dp)[0] = cc->fpr[0].d; \
533
+ ((double *)dp)[1] = cc->fpr[1].d; \
534
+ }
535
+
536
+ #define CCALL_HANDLE_COMPLEXARG \
537
+ if (sz == 2*sizeof(float)) { \
538
+ isfp = 2; \
539
+ if (ngpr < maxgpr) \
540
+ sz *= 2; \
541
+ }
542
+
543
+ #define CCALL_HANDLE_RET \
544
+ if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \
545
+ sp = (uint8_t *)&cc->fpr[0].f;
546
+
547
+ #endif
548
+
549
+ #define CCALL_HANDLE_STRUCTARG \
550
+ /* Pass all structs by value in registers and/or on the stack. */
551
+
552
+ #define CCALL_HANDLE_REGARG \
553
+ if (ngpr < maxgpr) { \
554
+ dp = &cc->gpr[ngpr]; \
555
+ if (ngpr + n > maxgpr) { \
556
+ nsp += ngpr + n - maxgpr; /* Assumes contiguous gpr/stack fields. */ \
557
+ if (nsp > CCALL_MAXSTACK) goto err_nyi; /* Too many arguments. */ \
558
+ ngpr = maxgpr; \
559
+ } else { \
560
+ ngpr += n; \
561
+ } \
562
+ goto done; \
563
+ }
564
+
486
565
  #else
487
566
  #error "Missing calling convention definitions for this architecture"
488
567
  #endif
@@ -722,6 +801,78 @@ noth: /* Not a homogeneous float/double aggregate. */
722
801
 
723
802
  #endif
724
803
 
804
+ /* -- MIPS64 ABI struct classification ---------------------------- */
805
+
806
+ #if LJ_TARGET_MIPS64
807
+
808
+ #define FTYPE_FLOAT 1
809
+ #define FTYPE_DOUBLE 2
810
+
811
+ /* Classify FP fields (max. 2) and their types. */
812
+ static unsigned int ccall_classify_struct(CTState *cts, CType *ct, CType *ctf)
813
+ {
814
+ int n = 0, ft = 0;
815
+ if ((ctf->info & CTF_VARARG) || (ct->info & CTF_UNION))
816
+ goto noth;
817
+ while (ct->sib) {
818
+ CType *sct;
819
+ ct = ctype_get(cts, ct->sib);
820
+ if (n == 2) {
821
+ goto noth;
822
+ } else if (ctype_isfield(ct->info)) {
823
+ sct = ctype_rawchild(cts, ct);
824
+ if (ctype_isfp(sct->info)) {
825
+ ft |= (sct->size == 4 ? FTYPE_FLOAT : FTYPE_DOUBLE) << 2*n;
826
+ n++;
827
+ } else {
828
+ goto noth;
829
+ }
830
+ } else if (ctype_isbitfield(ct->info) ||
831
+ ctype_isxattrib(ct->info, CTA_SUBTYPE)) {
832
+ goto noth;
833
+ }
834
+ }
835
+ if (n <= 2)
836
+ return ft;
837
+ noth: /* Not a homogeneous float/double aggregate. */
838
+ return 0; /* Struct is in GPRs. */
839
+ }
840
+
841
+ void ccall_copy_struct(CCallState *cc, CType *ctr, void *dp, void *sp, int ft)
842
+ {
843
+ if (LJ_ABI_SOFTFP ? ft :
844
+ ((ft & 3) == FTYPE_FLOAT || (ft >> 2) == FTYPE_FLOAT)) {
845
+ int i, ofs = 0;
846
+ for (i = 0; ft != 0; i++, ft >>= 2) {
847
+ if ((ft & 3) == FTYPE_FLOAT) {
848
+ #if LJ_ABI_SOFTFP
849
+ /* The 2nd FP struct result is in CARG1 (gpr[2]) and not CRET2. */
850
+ memcpy((uint8_t *)dp + ofs,
851
+ (uint8_t *)&cc->gpr[2*i] + LJ_ENDIAN_SELECT(0, 4), 4);
852
+ #else
853
+ *(float *)((uint8_t *)dp + ofs) = cc->fpr[i].f;
854
+ #endif
855
+ ofs += 4;
856
+ } else {
857
+ ofs = (ofs + 7) & ~7; /* 64 bit alignment. */
858
+ #if LJ_ABI_SOFTFP
859
+ *(intptr_t *)((uint8_t *)dp + ofs) = cc->gpr[2*i];
860
+ #else
861
+ *(double *)((uint8_t *)dp + ofs) = cc->fpr[i].d;
862
+ #endif
863
+ ofs += 8;
864
+ }
865
+ }
866
+ } else {
867
+ #if !LJ_ABI_SOFTFP
868
+ if (ft) sp = (uint8_t *)&cc->fpr[0];
869
+ #endif
870
+ memcpy(dp, sp, ctr->size);
871
+ }
872
+ }
873
+
874
+ #endif
875
+
725
876
  /* -- Common C call handling ---------------------------------------------- */
726
877
 
727
878
  /* Infer the destination CTypeID for a vararg argument. */
@@ -889,6 +1040,19 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct,
889
1040
  *(int32_t *)dp = d->size == 1 ? (int32_t)*(int8_t *)dp :
890
1041
  (int32_t)*(int16_t *)dp;
891
1042
  }
1043
+ #if LJ_TARGET_ARM64 && LJ_BE
1044
+ if (isfp && d->size == sizeof(float))
1045
+ ((float *)dp)[1] = ((float *)dp)[0]; /* Floats occupy high slot. */
1046
+ #endif
1047
+ #if LJ_TARGET_MIPS64 || (LJ_TARGET_ARM64 && LJ_BE)
1048
+ if ((ctype_isinteger_or_bool(d->info) || ctype_isenum(d->info)
1049
+ #if LJ_TARGET_MIPS64
1050
+ || (isfp && nsp == 0)
1051
+ #endif
1052
+ ) && d->size <= 4) {
1053
+ *(int64_t *)dp = (int64_t)*(int32_t *)dp; /* Sign-extend to 64 bit. */
1054
+ }
1055
+ #endif
892
1056
  #if LJ_TARGET_X64 && LJ_ABI_WIN
893
1057
  if (isva) { /* Windows/x64 mirrors varargs in both register sets. */
894
1058
  if (nfpr == ngpr)
@@ -904,7 +1068,7 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct,
904
1068
  cc->fpr[nfpr-1].d[0] = cc->fpr[nfpr-2].d[1]; /* Split complex double. */
905
1069
  cc->fpr[nfpr-2].d[1] = 0;
906
1070
  }
907
- #elif LJ_TARGET_ARM64
1071
+ #elif LJ_TARGET_ARM64 || (LJ_TARGET_MIPS64 && !LJ_ABI_SOFTFP)
908
1072
  if (isfp == 2 && (uint8_t *)dp < (uint8_t *)cc->stack) {
909
1073
  /* Split float HFA or complex float into separate registers. */
910
1074
  CTSize i = (sz >> 2) - 1;
@@ -951,7 +1115,8 @@ static int ccall_get_results(lua_State *L, CTState *cts, CType *ct,
951
1115
  CCALL_HANDLE_COMPLEXRET2
952
1116
  return 1; /* One GC step. */
953
1117
  }
954
- if (LJ_BE && ctype_isinteger_or_bool(ctr->info) && ctr->size < CTSIZE_PTR)
1118
+ if (LJ_BE && ctr->size < CTSIZE_PTR &&
1119
+ (ctype_isinteger_or_bool(ctr->info) || ctype_isenum(ctr->info)))
955
1120
  sp += (CTSIZE_PTR - ctr->size);
956
1121
  #if CCALL_NUM_FPR
957
1122
  if (ctype_isfp(ctr->info) || ctype_isvector(ctr->info))
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** FFI C call 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_CCALL_H
@@ -79,8 +79,8 @@ typedef union FPRArg {
79
79
  typedef intptr_t GPRArg;
80
80
  typedef union FPRArg {
81
81
  double d;
82
- float f;
83
- uint32_t u32;
82
+ struct { LJ_ENDIAN_LOHI(float f; , float g;) };
83
+ struct { LJ_ENDIAN_LOHI(uint32_t lo; , uint32_t hi;) };
84
84
  } FPRArg;
85
85
 
86
86
  #elif LJ_TARGET_PPC
@@ -95,11 +95,11 @@ typedef union FPRArg {
95
95
  typedef intptr_t GPRArg;
96
96
  typedef double FPRArg;
97
97
 
98
- #elif LJ_TARGET_MIPS
98
+ #elif LJ_TARGET_MIPS32
99
99
 
100
100
  #define CCALL_NARG_GPR 4
101
101
  #define CCALL_NARG_FPR (LJ_ABI_SOFTFP ? 0 : 2)
102
- #define CCALL_NRET_GPR 2
102
+ #define CCALL_NRET_GPR (LJ_ABI_SOFTFP ? 4 : 2)
103
103
  #define CCALL_NRET_FPR (LJ_ABI_SOFTFP ? 0 : 2)
104
104
  #define CCALL_SPS_EXTRA 7
105
105
  #define CCALL_SPS_FREE 1
@@ -110,6 +110,22 @@ typedef union FPRArg {
110
110
  struct { LJ_ENDIAN_LOHI(float f; , float g;) };
111
111
  } FPRArg;
112
112
 
113
+ #elif LJ_TARGET_MIPS64
114
+
115
+ /* FP args are positional and overlay the GPR array. */
116
+ #define CCALL_NARG_GPR 8
117
+ #define CCALL_NARG_FPR 0
118
+ #define CCALL_NRET_GPR 2
119
+ #define CCALL_NRET_FPR (LJ_ABI_SOFTFP ? 0 : 2)
120
+ #define CCALL_SPS_EXTRA 3
121
+ #define CCALL_SPS_FREE 1
122
+
123
+ typedef intptr_t GPRArg;
124
+ typedef union FPRArg {
125
+ double d;
126
+ struct { LJ_ENDIAN_LOHI(float f; , float g;) };
127
+ } FPRArg;
128
+
113
129
  #else
114
130
  #error "Missing calling convention definitions for this architecture"
115
131
  #endif
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  ** FFI C callback 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
  #include "lj_obj.h"
@@ -63,9 +63,13 @@ static MSize CALLBACK_OFS2SLOT(MSize ofs)
63
63
 
64
64
  #define CALLBACK_MCODE_HEAD 24
65
65
 
66
- #elif LJ_TARGET_MIPS
66
+ #elif LJ_TARGET_MIPS32
67
67
 
68
- #define CALLBACK_MCODE_HEAD 24
68
+ #define CALLBACK_MCODE_HEAD 20
69
+
70
+ #elif LJ_TARGET_MIPS64
71
+
72
+ #define CALLBACK_MCODE_HEAD 52
69
73
 
70
74
  #else
71
75
 
@@ -169,16 +173,16 @@ static void callback_mcode_init(global_State *g, uint32_t *page)
169
173
  uint32_t *p = page;
170
174
  void *target = (void *)lj_vm_ffi_callback;
171
175
  MSize slot;
172
- *p++ = A64I_LDRLx | A64F_D(RID_X11) | A64F_S19(4);
173
- *p++ = A64I_LDRLx | A64F_D(RID_X10) | A64F_S19(5);
174
- *p++ = A64I_BR | A64F_N(RID_X11);
175
- *p++ = A64I_NOP;
176
+ *p++ = A64I_LE(A64I_LDRLx | A64F_D(RID_X11) | A64F_S19(4));
177
+ *p++ = A64I_LE(A64I_LDRLx | A64F_D(RID_X10) | A64F_S19(5));
178
+ *p++ = A64I_LE(A64I_BR | A64F_N(RID_X11));
179
+ *p++ = A64I_LE(A64I_NOP);
176
180
  ((void **)p)[0] = target;
177
181
  ((void **)p)[1] = g;
178
182
  p += 4;
179
183
  for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) {
180
- *p++ = A64I_MOVZw | A64F_D(RID_X9) | A64F_U16(slot);
181
- *p = A64I_B | A64F_S26((page-p) & 0x03ffffffu);
184
+ *p++ = A64I_LE(A64I_MOVZw | A64F_D(RID_X9) | A64F_U16(slot));
185
+ *p = A64I_LE(A64I_B | A64F_S26((page-p) & 0x03ffffffu));
182
186
  p++;
183
187
  }
184
188
  lua_assert(p - page <= CALLBACK_MCODE_SIZE);
@@ -206,14 +210,27 @@ static void callback_mcode_init(global_State *g, uint32_t *page)
206
210
  static void callback_mcode_init(global_State *g, uint32_t *page)
207
211
  {
208
212
  uint32_t *p = page;
209
- void *target = (void *)lj_vm_ffi_callback;
213
+ uintptr_t target = (uintptr_t)(void *)lj_vm_ffi_callback;
214
+ uintptr_t ug = (uintptr_t)(void *)g;
210
215
  MSize slot;
211
- *p++ = MIPSI_SW | MIPSF_T(RID_R1)|MIPSF_S(RID_SP) | 0;
212
- *p++ = MIPSI_LUI | MIPSF_T(RID_R3) | (u32ptr(target) >> 16);
213
- *p++ = MIPSI_LUI | MIPSF_T(RID_R2) | (u32ptr(g) >> 16);
214
- *p++ = MIPSI_ORI | MIPSF_T(RID_R3)|MIPSF_S(RID_R3) |(u32ptr(target)&0xffff);
216
+ #if LJ_TARGET_MIPS32
217
+ *p++ = MIPSI_LUI | MIPSF_T(RID_R3) | (target >> 16);
218
+ *p++ = MIPSI_LUI | MIPSF_T(RID_R2) | (ug >> 16);
219
+ #else
220
+ *p++ = MIPSI_LUI | MIPSF_T(RID_R3) | (target >> 48);
221
+ *p++ = MIPSI_LUI | MIPSF_T(RID_R2) | (ug >> 48);
222
+ *p++ = MIPSI_ORI | MIPSF_T(RID_R3)|MIPSF_S(RID_R3) | ((target >> 32) & 0xffff);
223
+ *p++ = MIPSI_ORI | MIPSF_T(RID_R2)|MIPSF_S(RID_R2) | ((ug >> 32) & 0xffff);
224
+ *p++ = MIPSI_DSLL | MIPSF_D(RID_R3)|MIPSF_T(RID_R3) | MIPSF_A(16);
225
+ *p++ = MIPSI_DSLL | MIPSF_D(RID_R2)|MIPSF_T(RID_R2) | MIPSF_A(16);
226
+ *p++ = MIPSI_ORI | MIPSF_T(RID_R3)|MIPSF_S(RID_R3) | ((target >> 16) & 0xffff);
227
+ *p++ = MIPSI_ORI | MIPSF_T(RID_R2)|MIPSF_S(RID_R2) | ((ug >> 16) & 0xffff);
228
+ *p++ = MIPSI_DSLL | MIPSF_D(RID_R3)|MIPSF_T(RID_R3) | MIPSF_A(16);
229
+ *p++ = MIPSI_DSLL | MIPSF_D(RID_R2)|MIPSF_T(RID_R2) | MIPSF_A(16);
230
+ #endif
231
+ *p++ = MIPSI_ORI | MIPSF_T(RID_R3)|MIPSF_S(RID_R3) | (target & 0xffff);
215
232
  *p++ = MIPSI_JR | MIPSF_S(RID_R3);
216
- *p++ = MIPSI_ORI | MIPSF_T(RID_R2)|MIPSF_S(RID_R2) | (u32ptr(g)&0xffff);
233
+ *p++ = MIPSI_ORI | MIPSF_T(RID_R2)|MIPSF_S(RID_R2) | (ug & 0xffff);
217
234
  for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) {
218
235
  *p = MIPSI_B | ((page-p-1) & 0x0000ffffu);
219
236
  p++;
@@ -425,7 +442,7 @@ void lj_ccallback_mcode_free(CTState *cts)
425
442
  if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \
426
443
  *(double *)dp = *(float *)dp; /* FPRs always hold doubles. */
427
444
 
428
- #elif LJ_TARGET_MIPS
445
+ #elif LJ_TARGET_MIPS32
429
446
 
430
447
  #define CALLBACK_HANDLE_GPR \
431
448
  if (n > 1) ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \
@@ -451,6 +468,29 @@ void lj_ccallback_mcode_free(CTState *cts)
451
468
  UNUSED(isfp);
452
469
  #endif
453
470
 
471
+ #define CALLBACK_HANDLE_RET \
472
+ if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \
473
+ ((float *)dp)[1] = *(float *)dp;
474
+
475
+ #elif LJ_TARGET_MIPS64
476
+
477
+ #if !LJ_ABI_SOFTFP /* MIPS64 hard-float */
478
+ #define CALLBACK_HANDLE_REGARG \
479
+ if (ngpr + n <= maxgpr) { \
480
+ sp = isfp ? (void*) &cts->cb.fpr[ngpr] : (void*) &cts->cb.gpr[ngpr]; \
481
+ ngpr += n; \
482
+ goto done; \
483
+ }
484
+ #else /* MIPS64 soft-float */
485
+ #define CALLBACK_HANDLE_REGARG \
486
+ if (ngpr + n <= maxgpr) { \
487
+ UNUSED(isfp); \
488
+ sp = (void*) &cts->cb.gpr[ngpr]; \
489
+ ngpr += n; \
490
+ goto done; \
491
+ }
492
+ #endif
493
+
454
494
  #define CALLBACK_HANDLE_RET \
455
495
  if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \
456
496
  ((float *)dp)[1] = *(float *)dp;
@@ -542,7 +582,11 @@ static void callback_conv_args(CTState *cts, lua_State *L)
542
582
  nsp += n;
543
583
 
544
584
  done:
545
- if (LJ_BE && cta->size < CTSIZE_PTR)
585
+ if (LJ_BE && cta->size < CTSIZE_PTR
586
+ #if LJ_TARGET_MIPS64
587
+ && !(isfp && nsp)
588
+ #endif
589
+ )
546
590
  sp = (void *)((uint8_t *)sp + CTSIZE_PTR-cta->size);
547
591
  gcsteps += lj_cconv_tv_ct(cts, cta, 0, o++, sp);
548
592
  }
@@ -579,6 +623,10 @@ static void callback_conv_result(CTState *cts, lua_State *L, TValue *o)
579
623
  #if CCALL_NUM_FPR
580
624
  if (ctype_isfp(ctr->info))
581
625
  dp = (uint8_t *)&cts->cb.fpr[0];
626
+ #endif
627
+ #if LJ_TARGET_ARM64 && LJ_BE
628
+ if (ctype_isfp(ctr->info) && ctr->size == sizeof(float))
629
+ dp = (uint8_t *)&cts->cb.fpr[0].f[1];
582
630
  #endif
583
631
  lj_cconv_ct_tv(cts, ctr, dp, o, 0);
584
632
  #ifdef CALLBACK_HANDLE_RET
@@ -593,6 +641,12 @@ static void callback_conv_result(CTState *cts, lua_State *L, TValue *o)
593
641
  *(int32_t *)dp = ctr->size == 1 ? (int32_t)*(int8_t *)dp :
594
642
  (int32_t)*(int16_t *)dp;
595
643
  }
644
+ #if LJ_TARGET_MIPS64 || (LJ_TARGET_ARM64 && LJ_BE)
645
+ /* Always sign-extend results to 64 bits. Even a soft-fp 'float'. */
646
+ if (ctr->size <= 4 &&
647
+ (LJ_ABI_SOFTFP || ctype_isinteger_or_bool(ctr->info)))
648
+ *(int64_t *)dp = (int64_t)*(int32_t *)dp;
649
+ #endif
596
650
  #if LJ_TARGET_X86
597
651
  if (ctype_isfp(ctr->info))
598
652
  cts->cb.gpr[2] = ctr->size == sizeof(float) ? 1 : 2;