-
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
Inliner: don't inline callees with pinvokes inside EH #79125
Comments
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue Details[DllImport("user32.dll")]
static extern byte MessageBeep(uint uType);
static void Foo()
{
MessageBeep(42);
}
static void Test()
{
try
{
Foo();
}
catch
{
}
} Inliner should not inline callees with pinvokes to try/catch handlers because we never inline pinvoke machinery in JIT for those. So ^ snippet ends up generating:
but if we mark
|
Related issue around enabling inlining a P/Invoke inside a try block with a catch block (amongst other things around P/Invokes and exception handling): #70109 |
@jkoritzinsky thanks, didn't notice that - do you think it's worth doing as a quick workaround (I'd expect it to be a simple change) until we support what you suggested in #70109? |
Yes, I think it's definitely worth doing! It might also be worth avoiding inlining calls to functions that contain P/Invokes in finally blocks, as it has the same issue. If we do both cases (don't inline call to function with P/Invoke in try or finally blocks), I think we can finally complete #69758 and remove the P/Invoke stub emitter support from crossgen2 without causing any regressions for common use cases. |
Inliner should not inline callees with pinvokes to try/catch handlers because we never inline pinvoke machinery in JIT for those. So ^ snippet ends up generating:
but if we mark
Foo
as[MethodImpl(MethodImplOptions.NoInlining)]
we won't emitIL_STUB_PInvoke
The text was updated successfully, but these errors were encountered: