-
Notifications
You must be signed in to change notification settings - Fork 126
Closed
Description
The changes made to solve #1164 will mean that we can't run the constant propagation and branch removal before MarkStep as not all assemblies will be loaded at that time. It also means the algorithm can't rely on having visibility into all assemblies at the same time.
So we need to change it to be:
- per-method - it could be per-assembly, but it doesn't help much (not a big difference between per-method and per-assembly) and would be wasteful
- on-demand - only compute the constant propagation and branch removal when needed - this is basically a fallback of making assembly loading on-demand
- called from MarkStep right before ProcessMethod - this is basically an optimization to only perform the computations for methods which are actually going to be marked (no need to compute this for methods which will be trimmed from the app)
To do this the plan is to:
- - refactor the
RemoveUnreachableBlocksStepso that it doesn't precompute constant returns for all methods - do this on-demand fromTryInlineBodyDependencies. But keep the iterative algorithm - meaning we will go over all methods multiple times to perform the recursive propagation. Only compute if method returns a constant when needed #1734 - - refactor the
RemoveUnreachableBlocksStepto perform constant propagation and branch removal truly on-demand - so basically introduce a method which will do it for a single method - remove the iterative part of the algorithm. Constant propagation without iterations and stack based #1756
This will probably mean to:- Introduce a queue of methods which must be processed
- When reaching a method call to a method which hasn't been processed, add it to the queue and re-try the current method later on (this is basically avoiding recursion - and replacing it with re-try and a queue)
- Ideally reduce the number of methods this needs to happen on even more
- - remove the
RemoveUnreachableBlocksStepcompletely and instead call the functionality fromMarkStepright beforeProcessMethod. So that it only happens on marked methods (but before we actually go and mark the method's body). Constant propagation directly from MarkStep #1771
/cc @sbomer @marek-safar
Reactions are currently unavailable