Re: LuaJIT - Cannot create state: not enough memory

  • From: Mike Pall <mike-1502@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 25 Feb 2015 18:28:10 +0100

Daniel Ayoub wrote:
> My apologies if I misspoke as as I'm still quite new to this. What I meant
> is that I successfully cross-compiled for MIPS64. No, I did not see
> anything about memory layout constraints. I assumed that if code compiled
> without error that it should run ok.

Ah, ok! Sorry, I realize my mistake now. I forgot to add a check
that shows an error when attempting to compile for a MIPS64
target. I've fixed that in the git repository -- thank you for the
bug report!

> From on what I saw luajit is supported on mips provided that there is an
> FPU. In my case that is OK. Is there something else I need to do to run
> luajit? Any recommendations on what to try differently when compiling to
> bypass memory bug?

LuaJIT is a virtual machine with a hand-written interpreter and a
JIT compiler. This means a port to another architecture is not as
simple as getting the C code to compile. The VM both runs on and
_generates_ machine code for the target architecture. You'll need
to handle all of the specifics of that architecture in various
parts of the code.

Ok, so MIPS32 and MIPS64 are pretty close, but still ... pointers
are double the size, the calling conventions are different, there
are several calling conventions to choose from, some instructions
behave differently, etc. ...

For a port you'd need to take a look at the ~4500 lines of
assembler code for the MIPS32 interpreter plus the MIPS32 backend
of the JIT compiler. This task is far from trivial and requires
deep knowledge about the specific CPU architecture and LuaJIT's
internals, too.

Also, since this is a 64 bit architecture, you'll face quite a few
more complications. Some of the latter have been resolved in the
v2.1 branch with the LJ_GC64 and LJ_FR2 modes. But that means one
has to rewrite substantial parts of the MIPS32 interpreter for a
MIPS64 port.

--Mike

Other related posts: