JIT: Fix alignment for custom layouts with GC refs in them#122873
JIT: Fix alignment for custom layouts with GC refs in them#122873jakobbotsch merged 1 commit intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #122859 by correcting the alignment calculation for custom layouts that contain GC references in async continuation layouts. The change ensures that custom layouts with GC pointers are properly aligned to TARGET_POINTER_SIZE instead of using an alignment of 1, which is necessary for correct GC tracking and memory layout.
Key Changes:
- Modified alignment logic for custom layouts to conditionally use
TARGET_POINTER_SIZEwhen GC pointers are present - Non-GC custom layouts retain alignment of 1
|
PTAL @dotnet/jit-contrib |
Well, the question is what is natural alignment for custom layouts. Alignment for metadata based structs is based on contained fields, and computed by the runtime, but custom layouts in the JIT are just collections of bytes of specified size with some GC pointers in them. Do you know if the backend makes use of any alignment information for struct copies/loads/stores? And if so, where? |
Not sure to be honest, except for types with GC being rounded up to pointer size? |
Yeah, I wonder if the logic we have that loads from memory actually is doing some unaligned loads in some cases. |
|
/ba-g iOS dead letter |
Fix #122859