mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Merge branch 'trunk' of github.com:rtfeldman/roc into str_to_num
This commit is contained in:
commit
aec8d1bf3d
29 changed files with 1845 additions and 548 deletions
|
@ -681,17 +681,13 @@ impl<'a> WasmBackend<'a> {
|
|||
}
|
||||
|
||||
Expr::Array { elems, elem_layout } => {
|
||||
if let StoredValue::StackMemory {
|
||||
location,
|
||||
alignment_bytes,
|
||||
..
|
||||
} = storage
|
||||
{
|
||||
if let StoredValue::StackMemory { location, .. } = storage {
|
||||
let size = elem_layout.stack_size(PTR_SIZE) * (elems.len() as u32);
|
||||
|
||||
// Allocate heap space and store its address in a local variable
|
||||
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);
|
||||
|
||||
let (stack_local_id, stack_offset) =
|
||||
|
@ -1051,12 +1047,11 @@ impl<'a> WasmBackend<'a> {
|
|||
|
||||
// Save the allocation address to a temporary local variable
|
||||
let local_id = self.storage.create_anonymous_local(ValueType::I32);
|
||||
self.code_builder.set_local(local_id);
|
||||
self.code_builder.tee_local(local_id);
|
||||
|
||||
// Write the initial refcount
|
||||
let refcount_offset = extra_bytes - PTR_SIZE;
|
||||
let encoded_refcount = (initial_refcount as i32) - 1 + i32::MIN;
|
||||
self.code_builder.get_local(local_id);
|
||||
self.code_builder.i32_const(encoded_refcount);
|
||||
self.code_builder.i32_store(Align::Bytes4, refcount_offset);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue