-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Call AsyncMethodBuilder.Start on field not on local #41253
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
Call AsyncMethodBuilder.Start on field not on local #41253
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 |
cston
left a comment
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 @benaadams!
|
@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