-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Disqualify byref-like fields from ManagedSequential layout #25056
Conversation
Seems to do the trick to get packing ignored on ref structs. Fixes #20794.
Cc @sergiy-k |
Do we need a test? |
I realized we also need to make sure these are not considered blittable for this to really work. It only worked for the test that was in the issue because bool happens to be not blittable. |
@@ -174,7 +174,8 @@ do \ | |||
TypeHandle pNestedType = fsig.GetLastTypeHandleThrowing(ClassLoader::LoadTypes, | |||
CLASS_LOAD_APPROXPARENTS, | |||
TRUE); | |||
if (pNestedType.GetMethodTable()->IsManagedSequential()) | |||
if (pNestedType.GetMethodTable()->IsManagedSequential() && | |||
!pNestedType.GetMethodTable()->IsByRefLike()) |
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.
I believe this may disable struct promotion on Span as I believe that ContainsPointers() is false. See Compiler::StructPromotionHelper::CanPromoteStructType in the jit, in particular if (StructHasCustomLayout(typeFlags) && ((typeFlags & CORINFO_FLG_CONTAINS_GC_PTR) == 0))
StructHasCustomLayout is another name for !ManagedSequential
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.
🕐
Okay, so I looked into this in more detail and this is actually also changing how we lay out Running the standard sequential field layout algorithm on I'll look if I can get the padding ignored while keeping byref-like types blittable/managedsequential (however wrong that sounds). |
Thank you for your contribution. As announced in dotnet/coreclr#27549 this repository will be moving to dotnet/runtime on November 13. If you would like to continue working on this PR after this date, the easiest way to move the change to dotnet/runtime is:
|
Thank you for your contribution. As announced in #27549 the dotnet/runtime repository will be used going forward for changes to this code base. Closing this PR as no more changes will be accepted into master for this repository. If you’d like to continue working on this change please move it to dotnet/runtime. |
Seems to do the trick to get packing ignored on ref structs.
Fixes #20794.