- Notifications
You must be signed in to change notification settings - Fork4.2k
RuntimeHelpers.CreateSpan optimization for stackalloc#57123
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
RuntimeHelpers.CreateSpan optimization for stackalloc#57123
Uh oh!
There was an error while loading.Please reload this page.
Conversation
972aacf to0f2120dCompare83489e2 to609cba8Compare609cba8 to432d5e0Compare804a997 to654aba8Comparesrc/Compilers/CSharp/Test/Emit/CodeGen/CodeGenStackAllocInitializerTests.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Compilers/CSharp/Portable/CodeGen/EmitStackAllocInitializer.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Compilers/CSharp/Portable/CodeGen/EmitStackAllocInitializer.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Compilers/CSharp/Portable/CodeGen/EmitStackAllocInitializer.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Compilers/CSharp/Portable/CodeGen/EmitStackAllocInitializer.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
70dd5b4 tode12627Compare
RikkiGibson 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.
cool!
cston commentedOct 14, 2021
Thanks@svick! |
alrz commentedApr 23, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
So this is not supposed to reach main? |
svick commentedApr 23, 2022
It is, at some point. As far as I can see, the required runtime code is ready (dotnet/runtime#60948 (comment)), so I think the next step would be to get answers to the questions I had above and then this could be probably merged into main. I don't know if I'm going to be able to do that soon. |
jaredpar commentedApr 25, 2022
It's on the list of features we're trying to get into C# 11. This feature is mostly in the "just need to find some keyboard time" vs. "needs a lot of design". That is why we've pushed it further back in the schedule as we've prioritized items that need more design work. The schedule is very tight right now though as we had a number of last second asks that we're dealing with. |
Uh oh!
There was an error while loading.Please reload this page.
This PR changes the IL generated for
stackallocin the following way:bytearrays directly from PE data; usinginitblkwhen all bytes are the same), there is no change.ReadOnlySpan<T>and all initializers are constant, the wholestackallocis replaced by a call toCreateSpan.Span<T>or when only some initializers are constant),CreateSpanis used as a part of regularstackalloccodegen, together withcpblk.The IL for array initializers is also changed:
bytewith all initializers constant is converted to ROS, the whole expression is replaced withCreateSpan.There are still some questions I have and things that would need addressing to make this code production quality:
GetPinnableReference(without any pinning) to get the backing data for the result ofCreateSpan, for use incpblk?LocalRewriter. Is there some way to do that?