Skip to content

[clr-interp] Fix peepCallConfigureAwait* peeps#129978

Open
BrzVlad wants to merge 2 commits into
dotnet:mainfrom
BrzVlad:fix-clrinterp-async-peeps
Open

[clr-interp] Fix peepCallConfigureAwait* peeps#129978
BrzVlad wants to merge 2 commits into
dotnet:mainfrom
BrzVlad:fix-clrinterp-async-peeps

Conversation

@BrzVlad

@BrzVlad BrzVlad commented Jun 29, 2026

Copy link
Copy Markdown
Member

The parsing validation was not matching the actual opcode peeps. Added comments and reordered the parsing in opcode order to make it easier to follow.

All these peeps failed on ConfigureAwait patterns, as tested on local sample. Validated both from C# as well as IL, to also hit the large local index path.

Fixes newly added System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_ConfigureAwaitFalse

The parsing validation was not matching the actual opcode peeps. Added comments and reordered the parsing in opcode order to make it easier to follow.

All these peeps failed on ConfigureAwait patterns, as tested on local sample. Validated both from C# as well as IL, to also hit the large local index path.

Fixes System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_ConfigureAwaitFalse
Copilot AI review requested due to automatic review settings June 29, 2026 13:57
@BrzVlad BrzVlad requested a review from janvorli as a code owner June 29, 2026 13:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the CoreCLR interpreter’s async-call peephole checks to align validation/parsing with the actual opcode peep patterns for ConfigureAwait(...) sequences, improving correctness and making the logic easier to follow.

Changes:

  • Fix ConfigureAwait Task peephole parsing to use the correct pattern offsets for the ldc.i4.* context flag and method tokens.
  • Reorder and correct ValueTask ConfigureAwait peephole parsing/validation (including local index match and ldc.i4.* handling) to reflect opcode order.
  • Add concise IL pattern comments above the affected checks to document the intended sequences.

@BrzVlad

BrzVlad commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

/azp run runtime-libraries-interpreter

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Peeps don't contain all matching opcodes. For example:
```
static OpcodePeepElement peepRuntimeAsyncCallConfigureAwaitValueTask_L_L[] = {
    // Call or CallVirt at the start (at offset 0)
    { 5, CEE_STLOC},
    { 9, CEE_LDLOCA },
    // LDC_I4_0 or LDC_I4_1 goes here (at offset 13
    { 14, CEE_CALL},
    { 19, CEE_CALL },
    { 24, CEE_ILLEGAL } // End marker
```

m_pCBB is the current basic block. Aka the bblock that the call at offset 0 belongs to. All future opcodes in the peep have not yet been reached by the interpreter compiler so the offset to bb isn't initialized for them (only the first instruction in the bblock is mapped). This means that, in the above example, we could have code where LDC_I4 is the first instruction in the bblock and previous code was failing to check it. The fix avoids storing extra information in the peeps for this minor check, instead validating each il offset in the peep range.
@BrzVlad

BrzVlad commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

/azp run runtime-libraries-interpreter

@BrzVlad

BrzVlad commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

/azp run runtime-interpreter

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

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.

3 participants