Re:iOS 12 uses Lua code downloaded from Apple's servers
by pcwalton on Monday August 06, 2018 @11:08PM
(#17703625)
> There was a topic a few months ago about running JavaScript code in ring 0. People used similar arguments to claim it was safe enough. A v8 engineer chimed in to explain the reality of JavaScript engines.
I've worked with SpiderMonkey and have known the team for about a decade now. I'm aware of the complexity :)
> Consider the complexity of JavaScriptCore. Their new-ish "FTL" optimization engine stands for "Fourth Tier LLVM", which means there are at least 4 levels of runtime optimizations JSCore performs on code, which is a lot of non-trivial complexity. And JIT means they cannot utilize no-execute bits in hardware.
FTL is gone, I believe. But anyway, JSC is not just a JIT. If you're worried about the JIT, just use an interpreter.
> Then there is the memory and power-consumption. Lua's footprint for a VM instance is tiny. It is also a very efficient language, even in interpreted form. JavaScriptCore is comparatively heavy in both regards.
JSC uses a hand-written assembly interpreter. I would be shocked if it beat Lua in performance.
> For a core feature, it makes sense to have minimal dependencies with a minimal footprint so plenty of room is left for user applications.
JSC has been shipping since the first version of iOS in 2007. Tons of apps use embedded WebKit already.
> Remember that Apple Watch still does not have Safari and JavaScriptCore is not available for watchOS developers.
I've worked with SpiderMonkey and have known the team for about a decade now. I'm aware of the complexity :)
> Consider the complexity of JavaScriptCore. Their new-ish "FTL" optimization engine stands for "Fourth Tier LLVM", which means there are at least 4 levels of runtime optimizations JSCore performs on code, which is a lot of non-trivial complexity. And JIT means they cannot utilize no-execute bits in hardware.
FTL is gone, I believe. But anyway, JSC is not just a JIT. If you're worried about the JIT, just use an interpreter.
> Then there is the memory and power-consumption. Lua's footprint for a VM instance is tiny. It is also a very efficient language, even in interpreted form. JavaScriptCore is comparatively heavy in both regards.
JSC uses a hand-written assembly interpreter. I would be shocked if it beat Lua in performance.
> For a core feature, it makes sense to have minimal dependencies with a minimal footprint so plenty of room is left for user applications.
JSC has been shipping since the first version of iOS in 2007. Tons of apps use embedded WebKit already.
> Remember that Apple Watch still does not have Safari and JavaScriptCore is not available for watchOS developers.
This may well be the reason.