Re: JIT mcode alloc on Illumos

  • From: Theo Schlossnagle <jesus@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 3 Mar 2017 12:01:18 -0500

ping.. can someone merge this? It is

https://github.com/LuaJIT/LuaJIT/pull/292

And please pull it into the v2.1 branch as well?

On Fri, Feb 24, 2017 at 8:37 AM, Theo Schlossnagle <jesus@xxxxxxxxxx> wrote:

Howdy,

I've run into an issue where the address sanity checking for x64 prevents
stitching the JIT on Illumos.  The Illumos VM doesn't play exclusively in a
single 47bit VA.  The stack and the ld.so.1 target space are "up there."
 When I compile and link an executable 64bit and against libluajit, it will
place lj_vm_exit_handler "high"

; mdb -p `pgrep example`
Loading modules: [ ld.so.1 libumem.so.1 libmtev.so.0.0.7 libc.so.1 ]
lj_vm_exit_handler::whatis
fffffd7ffc21faf2 is libluajit-5.1.so.2.1.0`lj_vm_exit_handler, in
/opt/circonus/lib/amd64/libluajit-5.1.so.2.1.0 [fffffd7ffc1f0000,
fffffd7ffc279000)

This isn't a particular problem, but the proximity requirements of JITted
code to that symbol mean I need to hint an allocation "up there" and while
the mmap() on illumos will happily respect that hint and give me something
sufficiently close, there is a check in mj_mcode.c that prevents that from
working.  This patch fixes this for me; things JIT and stitch in just fine
now.

diff --git a/src/lj_mcode.c b/src/lj_mcode.c
index 0f29a3c..73e917e 100644
--- a/src/lj_mcode.c
+++ b/src/lj_mcode.c
@@ -204,7 +204,9 @@ static void mcode_protect(jit_State *J, int prot)

 /* -- MCode area allocation -----------------------------------------------
*/

-#if LJ_TARGET_X64
+#if LJ_TARGET_X64 && defined(__sun__)
+#define mcode_validptr(p)      (p)
+#elif LJ_TARGET_X64
 #define mcode_validptr(p)      ((p) && (uintptr_t)(p) < (uintptr_t)1<<47)
 #elif LJ_TARGET_ARM64 || LJ_TARGET_MIPS64
 /* We have no clue about the valid VA range. It could be 39 - 52 bits. */

If anyone sees unforeseen (by me) consequences of relaxing this sanity
check on Illumos, please let me know.  Otherwise, it would be great to have
this put back into the tree.

Best regards,

Theo

--

Theo Schlossnagle

http://omniti.com/is/theo-schlossnagle




-- 

Theo Schlossnagle

http://omniti.com/is/theo-schlossnagle

Other related posts: