Skip to content

Add Unsafe.CopyBlockUnaligned #18801

Closed
dotnet/corefx
#12443

Description

@benaadams

That uses the .unaligned prefix

Has come up in dotnet/corefxlab#848 and aspnet/HttpAbstractions#717

/cc @jkotas

Activity

  1. benaadams commented on Sep 30, 2016

    @benaadams
    MemberAuthor

    It will currently work with core clr but might not with other runtimes and may not work in future dotnet/coreclr#7198 (comment)

    ECMA-355 says:
    "cpblk assumes that both destaddr and srcaddr are aligned to the natural size of the machine (but see the unaligned. prefix instruction). The operation of the cpblk instruction can be altered by an immediately preceding volatile. or unaligned. prefix instruction.

  2. jkotas commented on Oct 3, 2016

    @jkotas
    Member

    We should also add InitBlockUnaligned to make the surface symmetric. Looks good to me otherwise.

  3. nietras commented on Oct 7, 2016

    @nietras
    Contributor

    I am looking at adding this. Would this be fine:

      .method public hidebysig static void CopyBlockUnaligned(void* destination, void* source, uint32 byteCount) cil managed aggressiveinlining
      {
            .custom instance void System.Runtime.Versioning.NonVersionableAttribute::.ctor() = ( 01 00 00 00 )
            .maxstack 3
            ldarg.0
            ldarg.1
            ldarg.2
            unaligned. 0x1
            cpblk
            ret
      } // end of method Unsafe::CopyBlockUnaligned
    

    and:

      .method public hidebysig static void InitBlockUnaligned(void* startAddress, uint8 'value', uint32 byteCount) cil managed aggressiveinlining
      {
            .custom instance void System.Runtime.Versioning.NonVersionableAttribute::.ctor() = ( 01 00 00 00 )
            .maxstack 3
            ldarg.0
            ldarg.1
            ldarg.2
            unaligned. 0x1
            initblk
            ret
      } // end of method Unsafe::InitBlockUnaligned
    

    any suggestions for tests?

  4. nietras commented on Oct 7, 2016

    @nietras
    Contributor

    And what about the uint32 byteCount as far as I understand Span also need UIntPtr version, correct?

  5. transferred this issue fromdotnet/corefxon Jan 31, 2020
  6. added this to the 2.0.0 milestone on Jan 31, 2020
  7. ghost locked as resolved and limited conversation to collaborators on Dec 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions