mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
correct UTILS_FREE_DATA_PTR function calls
This commit is contained in:
parent
0d0a4a8806
commit
3238ee7d0d
2 changed files with 14 additions and 2 deletions
|
@ -586,22 +586,29 @@ trait Backend<'a> {
|
|||
let dst = Symbol::DEV_TMP;
|
||||
|
||||
let layout = *self.layout_map().get(symbol).unwrap();
|
||||
debug_assert!(!matches!(self.interner().get_repr(layout), LayoutRepr::Builtin(Builtin::List(_))), "List are no longer safe to refcount through pointer alone. They must go through the zig bitcode functions");
|
||||
|
||||
let alignment_bytes = self.interner().allocation_alignment_bytes(layout);
|
||||
let alignment = self.debug_symbol("alignment");
|
||||
self.load_literal_i32(&alignment, alignment_bytes as i32);
|
||||
|
||||
// elems_refcounted (always false except for list which are refcounted differently)
|
||||
let elems_refcounted = self.debug_symbol("elems_refcounted");
|
||||
self.load_literal(&elems_refcounted, &Layout::BOOL, &Literal::Bool(false));
|
||||
|
||||
// NOTE: UTILS_FREE_DATA_PTR clears any tag id bits
|
||||
|
||||
self.build_fn_call(
|
||||
&dst,
|
||||
bitcode::UTILS_FREE_DATA_PTR.to_string(),
|
||||
&[*symbol, alignment],
|
||||
&[Layout::I64, Layout::I32],
|
||||
&[*symbol, alignment, elems_refcounted],
|
||||
&[Layout::I64, Layout::I32, Layout::BOOL],
|
||||
&Layout::UNIT,
|
||||
);
|
||||
|
||||
self.free_symbol(&dst);
|
||||
self.free_symbol(&alignment);
|
||||
self.free_symbol(&elems_refcounted);
|
||||
|
||||
self.build_stmt(layout_ids, following, ret_layout)
|
||||
}
|
||||
|
|
|
@ -986,6 +986,8 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
|
|||
|
||||
fn stmt_refcounting_free(&mut self, value: Symbol, following: &'a Stmt<'a>) {
|
||||
let layout = self.storage.symbol_layouts[&value];
|
||||
debug_assert!(!matches!(self.layout_interner.get_repr(layout), LayoutRepr::Builtin(Builtin::List(_))), "List are no longer safe to refcount through pointer alone. They must go through the zig bitcode functions");
|
||||
|
||||
let alignment = self.layout_interner.allocation_alignment_bytes(layout);
|
||||
|
||||
// Get pointer and offset
|
||||
|
@ -1010,6 +1012,9 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
|
|||
// push the allocation's alignment
|
||||
self.code_builder.i32_const(alignment as i32);
|
||||
|
||||
// elems_refcounted (always false except for list which are refcounted differently)
|
||||
self.code_builder.i32_const(false as i32);
|
||||
|
||||
self.call_host_fn_after_loading_args(bitcode::UTILS_FREE_DATA_PTR);
|
||||
|
||||
self.stmt(following);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue