is it prohibited using of JIT(just-in-time) compiled code in iOS app for AppStore?
Asked Answered
U

3

26

I heard that JIT compiled code is not allowed in iOS AppStore because placing executable code in heap is prohibited. It that right? Or just a rumor?

Unwritten answered 20/2, 2011 at 1:35 Comment(0)
H
8
  1. Installable code isn't allowed ("or" is the key word in 3.3.2). Everything (except Javascript) has to be statically linked.

  2. JIT compiling into Javascript source code text appears to be allowed. (Not a joke, there is a commercial compiler that does this.) Compiling into bytecode for execution by an interpreter written Javascript and running in a UIWebView may confuse the reviewers enough to possibly reject an app doing that.

  3. The iOS security sandbox will likely kill any app that tries to jump into any dynamically generated data.

Hannus answered 24/2, 2011 at 19:27 Comment(3)
#1 and #2 is not sure, but #3 makes me sure. Thanks!Unwritten
What about languages like Python, Lua, or GDScript?Garibaldi
Languages such as Python or Lua seem to be OK if interpreted or compiled to byte code and then interpreted, given a few restrictions mentioned in the 2024 Developer agreement. But compiling from Python to arm64 code and trying to jump into any new executable arm64 code is currently not allowed.Hannus
W
3

That is right. You can read in the iOS standard agreement, which you need to accept when setting up your developer enrollment:

3.3.2 An Application may not download or install executable code. Interpreted code may only be used in an Application if all scripts, code and interpreters are packaged in the Application and not downloaded. The only exception to the foregoing is scripts and code downloaded and run by Apple's built-in WebKit framework.

Wholesale answered 20/2, 2011 at 4:27 Comment(3)
It does not not seem to prohibit JIT..? It's just prohibits 'downloading'. JIT can be explained as a final step of script interpretation... Really confusing.Unwritten
The text you quote completely contradicts your statement. It says you're allowed to interpret so long as the code isn't downloaded by the application. This section did change within the last 6 months or so. I don't think it's prohibited any more.Piled
That line has changed but there are still warning about adding executable code. That's why Nitro is still only accessible using a Safari component. One misunderstanding you have is: Interpret != JIT. Interpreting is slow. Something like this buggy interpreted code can run regardless of the security settings. Python interpreter of single digit reverse polish notation limited to addition: input='34+1+7+'; temp=[];d=lambda x: temp.append(int(x)) if x != '+' else temp.append(temp.pop() + temp.pop());filter(d,input); print temp[-1]Zoology
R
2

JIT compiling into Javascript source code text appears to be allowed. (Not a joke, there is a commercial compiler that does this.) Compiling into bytecode for execution...

I also made my thoughts about a compiler (not JIT but real programming language) running on iOS. My idea was using addresses to assembler-written functions implementing pseudo-opcodes as instructions instead of "traditional bytecode" (1 byte per pseudo-opcode).

One ARM register is reserved as "code pointer" (here named "rCP") pointing into my "bytecode". The last instruction of a pseudo-opcode-function is "ldmfd rCP!, {pc}". This means the last instruction of the function is not a "return" but a jump into the next opcode.

Using this method you get very fast "bytecode". Maybe the commercial compiler works like this. I cannot believe that there is a JIT compiler running native code on iOS.

Retrench answered 1/11, 2011 at 6:55 Comment(1)
What you've just described Direct threading-- it's a common technique for implementing simple 'compilers' for languages.Duplessismornay

© 2022 - 2024 — McMap. All rights reserved.