Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further optimize FindValidCloneMethod #48949

Merged
merged 4 commits into from
Nov 3, 2020

Conversation

333fred
Copy link
Member

@333fred 333fred commented Oct 27, 2020

#48935 optimizes one path that hits FindValidCloneMethod, but there are others that could do with the same fast-path optimization. In order to accomplish that, I introduced a new HasPossibleCloneMethod on NamedTypeSymbol, that returns whether the type could have a method on it that is a valid clone method. For source types, this is a quick syntax check to see if it's a record. For metadata types, it's a check on just the member names for something with the right name. This should prevent us from unnecessarily loading all method signatures from metadata whenever we check for a clone method

@333fred 333fred changed the title isrecord optimize further Further optimize FindValidCloneMethod Oct 27, 2020
dotnet#48935 optimizes one path that hits FindValidCloneMethod, but there are others that could do with the same fast-path optimization. In order to accomplish that, I introduced a new HasPossibleCloneMethod on NamedTypeSymbol, that returns whether the type _could_ have a method on it that is a valid clone method. For source types, this is a quick syntax check to see if it's a record. For metadata types, it's a check on just the member names for something with the right name. This should prevent us from unnecessarily loading all method signatures from metadata unnecessarily whenever we check for a clone method.
@333fred 333fred force-pushed the isrecord-optimize-further branch from 7d026ce to a3ada0c Compare October 27, 2020 18:09
@333fred 333fred marked this pull request as ready for review October 27, 2020 18:09
@333fred 333fred requested a review from a team as a code owner October 27, 2020 18:09
@333fred
Copy link
Member Author

333fred commented Oct 27, 2020

@AlekseyTs @dotnet/roslyn-compiler this is ready for review.

@333fred
Copy link
Member Author

333fred commented Oct 28, 2020

@dotnet/roslyn-compiler for reviews please.

@@ -349,6 +349,7 @@ internal override bool IsInterface
internal sealed override NamedTypeSymbol NativeIntegerUnderlyingType => null;

internal override bool IsRecord => false;
internal override bool HasPossibleWellKnownCloneMethod() => false;
Copy link
Member

Choose a reason for hiding this comment

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

How are records represented in the EE? This line caught me a bit off guard. Must be I don't have the full pictuer here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure how records are represented in EE, but this doesn't particularly change whatever it is. @tmat, does EE have records support? If so, we likely need to file a separate bug and make a change here.`

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Oct 30, 2020

Done with review pass (iteration 3) #Closed

@333fred
Copy link
Member Author

333fred commented Nov 2, 2020

@AlekseyTs @jaredpar addressed feedback.

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (iteration 4)

@333fred 333fred closed this Nov 2, 2020
@333fred 333fred reopened this Nov 2, 2020
@333fred 333fred merged commit ec6e52e into dotnet:master Nov 3, 2020
@333fred 333fred deleted the isrecord-optimize-further branch November 3, 2020 01:45
@ghost ghost added this to the Next milestone Nov 3, 2020
@allisonchou allisonchou removed this from the Next milestone Nov 24, 2020
@allisonchou allisonchou added this to the 16.9.P2 milestone Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants