[wasm][coreclr] Fix struct layout#122704
Merged
radekdoulik merged 9 commits intodotnet:mainfrom Jan 9, 2026
Merged
Conversation
Fixes dotnet#122294 The default layout is now equal to the C struct layout. The auto layout is updated in the same way.
Contributor
There was a problem hiding this comment.
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 |
jkotas
reviewed
Dec 22, 2025
Member
|
cc @jkoritzinsky @davidwrighton - field layout algorithm change |
3 tasks
jkotas
reviewed
Jan 2, 2026
3fff77a to
e37117a
Compare
…or types with GC references
e37117a to
9607a71
Compare
jkoritzinsky
approved these changes
Jan 5, 2026
jkoritzinsky
reviewed
Jan 5, 2026
This was referenced Jan 6, 2026
Open
davidwrighton
approved these changes
Jan 6, 2026
This reverts commit d278c46.
This was referenced Jan 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #122294
The default layout is now equal to the struct layout in C. The auto layout is updated in the same way.