Re: luajit and iOS

  • From: Adam Strzelecki <ono@xxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 7 Sep 2012 00:08:10 +0200

This was already discussed some time ago on Lua ML (once there was no LuaJIT 
ML).

Have a look here:
http://lua-users.org/lists/lua-l/2011-04/msg01035.html

There is no physical/hardware limitation of JIT on iOS. Calling mprotect on iOS 
5 to set execute flag requires the app to have special entitlements (speaking 
only about non jailbroken device). The only app on iOS that has this 
entitlement is Safari because it needs that for Nitro JS engine.

So in theory your app could have such entitlement so iOS kernel will let you 
call mprotect to use JIT, but Apple won't issue such entitlement to you, even 
they if did, mprotect can be called only once and only for specific VM pages, 
which may be no-go for LuaJIT.

There's pretty decent book about such internals by Charlie Miller:
http://www.amazon.com/iOS-Hackers-Handbook-Charlie-Miller/dp/1118204123

Note that first iOS version that introduced support for mprotect was iOS 4, and 
due to the bug in its XNU kernel it was possible to set execute flag even 
having absolutely no entitlements to do so ;) Now in iOS 5 it is fixed and 
works as described above.

Cheers,
-- 
Adam Strzelecki


Other related posts: