Call AsyncMethodBuilder.Start on field not on local#41253
Call AsyncMethodBuilder.Start on field not on local#41253cston merged 2 commits intodotnet:masterfrom
Conversation
92a9a64 to
c3fd8d7
Compare
|
@benaadams Not sure why you requested my review, perhaps you were looking for someone else with a similar name or something? |
You raised issue "Unnecessary copy generated in async code" #21139 which this addresses? |
|
LOL, I have no recollection of ever opening such an issue in the Roslyn repo. I'll try to take a look when a get home from work. |
dd6b184 to
c3fd8d7
Compare
src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.cs
Show resolved
Hide resolved
|
The generated IL looks correct to me. Not familiar with Roslyn so I can't comment on the code change itself. |
What tool are you using to produce that ASCII art diagram of type layout? |
@SergeyTeplyakov's https://github.com/SergeyTeplyakov/ObjectLayoutInspector (nuget) |
|
Not sure an easy way to insert the assignment of So I guess this PR is as is |
|
Raised issue for Jit double zeroing dotnet/runtime#2325 |
|
Converts public async ValueTask<ReadResult> OuterMethod(object o)
{
return await InnerMethod(o);
static async ValueTask<ReadResult> InnerMethod(object o)
{
return default;
}
}From To |
|
@stephentoub are you good with the proposed code gen changes here? |
Seems fine. I can't think of anything this would negatively impact. |
|
Are similar changes applicable to VB compiler? |
It looks like VB calls |
|
@dotnet/roslyn-compiler for a second review, please. |
|
@benaadams, thanks for the contribution. |
Removes an unnecessary struct copy to local of the AsyncMethodBuilder-like; and calls
.Starton the mutable field and not the inert local copy.As well as being more semantically correct (see #41222) helps most with
AsyncValueTaskMethodBuilder<TResult>as they can be quite large.e.g. the
AsyncValueTaskMethodBuilderfor System.IO.PipelinesValueTask<ReadResult>at 48 bytes with 3 object referencesResolves: #20606