Workaround memset alignment sensitivity (dotnet/coreclr#24302)
* Workaround memset alignment sensitivity
memset is up to 2x slower on misaligned block on some types of hardware. The problem is uneven performance of "rep stosb"
used to implement the memset in some cases. The exact matrix on when it is slower and by how much is very complex.
This change workarounds the issue by aligning the memory block before it is passed to memset and filling in the potential misaligned
part manually. This workaround will regress performance by a few percent (<10%) in some cases, but we will gain up to 2x improvement
in other cases.
Fixes dotnet/coreclr#24300
Commit migrated from https://github.com/dotnet/coreclr/commit/
3661584ffcdeac6f35fa9e2485796a482ebbf7b3