-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EnC: Generate correct state mapping for methods containing await fore…
…ach (#69806)
- Loading branch information
Showing
32 changed files
with
1,405 additions
and
419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/Compilers/CSharp/Portable/BoundTree/BoundAwaitExpressionDebugInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Microsoft.CodeAnalysis.CodeGen; | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp; | ||
|
||
/// <summary> | ||
/// Debug info associated with <see cref="BoundAwaitExpression"/> to support EnC. | ||
/// </summary> | ||
/// <param name="AwaitId">The id of the generated await.</param> | ||
/// <param name="ReservedStateMachineCount"> | ||
/// The number of async state machine states to reserve. | ||
/// | ||
/// Any time multiple <see cref="BoundAwaitExpression"/>s might be associated with the same syntax node | ||
/// we need to make sure that the same number of state machine states gets allocated for the node, | ||
/// regardless of the actual number of <see cref="BoundAwaitExpression"/>s that get emitted. | ||
/// | ||
/// To do so one or more of the emitted <see cref="BoundAwaitExpression"/>s may | ||
/// reserve additional dummy state machine states so that the total number of states | ||
/// (one for each <see cref="BoundAwaitExpression"/> plus total reserved states) is constant | ||
/// regardless of semantics of the syntax node. | ||
/// | ||
/// E.g. `await foreach` produces at least one and at most two <see cref="BoundAwaitExpression"/>s: | ||
/// one for MoveNextAsync and the other for DisposeAsync. | ||
/// | ||
/// If the enumerator is async-disposable it produces two <see cref="BoundAwaitExpression"/>s with | ||
/// <paramref name="ReservedStateMachineCount"/> set to 0. | ||
/// | ||
/// If the enumerator is not async-disposable it produces a single <see cref="BoundAwaitExpression"/> with | ||
/// <paramref name="ReservedStateMachineCount"/> set to 1. | ||
/// | ||
/// The states are only reserved in DEBUG builds. | ||
/// </param> | ||
internal readonly record struct BoundAwaitExpressionDebugInfo(AwaitDebugId AwaitId, byte ReservedStateMachineCount); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 10 additions & 7 deletions
17
src/Compilers/CSharp/Portable/Generated/BoundNodes.xml.Generated.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.