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

Add Unsafe.CopyBlockUnaligned #18801

Closed
benaadams opened this issue Sep 30, 2016 · 4 comments · Fixed by dotnet/corefx#12443
Closed

Add Unsafe.CopyBlockUnaligned #18801

benaadams opened this issue Sep 30, 2016 · 4 comments · Fixed by dotnet/corefx#12443
Labels
api-approved API was approved in API review, it can be implemented area-System.Runtime.CompilerServices help wanted [up-for-grabs] Good issue for external contributors
Milestone

Comments

@benaadams
Copy link
Member

That uses the .unaligned prefix

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

/cc @jkotas

@benaadams
Copy link
Member Author

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.

@jkotas
Copy link
Member

jkotas commented Oct 3, 2016

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

@nietras
Copy link
Contributor

nietras commented Oct 7, 2016

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?

@nietras
Copy link
Contributor

nietras commented Oct 7, 2016

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

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.0.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-System.Runtime.CompilerServices help wanted [up-for-grabs] Good issue for external contributors
Projects
None yet
4 participants