Repository navigation
Split up ReflectionMethodBodyScanner - #2796
Conversation
This separates the pieces which require the dataflow analysis from those that don't. Also includes a few other small cleanup changes (no functional changes).
|
|
||
| MethodDefinition? owningMethod; | ||
| while (context.CompilerGeneratedState.TryGetOwningMethodForCompilerGeneratedMember (member, out owningMethod)) { | ||
| Debug.Assert (owningMethod != member); |
There was a problem hiding this comment.
What is this assertion protecting against?
There was a problem hiding this comment.
It's just an incomplete way of declaring the expectation that TryGetOwningMethod... walks up to the owning member so that this isn't an infinite loop.
|
|
||
| namespace Mono.Linker.Dataflow | ||
| { | ||
| public class FlowInsensitiveReflectionScanner |
There was a problem hiding this comment.
Very odd name. If the type does not need DataFlow why is it in the namespace?
There was a problem hiding this comment.
I actually don't mind this being in the DataFlow - it is data flow, just not inside a method body.
Maybe we should split this further:
AttributeDataFlow- handle all of the attribute stuff - we could even move some of the code from MarkStep to here possibly (NativeAOT has lot more of the code in these methods as well).GenericArgumentDataFlow- just the generic stuff - it's going to be small, but so what.- And maybe we should then rename the
ReflectionMethodBodyScannertoMethodBodyDataFlow- or something like that. But I'm not sure about this - both names have downsides as well.
There was a problem hiding this comment.
Yes I was having trouble finding a good name for this. The difference is that attribute/generic parameter logic doesn't have locals or any state that needs to be tracked so it's arguably not really a dataflow analysis. But it computes the same kinds of results as the dataflow analysis in the method body scanner.
I think @vitek-karas's suggestion to split it further addresses this. I split it up into separate types for attribute/generic logic. I left ReflectionMethodBodyScanner because it's a pretty established name at this point, but happy to change it if you prefer.
|
|
||
| namespace Mono.Linker.Dataflow | ||
| { | ||
| public class FlowInsensitiveReflectionScanner |
There was a problem hiding this comment.
I actually don't mind this being in the DataFlow - it is data flow, just not inside a method body.
Maybe we should split this further:
AttributeDataFlow- handle all of the attribute stuff - we could even move some of the code from MarkStep to here possibly (NativeAOT has lot more of the code in these methods as well).GenericArgumentDataFlow- just the generic stuff - it's going to be small, but so what.- And maybe we should then rename the
ReflectionMethodBodyScannertoMethodBodyDataFlow- or something like that. But I'm not sure about this - both names have downsides as well.
- Use switch expression - Split into attribute/generic dataflow types - Use readonly structs - Avoid ValueNode naming - Simplify some existing code
| readonly MarkStep _markStep; | ||
| readonly MessageOrigin _origin; | ||
|
|
||
| public AttributeDataFlow (LinkContext context, MarkStep markStep, in MessageOrigin origin) |
There was a problem hiding this comment.
We only ever use one instance method once before the struct goes out of scope. I know since it's a struct on the stack, it shouldn't allocate so it isn't less performant than static methods, but is there a reason we follow this pattern instead of making the methods static?
There was a problem hiding this comment.
Mainly I followed it to stay consistent with how ReflectionMethodBodyScanner is invoked. In general I think this pattern can be an ok way to separate per-invocation arguments (like the attribute field/argument) from the ones that could be shared across invocations (like context/markstep) even though we don't actually reuse the AttributeDataFlow instance here.
* Split up ReflectionMethodBodyScanner This separates the pieces which require the dataflow analysis from those that don't. Also includes a few other small cleanup changes (no functional changes). * PR feedback - Use switch expression - Split into attribute/generic dataflow types - Use readonly structs - Avoid ValueNode naming - Simplify some existing code Commit migrated from dotnet/linker@8e738bb
This separates the pieces which require the dataflow analysis from those that don't.
Also includes a few other small cleanup changes (no functional changes).
Please let me know if you have better ideas for a name than
FlowInsensitiveReflectionScanner.This addresses the feedback in #2782 (comment)