Skip to content

[crossgen2] Prevent inlining of PInvoke marshalling accross version bubbles #115277

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,11 @@ private bool IsNonVersionableWithILTokensThatDoNotNeedTranslationUncached(EcmaMe

public sealed override bool GeneratesPInvoke(MethodDesc method)
{
// Marshalling behavior isn't modeled as protected by R2R rules, so prevent inlining of marshalling
// defined outside of the version bubble.
if (!VersionsWithMethodBody(method))
return false;

return !Marshaller.IsMarshallingRequired(method);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3079,11 +3079,6 @@ private bool pInvokeMarshalingRequired(CORINFO_METHOD_STRUCT_* handle, CORINFO_S
Debug.Assert(!_compilation.NodeFactory.CompilationModuleGroup.GeneratesPInvoke(method));
return true;
}

// Marshalling behavior isn't modeled as protected by R2R rules, so disable pinvoke inlining for code outside
// of the version bubble
if (!_compilation.CompilationModuleGroup.VersionsWithMethodBody(method))
return true;
}
catch (RequiresRuntimeJitException)
{
Expand Down
Loading