Instead of checking every virtual method to see if it should be kept due to a base method every iteration of the MarkStep pipeline, check each method only when its relevant state has changed. These state changes are:
The override's declaring type is marked as instantiated
The base method is marked
The override's declaring type is marked as relevant to variant casting
This required some changes to TypeMapInfo:
modify GetBaseMethods to return OverrideInformation's
add a new method, GetInterfaceImplementors to get all types that implement a given interface.
I profiled the ASP.Net benchmark's build link time and got the following time in CPU ms:
27325 before the regression related to https://github.com/dotnet/linker/issues/3067
87310 in main
32011 after this change
This also changes behavior in a couple places:
When a type is marked as instantiated. Previously, we would mark all methods that override a method from a preserved scope, which would mark methods implementing an interface even if the interface implementation isn't kept. Now, the method should only be kept if the interface is marked and the interface implementation is marked.
~IDynamicInterfaceCastable is special cased to keep the interface implementation on all types that are instantiated or relevant to variant casting, regardless of whether or not IDynamicInterfaceCastable is marked or not.~
The IDynamicCastable test is updated to use the corelib descriptors to keep the IDynamicCastable interface implementations
Instead of checking every virtual method to see if it should be kept due to a base method every iteration of the MarkStep pipeline, check each method only when its relevant state has changed. These state changes are:
This required some changes to
TypeMapInfo
:GetBaseMethods
to return OverrideInformation'sGetInterfaceImplementors
to get all types that implement a given interface.I profiled the ASP.Net benchmark's build link time and got the following time in CPU ms: 27325 before the regression related to https://github.com/dotnet/linker/issues/3067 87310 in main 32011 after this change
This also changes behavior in a couple places:
Closes https://github.com/dotnet/linker/issues/3067 Closes https://github.com/dotnet/linker/issues/3069