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

Fix workaround for static virtual methods #66290

Merged
merged 1 commit into from
Mar 7, 2022
Merged
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
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028.

The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
  • Loading branch information
MichalStrehovsky committed Mar 7, 2022
commit 6ea2bce0dc70f647e3a48493cac47eda2af2af90
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFacto
{
Debug.Assert(!factory.MetadataManager.IsReflectionBlocked(_method.GetTypicalMethodDefinition()));

// Depends on static virtual method support. Turning off reflection for now.
if (_method.IsVirtual && _method.Signature.IsStatic)
return null;

DependencyList dependencies = new DependencyList();
factory.MetadataManager.GetDependenciesDueToReflectability(ref dependencies, factory, _method);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ public static bool IsMethodSupportedInReflectionInvoke(MethodDesc method)
return false;
}

// TODO: Reflection invoking static virtual methods
if (method.IsVirtual && method.Signature.IsStatic)
return false;

// Everything else can go in the mapping table.
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/tools/aot/ILCompiler/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ static string ILLinkify(string rootedAssembly)
// Check that methods and types generated during compilation are a subset of method and types scanned
bool scanningFail = false;
DiffCompilationResults(ref scanningFail, compilationResults.CompiledMethodBodies, scanResults.CompiledMethodBodies,
"Methods", "compiled", "scanned", method => !(method.GetTypicalMethodDefinition() is EcmaMethod) || method.Name == "ThrowPlatformNotSupportedException" || method.Name == "ThrowArgumentOutOfRangeException");
"Methods", "compiled", "scanned", method => !(method.GetTypicalMethodDefinition() is EcmaMethod) || method.Name == "ThrowPlatformNotSupportedException" || method.Name == "ThrowArgumentOutOfRangeException" || method.Name == "ThrowArgumentException");
DiffCompilationResults(ref scanningFail, compilationResults.ConstructedEETypes, scanResults.ConstructedEETypes,
"EETypes", "compiled", "scanned", type => !(type.GetTypeDefinition() is EcmaType));

Expand Down