Improve BitConverter.ToIntNN methods (dotnet/coreclr#9803)
authormikedn <onemihaid@hotmail.com>
Mon, 27 Feb 2017 20:44:27 +0000 (22:44 +0200)
committerJan Kotas <jkotas@microsoft.com>
Mon, 27 Feb 2017 20:44:27 +0000 (12:44 -0800)
commit05feb661328682976b8befde0625939d524efc82
tree9ae5b7850a81cd0032a9a1b5c8e3b014e3632f92
parentced92301b26c5a29fff7e09767020e7b82448a5f
Improve BitConverter.ToIntNN methods (dotnet/coreclr#9803)

* Improve BitConverter.ToIntNN methods

- Avoid duplicate argument validation
- Fix failed optimization attempt: (uint)i < a.Length needs to be (uint) < (uint)a.Length otherwise it gets promoted to long and that's bad for 32 bit architectures
- Workaround JIT limitation: fixed variables cannot be enregistered
- Use Unsafe.ReadUnaligned to avoid alignment handling complications
- Use Unsafe.As instead of fixed as it generates shorter code
- Don't forward unsigned method to signed methods. The JIT doesn't want to inline the signed methods even though the generated code isn't significantly larger

Commit migrated from https://github.com/dotnet/coreclr/commit/ac1dcaef3e9ddb5290b555db2aefca2adfe52419
src/coreclr/src/mscorlib/src/System/BitConverter.cs