You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
They are the same APIs that were previously available on macOS - pthread_jit_write_with_callback_np and PTHREAD_JIT_WRITE_ALLOW_CALLBACKS_NP, and they require new entitlements. Unfortunately, they are also distinct from the original pthread_jit_write_protect_np API that was introduced with macOS 11 to support Apple Silicon, and it requires a different approach to use it.
Neither CoreCLR nor MonoVM is currently structured in a way to make it easy to adapt.
This may possibly be interesting if we revive the CoreCLR on iOS (Simulator) PR, or as an option to enable JIT for Hot Restart (MonoVM) scenarios when deploying to iOS from Windows.
I hate to turn down the excitement. Unfortunately, the entitlements necessary to make this work are still restricted:
To build a web browser that uses an alternative browser engine, including the one in this sample project, you need to apply for certain entitlements from WWDR. For more information on how to use these entitlements, see Creating browser extensions in Xcode.
That severely restricts the usability. It still means that you can now officially use JIT on Mac Catalyst using supported APIs. I tested that scenario with ad-hoc signing but it should also work with the com.apple.security.cs.allow-jit entitlement which is not restricted on macOS.
Furthermore, the BrowserEngineKit APIs be_memory_inline_jit_restrict_rwx_to_rw_with_witness and be_memory_inline_jit_restrict_rwx_to_rx_with_witness match the functionality of pthread_jit_write_protect_np and may be easier to use for some quick hack to test the dev loop scenario. They are, however, restricted for App Store usage, so they are not a good replacement.
There’s a growing community of iOS users who rely on jit-based emulators via debugging. However, with the introduction of net 9+, jit is no longer supported on Work-in-progress programs, causing them to remain stuck on 8 when newer code is on 9+. I hope this issue will be addressed when jit is reintroduced for iOS DotNet.
@Spidy123222 could you please clarify on the usage of "jit-based emulators". AFAIK .NET on iOS never had a JIT because of the restrictions from the OS. While this issue describes some new ways of allowing JIT, it is still very limitted and effectively unusable for release apps (to the store). Given that store apps are the primary target for .NET on iOS, we don't have any plans to implement JIT on iOS. We do support interpreter, which should have effectively the same functionality, just different perf characteristics.
Please don't close it just yet. I think it's still relevant for debugging scenarios (Mac Catalyst, iOS Simulator). We currently enable these scenarios by unsanctioned usage of the pthread_jit_write_protect_np which works locally but it's obviously ineligible for wide distribution. Apple is pushing these new APIs and we may eventually need to migrate on macOS too.
I don't think the issue is immediately actionable though. We still have way too many places that use W^X memory. I've gradually tried to remove some of them and many were removed with the ongoing interpreter work.
Using pthread_jit_write_with_callback_np is not easy with the current W^X memory abstraction in CoreCLR. The current abstraction uses an object on the stack which provides methods to get writable memory, while the new Apple API basically requires a callback that receives a temporary pointer to the writable memory. It's not trivially possible to modify the current abstraction to work with pthread_jit_write_with_callback_np without compromising the intent of the callback API (ie. not using a single process-wide callback) or using large temporary buffers.
I am essentially waiting on the runtime to get in a better shape as part of the interpreter work to even pursue this task and experiment with it.
As for the thing @Spidy123222 mentioned. The emulators still rely on a debugger trick to enable the JIT. When the debugger is attached (or the system thinks it's attached) it allows some limitet JITing for function evaluation.
As for the thing @Spidy123222 mentioned. The emulators still rely on a debugger trick to enable the JIT. When the debugger is attached (or the system thinks it's attached) it allows some limited JITing for function evaluation.
Yeah this is what's used with developer accounts of users for more power user methods to run advanced emulation (things that cannot run on a interpiter well) or tools like flutter with Hot Reload via Dart or like what you said function evaluation.
I’m hoping to at least allow compilation for iOS to enable the execution of such programs with a flag to force the ability even if I'm not able to submit for AppStore or just allow it like before (whatever is preferred). This feature could also adapt to accommodate additional capabilities when iOS introduces more countries for just-in-time compilation with web browsers or other programs. However, Dotnet 9 rendered all of this functionality unusable when upgrading Dotnet 8 projects to Dotnet 9 to keep up with the original project's changes (These iOS projects tend to be forks or part of the main program like Flutter).
Activity
dotnet-policy-service commentedon Oct 1, 2024
Tagging subscribers to 'os-ios': @vitek-karas, @kotlarmilos, @ivanpovazan, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.
filipnavara commentedon Oct 1, 2024
I hate to turn down the excitement. Unfortunately, the entitlements necessary to make this work are still restricted:
That severely restricts the usability. It still means that you can now officially use JIT on Mac Catalyst using supported APIs. I tested that scenario with ad-hoc signing but it should also work with the
com.apple.security.cs.allow-jitentitlement which is not restricted on macOS.Furthermore, the BrowserEngineKit APIs
be_memory_inline_jit_restrict_rwx_to_rw_with_witnessandbe_memory_inline_jit_restrict_rwx_to_rx_with_witnessmatch the functionality ofpthread_jit_write_protect_npand may be easier to use for some quick hack to test the dev loop scenario. They are, however, restricted for App Store usage, so they are not a good replacement.dotnet-policy-service commentedon Oct 1, 2024
Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.
Spidy123222 commentedon Dec 29, 2024
There’s a growing community of iOS users who rely on jit-based emulators via debugging. However, with the introduction of net 9+, jit is no longer supported on Work-in-progress programs, causing them to remain stuck on 8 when newer code is on 9+. I hope this issue will be addressed when jit is reintroduced for iOS DotNet.
vitek-karas commentedon Jun 23, 2025
@Spidy123222 could you please clarify on the usage of "jit-based emulators". AFAIK .NET on iOS never had a JIT because of the restrictions from the OS. While this issue describes some new ways of allowing JIT, it is still very limitted and effectively unusable for release apps (to the store). Given that store apps are the primary target for .NET on iOS, we don't have any plans to implement JIT on iOS. We do support interpreter, which should have effectively the same functionality, just different perf characteristics.
vitek-karas commentedon Jun 23, 2025
@filipnavara I'm inclined to close this issue. I don't see us special casing macCatalyst on its own, and on iOS this is not very useful.
filipnavara commentedon Jun 23, 2025
Please don't close it just yet. I think it's still relevant for debugging scenarios (Mac Catalyst, iOS Simulator). We currently enable these scenarios by unsanctioned usage of the
pthread_jit_write_protect_npwhich works locally but it's obviously ineligible for wide distribution. Apple is pushing these new APIs and we may eventually need to migrate on macOS too.I don't think the issue is immediately actionable though. We still have way too many places that use W^X memory. I've gradually tried to remove some of them and many were removed with the ongoing interpreter work.
Using
pthread_jit_write_with_callback_npis not easy with the current W^X memory abstraction in CoreCLR. The current abstraction uses an object on the stack which provides methods to get writable memory, while the new Apple API basically requires a callback that receives a temporary pointer to the writable memory. It's not trivially possible to modify the current abstraction to work withpthread_jit_write_with_callback_npwithout compromising the intent of the callback API (ie. not using a single process-wide callback) or using large temporary buffers.I am essentially waiting on the runtime to get in a better shape as part of the interpreter work to even pursue this task and experiment with it.
As for the thing @Spidy123222 mentioned. The emulators still rely on a debugger trick to enable the JIT. When the debugger is attached (or the system thinks it's attached) it allows some limitet JITing for function evaluation.
filipnavara commentedon Jun 23, 2025
(Feel free to bump it to Future milestone though)
Spidy123222 commentedon Jun 24, 2025
Yeah this is what's used with developer accounts of users for more power user methods to run advanced emulation (things that cannot run on a interpiter well) or tools like flutter with Hot Reload via Dart or like what you said function evaluation.
I’m hoping to at least allow compilation for iOS to enable the execution of such programs with a flag to force the ability even if I'm not able to submit for AppStore or just allow it like before (whatever is preferred). This feature could also adapt to accommodate additional capabilities when iOS introduces more countries for just-in-time compilation with web browsers or other programs. However, Dotnet 9 rendered all of this functionality unusable when upgrading Dotnet 8 projects to Dotnet 9 to keep up with the original project's changes (These iOS projects tend to be forks or part of the main program like Flutter).