Skip to content

wasm - fix bitcasting between arrays and scalar types#17819

Merged
andrewrk merged 2 commits intoziglang:masterfrom
Luukdegram:wasm-bitcast-fix
Nov 2, 2023
Merged

wasm - fix bitcasting between arrays and scalar types#17819
andrewrk merged 2 commits intoziglang:masterfrom
Luukdegram:wasm-bitcast-fix

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