Improve RuntimeHelpers.GetSubArray (dotnet/coreclr#23829)
* Improve RuntimeHelpers.GetSubArray
This change does three things.
First, it fixes `GetSubArray` to work when the supplied array is actually a `U[]` where `U : T`. Currently this case ends up throwing an exception inside of span, which doesn't like working with arrays covariantly.
Second, it fixes argument validation so that we throw an ArgumentNullException if the input array is null rather than NullReferenceException.
Third, it improves the performance of `GetSubArray` for the 95% common case where either `T` is a value type or the type of the array matches the `T` type specified.
* Only use `Array.Empty<T>` when `typeof(T[]) == array.GetType()`
Commit migrated from https://github.com/dotnet/coreclr/commit/
5fd24c69f75a1222a4d9b7abaed1c5712d47bd06