-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Use a singleton sentinel for empty type-parameters for non-generic named-types and methods. #68131
Conversation
f9194a3
to
1930390
Compare
1930390
to
987c5bf
Compare
@jaredpar ptal. |
src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs
Outdated
Show resolved
Hide resolved
@@ -23,7 +23,6 @@ namespace Microsoft.CodeAnalysis.CSharp.Symbols | |||
/// </summary> | |||
internal abstract class SourceOrdinaryMethodSymbolBase : SourceOrdinaryMethodOrUserDefinedOperatorSymbol | |||
{ | |||
private readonly ImmutableArray<TypeParameterSymbol> _typeParameters; |
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.
methods were odd. _typeParameters was in SourceOrdinaryMethodSymbolBase (not SourceOrdinaryMethodSymbol), but was always empty for all other types. So this pushed this value down into SourceOrdinaryMethodSymbol, which could then use the new TypeParameterInfo object. All other methods just return 'Empty' from their TypeParameters
helpers.
Note: this also ends up saving this extra pointer from all other source methods.
/// <summary> | ||
/// Wrapper around type-parameter/constraints/constraint-kind info. We wrap this information (instead of inlining | ||
/// directly within type/method symbols) as most types/methods are not generic. As such, all those non-generic | ||
/// types can point at the singleton sentivel <see cref="Empty"/> value, and avoid two pointers of overhead. |
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.
fixed!
src/Compilers/CSharp/Portable/Symbols/Source/TypeParameterInfo.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Source/TypeParameterInfo.cs
Outdated
Show resolved
Hide resolved
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.
Done with review pass (iteration 6). Only minor comments
@dotnet/roslyn-compiler @cston ptal |
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 Thanks (iteration 10)
src/Compilers/CSharp/Portable/Symbols/Source/TypeParameterInfo.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Source/SourceOrdinaryMethodSymbol.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Source/SourceOrdinaryMethodSymbolBase.cs
Show resolved
Hide resolved
Done with review pass (commit 10) |
This is ready for 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.
LGTM (commit 13)
Small changes to address large heap usage of SourceNamedTypeSymbol and SourceOrdinaryMethodSymbol:
Takes us to:
Drops us 1.4%.