Skip to content

API change SequenceReader.ctor pass ReadOnlySequence via in #28836

@benaadams

Description

@benaadams
 public ref partial struct SequenceReader<T> where T : unmanaged, System.IEquatable<T>
 {
-    public SequenceReader(System.Buffers.ReadOnlySequence<T> sequence);
+    public SequenceReader(in System.Buffers.ReadOnlySequence<T> sequence);
 }

Drops 32-bytes of stack zeroing and this from call site

vmovdqu  xmm0, qword ptr [rbx]
vmovdqu  qword ptr [rbp-1D0H], xmm0
vmovdqu  xmm0, qword ptr [rbx+16]
vmovdqu  qword ptr [rbp-1C0H], xmm0

Its a 4 element struct so its unlikely to be covered by calling convention; however it is also an Aggressive Inline (albeit a frighteningly large one) and there has been speculation that the Jit could eventually elide the copy (@mikedn mentioned it on the ValueTaskAwaiter PR); though it doesn't currently.

@stephentoub raised the following concern dotnet/corefx#35678 (comment)

I would, however, urge us to avoid polluting methods like this with in unless we find that a) it makes a meaningful difference and b) we expect that difference will never be able to captured by JIT-level changes instead.

/cc @stephentoub @jkotas @AndyAyersMS

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions