-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Pool instances of SymbolDisplayVisitor #70363
Conversation
src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Members.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.cs
Show resolved
Hide resolved
src/Compilers/Core/Portable/SymbolDisplay/AbstractSymbolDisplayVisitor.cs
Show resolved
Hide resolved
src/Compilers/Core/Portable/SymbolDisplay/AbstractSymbolDisplayVisitor.cs
Show resolved
Hide resolved
src/Compilers/Core/Portable/SymbolDisplay/AbstractSymbolDisplayVisitor.cs
Show resolved
Hide resolved
src/Compilers/Core/Portable/SymbolDisplay/AbstractSymbolDisplayVisitor.cs
Outdated
Show resolved
Hide resolved
@@ -385,15 +384,15 @@ public override void VisitMethod(IMethodSymbol symbol) | |||
{ | |||
containingType = symbol.ReceiverType; | |||
includeType = true; | |||
Debug.Assert(containingType != null); | |||
RoslynDebug.Assert(containingType != null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➡️ Currently, no. If in the future we have the ability to analyze linked variables (in this case, an effective 'not null when includeType is true'), it would make a difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If in the future we have the ability to analyze linked variables (in this case, an effective 'not null when includeType is true'), it would make a difference.
Why that would make a difference for RoslynDebug.Assert
, but not for Debug.Assert
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug.Assert
is not annotated in all target frameworks, but RoslynDebug.Assert
is. In general, null checks should always go through RoslynDebug
so the annotation applies consistently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I am buying this. I think Debug.Assert
works fine for the purpose of nullable analysis in this project, and I would prefer us transitioning in the opposite direction, i.e. stop using RoslynDebug
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➡️ Switched all uses of RoslynDebug
in this PR to Debug
src/Compilers/Core/Portable/SymbolDisplay/AbstractSymbolDisplayVisitor.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/SymbolDisplay/AbstractSymbolDisplayVisitor.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/SymbolDisplay/AbstractSymbolDisplayVisitor.cs
Outdated
Show resolved
Hide resolved
Done with review pass (commit 4) |
src/Compilers/VisualBasic/Portable/SymbolDisplay/SymbolDisplayVisitor.vb
Outdated
Show resolved
Hide resolved
Done with review pass (commit 5). Overall, LGTM, but there are two remaining questions. I would like to get them resolved before signing off. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (commit 6)
@dotnet/roslyn-compiler for second review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small comment. Otherwise looking good.
FreeNotFirstVisitor(_lazyNotFirstVisitorNamespaceOrType); | ||
|
||
_builder = null!; | ||
_format = null!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If _format
is the field we're using as a sentinel of "this thing is currently in use", we should set it to null
last.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➡️ I decided to keep these in the order the fields are declared in the type, so it's easy to see they are all included. The null check is not intended to suggest that the type is thread-safe; it merely serves to document a precondition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The null check is not intended to suggest that the type is thread-safe; it merely serves to document a precondition.
It doesn't suggest the type is threadsafe, but it does suggest that we're taking some amount of care to ensure that SymbolDisplayVisitor
isn't being reused by multiple things at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➡️ Relocated the assignment so this can get merged
b6c93d5
to
739bef5
Compare
After review, rebased to combine commits with no content changes. |
Addresses the 3rd most allocated object in AB#1899592 (123MB / 12,7%).
Review commit-by-commit recommended