Skip to content
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

Collection expressions: empty Span optimization #70260

Conversation

RikkiGibson
Copy link
Contributor

Part of #68785

@RikkiGibson RikkiGibson requested a review from a team as a code owner October 5, 2023 21:18
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 5, 2023
@RikkiGibson RikkiGibson changed the base branch from main to features/CollectionLiterals October 5, 2023 21:19
@RikkiGibson RikkiGibson requested a review from a team October 5, 2023 21:51
@CyrusNajmabadi
Copy link
Member

Love it

IL_0005: newobj "System.ReadOnlySpan<T>..ctor(T[])"
IL_000a: call "MyCollection<T> MyCollectionBuilder.Create<T>(scoped System.ReadOnlySpan<T>)"
IL_000f: ret
.locals init (System.ReadOnlySpan<T> V_0)
Copy link
Member

Choose a reason for hiding this comment

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

Do we understand why the new codegen involves an additional local and IL instruction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

initobj expects an address on the stack. In some cases a new local is introduced in order to provide that.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (iteration 1)

@CyrusNajmabadi
Copy link
Member

Note: we should do this for 17.8. This is a very trivial change, but important to our messaging about collections and perf. Having a core span scenario work well is high on that list.

@RikkiGibson RikkiGibson merged commit 8fc28af into dotnet:features/CollectionLiterals Oct 6, 2023
25 checks passed
@RikkiGibson RikkiGibson deleted the empty-span-default branch October 6, 2023 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Feature - Collection Expressions untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants