-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support marshalled delegates with NativeAOT on iOS platforms #82090
Comments
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsNativeAOT supports marshalled delegates for platforms with hardened runtime by using a scheme of preallocated thunks which is available under the
Even though marshalled delegates are considered as a legacy feature, they can still be used in the user's code and even framework libraries (e.g., Xamarin: https://github.com/xamarin/xamarin-macios/blob/main/src/ObjCRuntime/Blocks.cs#L122) which means they have to be supported in some way. As a final note, NativeAOT supports function pointers which are preferred over marshalled delegates, as they have better performance and smaller footprint at runtime. Xamarin codebase is in process of fully switching to function pointers.
|
@filipnavara noted that there is also a third thunk allocation scheme which could serve the purpose: #81780 (comment) |
Tagging subscribers to 'os-ios': @steveisok, @akoeplinger Issue DetailsNativeAOT supports marshalled delegates for platforms with hardened runtime by using a scheme of preallocated thunks which is available under the
Even though marshalled delegates are considered as a legacy feature, they can still be used in the user's code and even framework libraries (e.g., Xamarin: https://github.com/xamarin/xamarin-macios/blob/main/src/ObjCRuntime/Blocks.cs#L122) which means they have to be supported in some way. As a final note, NativeAOT supports function pointers which are preferred over marshalled delegates, as they have better performance and smaller footprint at runtime. Xamarin codebase is in process of fully switching to function pointers.
|
I have a prototype ready, so I would be happy to take a stab at it once the iOS build support lands. |
Awesome, thanks! Assigning the issue to you then. |
NativeAOT supports marshalled delegates for platforms with hardened runtime by using a scheme of preallocated thunks which is available under the
FEATURE_FIXED_POOL_THUNKS
preprocessor directive. However, it seems the functions used by this scheme are implemented in assembler and are only supported on Windows:runtime/src/coreclr/nativeaot/Runtime/arm64/ThunkPoolThunks.asm
Line 4 in 8d3070f
Even though marshalled delegates are considered as a legacy feature, they can still be used in the user's code and even framework libraries (e.g., Xamarin: https://github.com/xamarin/xamarin-macios/blob/main/src/ObjCRuntime/Blocks.cs#L122) which means they have to be supported in some way.
As a final note, NativeAOT supports function pointers which are preferred over marshalled delegates, as they have better performance and smaller footprint at runtime. Xamarin codebase is in process of fully switching to function pointers: dotnet/macios#10470.
The text was updated successfully, but these errors were encountered: