Skip to content

wasm - fix bitcasting between arrays and scalar types #17819

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

Merged
merged 2 commits into from
Nov 2, 2023

Conversation

Luukdegram
Copy link
Contributor

A bug was discovered by #17802, where in the Wasm backend it didn't correctly bitcast values between array and scalar types. This fixes that and re-enables the behavior tests as well as the default test-runner.

Arrays are currently always passed by reference, this means that we
always keep the value in linear memory and never load it to Wasm's
stack. Scalar values however do get lowered to Wasm's stack.
This means when bitcasting from an array to a scalar value, we must
load the memory of the array as such scalar type. To bitcast
a scalar type to an array, we allocate a new temporary in the
linear data segment, and then store the scalar value there.
@andrewrk andrewrk merged commit d892665 into ziglang:master Nov 2, 2023
@Luukdegram Luukdegram deleted the wasm-bitcast-fix branch November 2, 2023 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants