Skip to content
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

Shuffle fields in VMRuntimeLimits #9739

Merged
merged 2 commits into from
Dec 5, 2024

Conversation

alexcrichton
Copy link
Member

Right now this structure has a pointer-sized field, two 64-bit integers,
and then three pointer-sized fields. This structure's layout is
nontrivial to calculate on 32-bit platforms as it needs to take the
alignment of 64-bit integers into account which differs between ARM and
x86 for example. To make this easier shuffle all the 64-bit integers are now
first, which means we don't have to worry about alignment.

I'll note that this particular ordering is still a bit brittle because
we might need to shuffle things again if more fields are added. That
being said any misalignment is caught during testing of the wasmtime
crate so there's not much danger in adding more things, it'll just
require updating a few more locations.

Right now this structure has a pointer-sized field, two 64-bit integers,
and then three pointer-sized fields. This structure's layout is
nontrivial to calculate on 32-bit platforms as it needs to take the
alignment of 64-bit integers into account which differs between ARM and
x86 for example. To make this easier shuffle all the 64-bit integers are now
first, which means we don't have to worry about alignment.

I'll note that this particular ordering is still a bit brittle because
we might need to shuffle things again if more fields are added. That
being said any misalignment is caught during testing of the `wasmtime`
crate so there's not much danger in adding more things, it'll just
require updating a few more locations.
@alexcrichton alexcrichton requested a review from a team as a code owner December 5, 2024 01:23
@alexcrichton alexcrichton requested review from fitzgen and removed request for a team December 5, 2024 01:23
@alexcrichton
Copy link
Member Author

I'll note that the diff here looks scary but it's practically pretty small. The first commit is the actual change and the second commit is purely test expectation updates. This is because the offset of the stack-limit field has changed, and functions all have an explicit check of the stack limit.

@github-actions github-actions bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Dec 5, 2024
@fitzgen fitzgen added this pull request to the merge queue Dec 5, 2024
Merged via the queue into bytecodealliance:main with commit 1013851 Dec 5, 2024
42 checks passed
@alexcrichton alexcrichton deleted the shuffle-vmcontext branch December 5, 2024 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasmtime:api Related to the API of the `wasmtime` crate itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants