Skip to content

Commit

Permalink
Fix scanning synchronized methods (#86427)
Browse files Browse the repository at this point in the history
After #85810 we need to generate reflection metadata for owning types of static synchronized methods. Before that change, obtaining a RuntimeType for locking would obtain a reflection blocked type. We now need a named type and scanner must predict it.

Found in Pri0 testing.
  • Loading branch information
MichalStrehovsky committed May 18, 2023
1 parent 73a06af commit aef327f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ public DependencyList Import()
{
_dependencies.Add(GetHelperEntrypoint(ReadyToRunHelper.MonitorEnterStatic), reason);
_dependencies.Add(GetHelperEntrypoint(ReadyToRunHelper.MonitorExitStatic), reason);

MethodDesc method = _methodIL.OwningMethod;
if (method.OwningType.IsRuntimeDeterminedSubtype)
{
_dependencies.Add(GetGenericLookupHelper(ReadyToRunHelperId.NecessaryTypeHandle, method.OwningType), reason);
}
else
{
_dependencies.Add(_factory.NecessaryTypeSymbol(method.OwningType), reason);
}
}
else
{
Expand Down

0 comments on commit aef327f

Please sign in to comment.