提交 9aa93b22 编写于 作者: P Pharring

DeltaBinder is another top allocation in C# typing traces (0.6%)

Made Binder concrete and eliminated DeltaBinder if the containingMemberOrLambda was null. (changeset 1215712)
上级 0e429ebc
......@@ -4,11 +4,10 @@
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CSharp
{
internal abstract partial class Binder
internal partial class Binder
{
private class QueryTranslationState
{
......
......@@ -5,11 +5,10 @@
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CSharp
{
internal abstract partial class Binder
internal partial class Binder
{
delegate BoundBlock LambdaBodyResolver(LambdaSymbol lambdaSymbol, ExecutableCodeBinder lambdaBodyBinder, DiagnosticBag diagnostics);
......
......@@ -3,12 +3,10 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CSharp
{
internal abstract partial class Binder
internal partial class Binder
{
/// <summary>
/// We represent the set of query variables in scope at a particular point by a RangeVariableMap.
......
......@@ -5,12 +5,11 @@
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp
{
internal abstract partial class Binder
internal partial class Binder
{
// A binder that finds query variables (BoundRangeVariableSymbol) and can bind them
// to the appropriate rewriting involving lambda parameters when transparent identifiers are involved.
......
......@@ -14,9 +14,8 @@ namespace Microsoft.CodeAnalysis.CSharp
/// A Binder converts names in to symbols and syntax nodes into bound trees. It is context
/// dependent, relative to a location in source code.
/// </summary>
internal abstract partial class Binder
internal partial class Binder
{
internal CSharpCompilation Compilation { get; private set; }
private readonly Binder next;
......
......@@ -2,11 +2,8 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp
{
......@@ -14,7 +11,7 @@ namespace Microsoft.CodeAnalysis.CSharp
/// This portion of the binder converts a AnonymousObjectCreationExpressionSyntax into
/// a bound anonymous object creation node
/// </summary>
internal abstract partial class Binder
internal partial class Binder
{
private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpressionSyntax node, DiagnosticBag diagnostics)
{
......
......@@ -7,12 +7,11 @@
using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp
{
internal abstract partial class Binder
internal partial class Binder
{
#region Bind All Attributes
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using System.Collections.Generic;
namespace Microsoft.CodeAnalysis.CSharp
{
/// <summary>
/// This portion of the binder converts an AwaitExpressionSyntax into a BoundExpression
/// </summary>
internal abstract partial class Binder
internal partial class Binder
{
private BoundExpression BindAwait(PrefixUnaryExpressionSyntax node, DiagnosticBag diagnostics)
{
......
......@@ -5,12 +5,11 @@
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp
{
internal abstract partial class Binder
internal partial class Binder
{
/// <summary>
/// Return a collection of bound constraint clauses indexed by type parameter
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using System.Collections.Generic;
namespace Microsoft.CodeAnalysis.CSharp
{
internal abstract partial class Binder
internal partial class Binder
{
protected BoundExpression CreateConversion(
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Roslyn.Utilities;
using System.Collections.Generic;
namespace Microsoft.CodeAnalysis.CSharp
{
internal abstract partial class Binder
internal partial class Binder
{
internal ImmutableArray<Symbol> BindCref(CrefSyntax syntax, out Symbol ambiguityWinner, DiagnosticBag diagnostics)
{
......
......@@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.CSharp
/// <summary>
/// This portion of the binder converts an <see cref="ExpressionSyntax"/> into a <see cref="BoundExpression"/>.
/// </summary>
internal abstract partial class Binder
internal partial class Binder
{
/// <summary>
/// Determines whether "this" reference is available within the current context.
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace Microsoft.CodeAnalysis.CSharp
{
internal abstract partial class Binder
internal partial class Binder
{
/// <summary>
/// Represents a small change from the enclosing/next binder.
/// Can specify a BindingLocation and/or a ContainingMemberOrLambda.
/// Can specify a BindingLocation and a ContainingMemberOrLambda.
/// </summary>
private sealed class DeltaBinder : Binder
private sealed class BinderWithContainingMemberOrLambda : Binder
{
private readonly Symbol containingMemberOrLambda;
internal DeltaBinder(BinderFlags location, Binder next, Symbol containingMemberOrLambda = null)
: base(next, location)
internal BinderWithContainingMemberOrLambda(Binder next, Symbol containingMemberOrLambda)
: base(next)
{
this.containingMemberOrLambda = containingMemberOrLambda ?? Next.ContainingMemberOrLambda;
this.containingMemberOrLambda = containingMemberOrLambda;
}
internal BinderWithContainingMemberOrLambda(Binder next, BinderFlags flags, Symbol containingMemberOrLambda)
: base(next, flags)
{
this.containingMemberOrLambda = containingMemberOrLambda;
}
internal override Symbol ContainingMemberOrLambda
......@@ -31,20 +36,20 @@ internal Binder WithFlags(BinderFlags flags)
{
return this.Flags == flags
? this
: new DeltaBinder(flags, this);
: new Binder(this, flags);
}
internal Binder WithAdditionalFlags(BinderFlags flags)
{
return this.Flags.Includes(flags)
? this
: new DeltaBinder(this.Flags | flags, this);
: new Binder(this, this.Flags | flags);
}
internal Binder WithContainingMemberOrLambda(Symbol containing)
{
Debug.Assert((object)containing != null);
return new DeltaBinder(this.Flags, this, containing);
return new BinderWithContainingMemberOrLambda(this, containing);
}
/// <remarks>
......@@ -54,14 +59,14 @@ internal Binder WithContainingMemberOrLambda(Symbol containing)
internal Binder WithAdditionalFlagsAndContainingMemberOrLambda(BinderFlags flags, Symbol containing)
{
Debug.Assert((object)containing != null);
return new DeltaBinder(this.Flags | flags, this, containing);
return new BinderWithContainingMemberOrLambda(this, this.Flags | flags, containing);
}
internal Binder WithUnsafeRegionIfNecessary(SyntaxTokenList modifiers)
{
return (this.Flags.Includes(BinderFlags.UnsafeRegion) || !modifiers.Any(SyntaxKind.UnsafeKeyword))
? this
: new DeltaBinder(this.Flags | BinderFlags.UnsafeRegion, this);
: new Binder(this, this.Flags | BinderFlags.UnsafeRegion);
}
internal Binder WithCheckedOrUncheckedRegion(bool @checked)
......@@ -73,7 +78,7 @@ internal Binder WithCheckedOrUncheckedRegion(bool @checked)
return this.Flags.Includes(added)
? this
: new DeltaBinder((this.Flags & ~removed) | added, this);
: new Binder(this, (this.Flags & ~removed) | added);
}
}
}
......@@ -5,11 +5,10 @@
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CSharp
{
internal abstract partial class Binder
internal partial class Binder
{
// An anonymous function can be of the form:
//
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CSharp
{
partial class Binder
internal partial class Binder
{
/// <summary>
/// <para>Once a simple name has been bound to a particular symbol, we need to ensure that symbol is the
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
using System.Collections.Generic;
namespace Microsoft.CodeAnalysis.CSharp
{
internal abstract partial class Binder
internal partial class Binder
{
private BoundExpression BindCompoundAssignment(BinaryExpressionSyntax node, DiagnosticBag diagnostics)
{
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
......@@ -7,14 +8,13 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
using System.Collections.Generic;
namespace Microsoft.CodeAnalysis.CSharp
{
/// <summary>
/// This portion of the binder converts a QueryExpressionSyntax into a BoundExpression
/// </summary>
internal abstract partial class Binder
internal partial class Binder
{
const string transparentIdentifierPrefix = "<>h__TransparentIdentifier";
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
using System.Collections.Generic;
namespace Microsoft.CodeAnalysis.CSharp
{
/// <summary>
/// This portion of the binder reports errors arising from resolving queries.
/// </summary>
internal abstract partial class Binder
internal partial class Binder
{
/// <summary>
/// This is a clone of the Dev10 logic for reporting query errors.
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Diagnostics;
using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
using System.Collections.Generic;
namespace Microsoft.CodeAnalysis.CSharp
{
/// <summary>
/// This portion of the binder converts StatementSyntax nodes into BoundStatements
/// </summary>
internal abstract partial class Binder
internal partial class Binder
{
/// <summary>
/// This is the set of parameters and local variables that were used as arguments to
......
......@@ -8,13 +8,11 @@
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.RuntimeMembers;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
using Cci = Microsoft.Cci;
namespace Microsoft.CodeAnalysis.CSharp
{
internal abstract partial class Binder
internal partial class Binder
{
/// <summary>
/// Binds the type for the syntax taking into account possibility of "var" type.
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Diagnostics;
using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Symbols;
namespace Microsoft.CodeAnalysis.CSharp
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Immutable;
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
using System.Collections.Generic;
namespace Microsoft.CodeAnalysis.CSharp
{
internal abstract partial class Binder
internal partial class Binder
{
// Diagnostics are generated in a separate pass when we emit.
internal ImmutableArray<Symbol> BindXmlNameAttribute(XmlNameAttributeSyntax syntax, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CSharp
{
/// <summary>
......
......@@ -4,7 +4,6 @@
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CSharp
{
......
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CSharp
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册