-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[Mono] Implement support for UnsafeAccessorAttribute #86040
Comments
/cc @SamMonoRT |
It doesn't look like we will need anything special to skip accessibility checks for fields For something like class MyClass {
private MyFieldType MyField;
...
}
[UnasafeAccessor(UnsafeAccessorKind.Field, Name="MyField")]
static extern ref MyFieldType GetMyField(MyClass c); the ilgen could use
for method calls, |
For generic field access we can't use |
@lambdageek I've added #86161 for CoreCLR. |
There's also a question of when do we create the IL for this "extern" method which is sort of interesting. I think for JIT/AOT we can actually do it during the call to I guess the question is whether the same logic that we use for dllimports and icalls will work for plain "extern" methods. (I'm pretty sure that's not the case - we look for the |
I guess the thing to pattern this on is where we call and in general we probably should treat these as special kind of wrappers, kind of like So we should add new subtypes of |
From #81741 (comment):
|
@lambdageek See the updates to |
All the work planned for .NET8 has been completed. Moving this tracking issue to 9.0.0 |
This can be closed. The remaining work is tracked by #89439 |
Implement support for "zero overhead member access with suppressed visibility checks" #81741 for the mono JIT/AOT and interp
UnsafeAccessorAttribute
as a well-known attribute to the runtimeWe will need to extract a named string-value property from the custom attribute ([Mono] UnsafeAccessorAttribute non-generic support for field #88626)
static extern
methods with the attribute and trigger emitting the method wrapper for UnsafeAccessor ([Mono] UnsafeAccessorAttribute non-generic support for field #88626)(test cases:
Verify_IgnoreCustomModifier
,Verify_UnmanagedCallConvBitAreTreatedAsCustomModifiersAndIgnored
,Verify_ManagedUnmanagedFunctionPointersDontMatch
andVerify_InvalidTargetUnsafeAccessorAmbiguousMatch
)There might be some mild complication here for working with generics (the
static extern
method will be generic in that case) - our ilgen method builder might not support generics (in which case it will have to be extended)The text was updated successfully, but these errors were encountered: