Skip to content
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

Closed
Tracked by #80905
ivanpovazan opened this issue Feb 14, 2023 · 5 comments · Fixed by #82317
Closed
Tracked by #80905

Support marshalled delegates with NativeAOT on iOS platforms #82090

ivanpovazan opened this issue Feb 14, 2023 · 5 comments · Fixed by #82317
Assignees
Milestone

Comments

@ivanpovazan
Copy link
Member

ivanpovazan commented Feb 14, 2023

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:

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: xamarin/xamarin-macios#10470.

@ghost
Copy link

ghost commented Feb 14, 2023

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

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:

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.

Author: ivanpovazan
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: 8.0.0

@ivanpovazan
Copy link
Member Author

@filipnavara noted that there is also a third thunk allocation scheme which could serve the purpose: #81780 (comment)
Would you be interested in taking over this issue?

@ivanpovazan ivanpovazan added the os-ios Apple iOS label Feb 14, 2023
@ghost
Copy link

ghost commented Feb 14, 2023

Tagging subscribers to 'os-ios': @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

Issue Details

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:

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.

Author: ivanpovazan
Assignees: -
Labels:

os-ios, area-NativeAOT-coreclr

Milestone: 8.0.0

@filipnavara
Copy link
Member

I have a prototype ready, so I would be happy to take a stab at it once the iOS build support lands.

@ivanpovazan
Copy link
Member Author

Awesome, thanks! Assigning the issue to you then.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 17, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Feb 25, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Mar 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants