-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[wasm][coreclr] Fix struct layout #122704
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
[wasm][coreclr] Fix struct layout #122704
Conversation
Fixes dotnet#122294 The default layout is now equal to the C struct layout. The auto layout is updated in the same way.
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.
Pull request overview
This PR fixes struct layout alignment for WebAssembly (WASM) in CoreCLR to match C language struct layout rules. The changes ensure that when a type requires 8-byte alignment on WASM, the actual field alignment requirement is consulted rather than hardcoding the alignment to 8 bytes, which aligns the behavior with C struct layout semantics.
- Updates auto layout handling to use actual field alignment requirements on WASM when types require 8-byte alignment
- Updates default layout handling with the same WASM-specific logic for consistency
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/vm/methodtablebuilder.cpp | Adds TARGET_WASM-specific logic in auto layout to use max(8, GetFieldAlignmentRequirement()) instead of hardcoded 8-byte alignment |
| src/coreclr/vm/classlayoutinfo.cpp | Adds TARGET_WASM-specific logic in default layout to use max(8, GetFieldAlignmentRequirement()) instead of hardcoded 8-byte alignment |
|
cc @jkoritzinsky @davidwrighton - field layout algorithm change |
3fff77a to
e37117a
Compare
…or types with GC references
e37117a to
9607a71
Compare
This reverts commit d278c46.
Fixes #122294
The default layout is now equal to the struct layout in C. The auto layout is updated in the same way.