Skip to content

Conversation

@jtschuster
Copy link
Member

In ReflectionMethodBodyScanner and HandleCallAction, we do many of the same checks that already occur in GetIntrinsicIdFromMethod, and in a few places we have 'when' conditions that could just be regular cases. This removes the extra checks so the switch can be simpler and more optimized.

In the linker, we also get the IntrinsicId twice, so this adds an optional parameter for a known IntrinsicId.

Copy link
Member

@sbomer sbomer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

Copy link
Member

@vitek-karas vitek-karas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall

Debug.Assert (requiresDataFlowAnalysis || annotatedMethodReturnValue.DynamicallyAccessedMemberTypes == DynamicallyAccessedMemberTypes.None);

intrinsicId = Intrinsics.GetIntrinsicIdForMethod (calledMethod);
intrinsicId = knownIntrinsicId ?? Intrinsics.GetIntrinsicIdForMethod (calledMethod);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer we make the parameter mandatory. In linker it should be always known, in analyzer it isn't, but it's easy to call the helper.

&& calledMethod.HasParameterOfType (0, "System.Reflection.BindingFlags")
&& !calledMethod.IsStatic (): {

case IntrinsicId.Type_GetConstructors:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're in this area - could you please rename these enums to be more descriptive? For example GetMethods has two overloads, with and without parameters. This one is the one with the parameter, but the enum doesn't make that obvious in any way. So maybe GetMethod_BindingFlags or something like that.

There's a related work item #1623 which is about making the matches more specific and robust. Maybe not in this change, but it would be a really nice thing to cleanup.

Rename GetMembers(BindingFlags) enum variants
Make intrinsicId a required param
Add doc comments for a few intrinsicIds
@jtschuster jtschuster merged commit 6000a84 into dotnet:main Oct 7, 2022
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
…er#3060)

Remove redundant checks on intrinsicIds
Rename Get<Member>s(BindingFlags) enum variants
Make intrinsicId a required param
Add doc comments for a few intrinsicIds

Commit migrated from dotnet/linker@6000a84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants