Make NativeCallableAttribute public.#33005
Conversation
|
/cc @Scottj1s |
|
/cc @MichalStrehovsky for CrossGen2 |
|
@janvorli Can you take a look at the work here and offer your thoughts on exceptions handling at the margins. @jkotas and I are in agreement that on Unix exceptions here aren't supported at this transition point, but on Windows we would want the typical behavior reverse P/Invoke behavior. Can you point me at an example of what I would need to do? Also, do you have any thoughts on the cost to support x86? |
|
@AaronRobinsonMSFT as for the EH on Linux, to ensure that we fail fast if there is an exception leaking from a method marked with NativeCallable, I can see two options here:
|
|
Thanks @janvorli. (1) seems like a generally less ideal approach - doesn't really handle the pay-for-play mentality we try to have in the interop space. I had been thinking about (2) as an option but wanted to hear from you first. Since you suggested it, I will reach out to the @dotnet/jit-contrib team and ask for some advice if flags already exist or how I should think about the work. Would (2) apply for both Windows and non-Windows? |
|
I think that (1) is the right way to do it. (2) adds performance overhead to the non-exception path for no good reason.
This fact is encoded in GCInfo. So all you need to do is to crack GCInfo of the method that is not a big deal on exception handing path. .NET Native / CoreRT - that has very pay-for-play and performance minded design - does exactly that. |
Ah, I have forgotten that. It is the reverse pinvoke frame stack slot info presence, right? |
Yep |
@jkotas Doesn't (1) imply that whenever a managed exception is thrown this check can occur? As opposed to (2) that will only occur if a reverse P/Invoke happens. I would assume that managed exceptions occur far more often than a reverse P/Invoke or am I missing something here? |
|
Update for PR. Spoke offline with @jkotas. The gist of the argument is that the exception path is already expensive and this check in the suggested area isn't going to move the needle in a measurable way; ergo (1) is appropriate. |
|
@AaronRobinsonMSFT I've made the change in the UnwindManagedExceptionPass1 and I was really simple. I can either share the diff or I can make it a separate PR after your changes get in. |
|
@janvorli W00t! Thank you much. If you can share the diff I will apply it. |
|
@jkotas @janvorli @MichalStrehovsky @jkoritzinsky Please take another look. I believe I have addressed all outstanding issues and added sufficient scenario testing. |
|
This is a performance optimization. Do you have any performance numbers? |
Oh ok, yea the link is not working well. With this link c78f4a4#diff-b06261f7127af3268df1f78173d20b34R1659 it's in I think your change would cover this case as well, it would go in with Unknown and use the slow path. |
|
Edited above to add file name |
Create macro for fail fast create thread.
src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs
Outdated
Show resolved
Hide resolved
jkotas
left a comment
There was a problem hiding this comment.
Just last few nits, but looks great otherwise
src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs
Outdated
Show resolved
Hide resolved
|
The Linux x64 Debug and Checked versions passed prior to the exception change in CrossGen2 so assuming they are not related to any changes here. |
Related to dotnet#33005
Related to dotnet#33653, dotnet#33005
Fixes #32462
TODO:
NativeCallableAttributetests pass./cc @jkotas @fadimounir @jeffschwMSFT @jkoritzinsky