Skip to content

Commit

Permalink
Report catch type dependencies in IL scanner (#102550)
Browse files Browse the repository at this point in the history
We were missing reporting the type used in a catch when it doesn't require a generic lookup. This can be a problem when such type is never thrown and the exception is generic (in which case we sometimes upgrade necessary types to constructed types and those need scanned vtables).

Found in the Pri 1 test suite.
  • Loading branch information
MichalStrehovsky authored May 22, 2024
1 parent 1ee41c6 commit 437a9a3
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,15 @@ private void StartImportingBasicBlock(BasicBlock basicBlock)
if (region.Kind == ILExceptionRegionKind.Catch)
{
TypeDesc catchType = (TypeDesc)_methodIL.GetObject(region.ClassToken);

// EH tables refer to this type
if (catchType.IsRuntimeDeterminedSubtype)
{
// For runtime determined Exception types we're going to emit a fake EH filter with isinst for this
// type with a runtime lookup
_dependencies.Add(GetGenericLookupHelper(ReadyToRunHelperId.TypeHandleForCasting, catchType), "EH filter");
_dependencies.Add(GetGenericLookupHelper(ReadyToRunHelperId.TypeHandleForCasting, catchType), "EH");
}
else
{
_dependencies.Add(_compilation.ComputeConstantLookup(ReadyToRunHelperId.TypeHandleForCasting, catchType), "EH");
}
}
}
Expand Down

0 comments on commit 437a9a3

Please sign in to comment.