# Jailed Just-in-Time Compilation on iOS

DevFeed: [Jailed Just-in-Time Compilation on iOS](<https://devfeed.tech/articles/jailed-just-in-time-compilation-on-ios-27354.md>)

Original publisher: [Read original article](<https://saagarjha.com/blog/2020/02/23/jailed-just-in-time-compilation-on-ios/>)

Published: 2020-02-23T00:00:00Z

Content type: tutorial

Language: en

Sources: [Saagar Jha](<https://devfeed.tech/sources/saagar-jha.md>)

Topics: [JIT](<https://devfeed.tech/topics/jit.md>), [iOS](<https://devfeed.tech/topics/ios.md>), [Security](<https://devfeed.tech/topics/security.md>), [virtual machines](<https://devfeed.tech/topics/virtual-machines.md>)

Tags: [ios](<https://devfeed.tech/tags/ios.md>), [jit](<https://devfeed.tech/tags/jit.md>), [security](<https://devfeed.tech/tags/security.md>), [virtual-machines](<https://devfeed.tech/tags/virtual-machines.md>), [writing](<https://devfeed.tech/tags/writing.md>)

## AI overview

This article explains how just-in-time compilation can work on iOS without a jailbreak despite the platform's dynamic-codesigning restrictions. It describes W^X permission switching and dual memory mappings that provide separate writable and executable views of the same physical page.

## Source excerpt

Just-in-time compilation on iOS normally requires applications to possess the dynamic-codesigning entitlement, a privilege that Apple uniquely awards to system processes that require the high-performance tiers of JavaScriptCore. "True" just-in-time compilers require the ability to generate executable pages with an invalid code signature, a practice that is usually prohibited on iOS for third-party apps because it sidesteps code validation guarantees that Apple would like to enforce. While these applications cannot use mmap's MAP_JIT without this entitlement (the usual way to create a RWX region for JIT purposes), there is a method that does work on devices without a jailbreak, though its combination of being unfit for the App Store and really only being useful for speeding up virtual machines makes it seemingly unknown outside of the emulation community. The technique relies on a somewhat arcane side effect of how debugging works on iOS to enable a slightly more limited JIT.