Trouble using LuaJIT on ARM with restrictions on allocatable memory

  • From: Mirolyub Hristov <mirosam@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 14 Nov 2014 18:36:20 +0100

I have an ARM device (ARM11 MPCore) and I'm trying to enable the JIT in
LuaJIT. I enabled debug tracing using v.lua and found out that all traces
fail
with the error MCODEAL (failed to allocate mcode memory).

Looking at the LuaJIT sources, the problem seems to be that mcode_alloc
tries
to allocate at an address within 32MB from the address of
lj_vm_exit_handler.
Unfortunately, on my platform this is impossible.

lj_vm_exit_handler lives at around 0x00200000 and the application can only
allocate from 0x08000000 and above. This is too far for a relative jump
which
makes the JIT never actually run.

I understand that LuaJIT wants to do this so it can use relative jumps and I
can allocate a large enough block such that it can jump around inside as
much
as it wants, but is there a way to use a "far jump" for the first entry and
not rely on the address being 25 bits away from lj_vm_exit_handler?

Thanks,
Mirolyub Hristov

Other related posts: