lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

* Mike Pall:

> You can pass it any pointer value that is legal on x64 in
> user-mode under the currently supported 48 bit memory model. In
> practice this means it's accepted by lua_pushlightuserdata() if
> the highest 16 bits are zero (user-mode pointers can only point to
> addresses 0 .. 2^47-1).

I raised this on the x86_64 ABI mailing list.  The belief over there
is that all 2**64 pointer values are valid per the ABI.  It's just
that *addresses of objects* will always fall in the 2**48 sub-range.

Lua could do something similar to Objective Caml here.  To certain
routines in their VM, you may only pass valid pointers to objects you
created outside the VM (or pointing to somewhere in those objects).
All other pointers can be mutilated by the GC.  But adopting this
would change the Lua API.

Another option would be to box light userdata if it's outside the
2**48 range.