mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
Wasm bugfix: allocate using the heap alignment, not the stack alignment
This commit is contained in:
parent
eeb4b20390
commit
acade33497
1 changed files with 3 additions and 7 deletions
|
@ -678,17 +678,13 @@ impl<'a> WasmBackend<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Expr::Array { elems, elem_layout } => {
|
Expr::Array { elems, elem_layout } => {
|
||||||
if let StoredValue::StackMemory {
|
if let StoredValue::StackMemory { location, .. } = storage {
|
||||||
location,
|
|
||||||
alignment_bytes,
|
|
||||||
..
|
|
||||||
} = storage
|
|
||||||
{
|
|
||||||
let size = elem_layout.stack_size(PTR_SIZE) * (elems.len() as u32);
|
let size = elem_layout.stack_size(PTR_SIZE) * (elems.len() as u32);
|
||||||
|
|
||||||
// Allocate heap space and store its address in a local variable
|
// Allocate heap space and store its address in a local variable
|
||||||
let heap_local_id = self.storage.create_anonymous_local(PTR_TYPE);
|
let heap_local_id = self.storage.create_anonymous_local(PTR_TYPE);
|
||||||
self.allocate_with_refcount(Some(size), *alignment_bytes, 1);
|
let heap_alignment = elem_layout.alignment_bytes(PTR_SIZE);
|
||||||
|
self.allocate_with_refcount(Some(size), heap_alignment, 1);
|
||||||
self.code_builder.set_local(heap_local_id);
|
self.code_builder.set_local(heap_local_id);
|
||||||
|
|
||||||
let (stack_local_id, stack_offset) =
|
let (stack_local_id, stack_offset) =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue