DISCLAIMER: the post contains my personal opinions on the subject. I would appreciate it if you could correct my mistakes.
|SpiderMonkey||Interpreter only||Interpreter and JIT|
|V8||JIT only for jailbroken devices||JIT|
Compatibility. The engine should support both iOS and Android, and work on both simulators and devices, which requires it support both ARM and x86.
Stability. It should stably work on both platforms and supported CPU architectures.
Small footprint. The memory footprint and binary size of the executable file should be small.
Rhino and V8 were out first since they don’t support iOS. I really wanted to build OpenAphid-Engine with V8, which showed great performance and elegant code structure during my preliminary experiment on Android. But I got disappointed due to the fact that V8 only employed a JIT mode while iOS doesn’t allow JIT unless on a jailbroken device. Please refer to issue #1312 if you need more technical details.
All test apps were built with LLVM 4.1 in release mode; all engines were running in interpreter mode restricted by iOS.
Explanations of some benchmarks:
1m-js_loopruns an empty loop for one million times.
1m-native_functioninvokes an injected native function for 1M times while the native function simply returns undefined.
fib(30)calculates Fibonacci(30) in a recursive manner.
sudoku-5solves five Sudoku problems with the algorithm from this project.
SpiderMonkey is fast on desktop with its advanced method tracing JIT. But it’s a whole different story on iOS devices.
The running time of
1m-native_functionwas over six times longer than
The C APIs had a clean design but was lack of flexible memory management APIs. It seemed difficult to resolve issues caused by circular references without deeper cooperation with the internal garbage collector.
I abandoned the original plan of using the C APIs in order to solve problem 1 and 2. The version of JSC from iOS 4.3.3 was used, as it’s faster than the version from iOS 5 in interpreter mode with a smaller binary executable file.
Engines Used in Other Products
|ngCore 1.6 and above||UIWebView||V8|
|ngCore 1.7 and later||SpiderMonkey||V8|