mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
Ensure WASM code gen uses proper tag ID alignment
We should use the alignment of the tag ID layout, not the alignment of the rest of the data in the tag union. The reason is that the tag ID may be smaller than the data.
This commit is contained in:
parent
235d6a9e88
commit
326bfe9aa3
1 changed files with 6 additions and 2 deletions
|
@ -830,7 +830,9 @@ impl<'a> WasmBackend<'a> {
|
|||
// Store the tag ID (if any)
|
||||
if stores_tag_id_as_data {
|
||||
let id_offset = data_offset + data_size - data_alignment;
|
||||
let id_align = Align::from(data_alignment);
|
||||
|
||||
let id_align = union_layout.tag_id_builtin().alignment_bytes(PTR_SIZE);
|
||||
let id_align = Align::from(id_align);
|
||||
|
||||
self.code_builder.get_local(local_id);
|
||||
|
||||
|
@ -912,7 +914,9 @@ impl<'a> WasmBackend<'a> {
|
|||
if union_layout.stores_tag_id_as_data(PTR_SIZE) {
|
||||
let (data_size, data_alignment) = union_layout.data_size_and_alignment(PTR_SIZE);
|
||||
let id_offset = data_size - data_alignment;
|
||||
let id_align = Align::from(data_alignment);
|
||||
|
||||
let id_align = union_layout.tag_id_builtin().alignment_bytes(PTR_SIZE);
|
||||
let id_align = Align::from(id_align);
|
||||
|
||||
self.storage
|
||||
.load_symbols(&mut self.code_builder, &[structure]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue