-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Remove RawArrayData #110902
base: main
Are you sure you want to change the base?
Remove RawArrayData #110902
Conversation
// This field should be the first field in Array as the runtime/compilers depend on it | ||
private int _numComponents; | ||
#pragma warning restore | ||
internal uint RawLength; // Array._numComponents padded to IntPtr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should follow dotnet/runtime naming conventions for fields.
I do not see a problem with this performance wise. However, I expect that there is going to be a long tail of places that are not prepared to handle fields on array type. Some of them may be outside dotnet/runtime. There may be more straightforward (less breaking) ways to get rid of RawArrayData. For example, call |
Removes RawArrayData and makes Array reflect the actual runtime layout instead.
Makes code a bit safer by removing
Unsafe.As
usages with invalid types.cc @EgorBo @tannergooding I ended up doing this after the discussion on Discord
cc @jkotas There was one CoreCLR assert here due to array MT creation not setting the field count, I made it set it here in debug to avoid that and any perf impact in release, is that okay to do?