Finish support for rank 1 mdarrays#3610
Conversation
Three parts: 1. Update casting logic to allow casting SzArray to rank 1 MdArray (but not the other way around) 2. Update MdArray rank 1 methods to be able to operate on SzArrays 3. Update array creation path to emulate the behavior where allocating rank 1 MdArray with 0 lower bounds actually gives you an SzArray Third bullet point makes this the most annoying, because we can't reliably support `newobj instance void int32[0...]::.ctor(int32)` without hitting the type loader. I was also considering adding an optional field on Rank 1 MdArrays that lets you get to the SzArray's EEType from it. It might be better.
|
Wow, I had no idea that MdArray-1=>SzArray horsetrade was so deeply embedded into the runtime. Since you've put that logic into RuntimeAugments.NewMultiDimArray(), you can get rid of these checks: |
Checks removed. |
jkotas
left a comment
There was a problem hiding this comment.
Is it going to need a follow up change in ProjectN, or is it just going to work there?
|
@davidwrighton PTAL Now that I've slept on it, I thinking that the way to deal with
My preference is 1. |
If we want I can file a bug if you think we should support this, but we'll get a reminder about this when NUTC starts running against the CoreCLR test assets. I checked in a test for this a month ago or so. |
|
System.Private.Reflection.Execution/src/Internal/Reflection/Execution/TypeLoader/TypeCast.cs is missing the changes needed for this change. (In fact it appears to be missing array rank checks entirely). |
The method in TypeCast.cs where I had to do the change in Runtime.Base is not mirrored in that TypeCast.cs, so no changes are needed. The various IsArray/GetArrayRank checks are suspect, but it's a separate issue (it will lead to e.g. incorrectly considering I have also validated that the (yet another) copy of casting logic in |
* Make calling Rank 1 MdArray ctor more reliable. This is not a great fix (great fix would be one of the two options I enumerated in dotnet#3610), but at least makes the problem go away. It's unlikely anyone is going to use this anyway. * Fix exception types we throw.
* Make calling Rank 1 MdArray ctor more reliable. This is not a great fix (great fix would be one of the two options I enumerated in #3610), but at least makes the problem go away. It's unlikely anyone is going to use this anyway. * Fix exception types we throw.
Three parts:
not the other way around)
rank 1 MdArray with 0 lower bounds actually gives you an SzArray
Third bullet point makes this the most annoying, because we can't
reliably support
newobj instance void int32[0...]::.ctor(int32)without hitting the type loader. I was also considering adding an
optional field on Rank 1 MdArrays that lets you get to the SzArray's
EEType from it. It might be better.
Fixes #3331.