diff options
author | Sven Boemer <sbomer@gmail.com> | 2021-02-04 20:05:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-04 20:05:58 +0300 |
commit | ed3d6916e09600a02fe3818b33b33cda917e43fe (patch) | |
tree | 33f44f978ecd489d92268bd6a6f755478a44dd7d /.github | |
parent | faf9cc056e4c6481ba3c061521477185e37a1fce (diff) |
Enable processing of dynamically referenced assemblies (#1666)
* Remove LoadReferencesStep
Introduce TryResolve helper, and avoid some calls to GetLoadedAssembly
* Load assemblies lazily
- Run TypeMap logic on-demand
- Register every resolved assembly
so that it gets an action
- Process embedded XML files lazily
- Run body substitutions lazily
- Introduce abstraction to allow XML processing
to run before or during MarkStep
- Iterate over reference closure when needed
instead of only looking at loaded assemblies
- Track applied preserve info
so that it may be changed by new XML
- Only mark assemblies when used
- Introduce test attributes
to check instructions in other assemblies
- Add a base class for per-assembly logic
Squashed commit with updates, cleanup, PR feedback
Cleanup
Clean up copy/save mark logic
Call TryResolve where we used to look for loaded assemblies without throwing
Process XML from type forwarder assemblies
PR feedback
- Prefix "assembly" field with underscore
- Change "context" field to a property
Separate per-assembly step processing
Embedded XML is now read only when needed, with separate caches for descriptors,
substitutions, attributes, removing unreachable blocks, and remaining
per-assembly steps. The attribute cache is kept on CustomAttributeSource.
BaseAssemblyStep -> BasePerAssemblyStep
And don't implement IStep. Instead, take an assembly and context in the ctor.
Some PR feedback
- Don't change GetType use in attribute XML
- Add clarifying comments
- Avoid an extra cache for marking entire assembly
PR feedback
- remove Delete case (this command-line option will be removed)
- change EmbeddedXmlStep -> EmbeddedXmlInfo static class
PR feedback
- Don't support xml in pure facades
- Update constant prop test after rebase
- Slightly clean up RemoveUnreachableBlocksStep
* Add tests for swept references
And fix up some existing tests
* Add lazy loading testcases
- RemoveAttributeInstances from lazy XML
- Changing TypePreserve from lazy XML
- Substitutions from lazy XML
- Constant propagation in lazy assemblies
* Keep copy/save behavior for lazy assemblies
* Avoid loading all references while sweeping
* Ensure that unused assemblies have references removed
We used to remove references to any resolved assembly that was unused.
Now, an unused assembly may not have been resolved at all, so we need to
iterate over references that might resolve to an unused assembly to ensure
that they are removed.
Iterating over all references from loaded assemblies accomplishes this,
but we might miss a resolved unused assembly that was never referenced,
and never set its action to Delete. (This can happen for type forwarders,
for example.) A simple pre-pass over loaded assemblies ensures we handle
this case.
* Remove DynamicDependencyLookupStep
* Change corlib search order
To avoid loading mscorlib in most cases. Otherwise we load mscorlib and
do a bunch of unnecessary work to resolve all of its exported types.
Fixes CanEnableReducedTracing, which was getting a lot of spew from
the exported type marking for mscorlib.
* Fix behavior of mono steps
- Run RemoveSecurityStep for lazy assemblies
- Resolve mscorlib in LoadI18nAssemblies
* Turn on tracking of lazy pending members
* Move MarkExportedTypesTargetStep
* Hide substitution processing inside helper class
This class mediates access to the method actions which can be set by
substitution xml.
Also fix and enable the constant prop testcases which depend on
substitutions.
* Load all references for IDynamicInterfaceCastable
This preserves the behavior which searches all referenced assemblies
for interfaces with DynamicInterfaceCastableImplementationAttribute,
and keeps them if they implement any marked interfaces.
* PR feedback
- Clean up dead code
- Clean up use of non-generic IDictionary
- Add file headers
- Use static classes for per-assembly logic
- Link to open github issues
- Avoid "step" terminology for per-assembly logic
* Move attribute/substitution processing to cache initialization
Instead of calling EnsureProcessed at key points, the attribute XML
processing is now done as part of cache initialization when it is first
accessed.
GetCustomAttributes, GetAction, and similar will no longer trigger
processing that adds attributes to the global store. Instead, we maintain
separate global and per-assembly stores, where the precedence
(global > per-assembly) is explicit in the getters.
In the case of attributes, the precedence is not important because they
are additive, but it does matter for the method actions which can be
mutated.
As part of the change, the attribute/substitution steps have been separated
into steps (which run on command-line XML) and parsers (which are run on
cache initialization for the embedded XML). The steps are simple wrappers
that call the parsers. The parsers can either return a new object representing
the parsed information, or they can modify a passed-in object. The latter is
used for the command-line XML steps which modify the global store of attributes
or substitutions.
* Pick better names
CustomAttributeSource.GlobalXmlInfo -> GlobalAttributeInfo
LinkAttributesParser._xmlInfo -> _attributeInfo
* PR feedback
- Rename "Global" to "Primary"
- Use TryGetValue
- Use properties instead of fields
* Rename more things
- SubstitutionInfo.SetAction -> SetMethodAction
- SubstitutionInfo.SetSubstitutedInit -> SetFieldInit
- ProcessLinkerXmlStepBase -> ProcessLinkerXmlBase
* Separate shared XML logic from IStep interface
- Make ProcessLinkerXmlBase not an IStep
- Separate descriptor marking logic from IStep implementation in
ResolveFromXmlStep
- Introduce DescriptorMarker helper similar to the XML parsers
- Remove parse overload that returns XML info
- Provide context to ctor of XML processing logic
Diffstat (limited to '.github')
0 files changed, 0 insertions, 0 deletions