mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-22 11:32:27 +00:00
Do not require allocating Layouts in arena before interning
This should reduce memory spend, the interner has its own effective arena anyway
This commit is contained in:
parent
4652661a5c
commit
ce717dca8b
19 changed files with 161 additions and 171 deletions
|
@ -592,7 +592,7 @@ fn eq_boxed<'a>(
|
|||
ident_ids,
|
||||
ctx,
|
||||
layout_interner,
|
||||
*inner_layout,
|
||||
inner_layout,
|
||||
root.arena.alloc([a, b]),
|
||||
)
|
||||
.unwrap();
|
||||
|
@ -600,13 +600,13 @@ fn eq_boxed<'a>(
|
|||
Stmt::Let(
|
||||
a,
|
||||
a_expr,
|
||||
*inner_layout,
|
||||
inner_layout,
|
||||
root.arena.alloc(
|
||||
//
|
||||
Stmt::Let(
|
||||
b,
|
||||
b_expr,
|
||||
*inner_layout,
|
||||
inner_layout,
|
||||
root.arena.alloc(
|
||||
//
|
||||
Stmt::Let(
|
||||
|
@ -641,7 +641,7 @@ fn eq_list<'a>(
|
|||
let elem_layout = layout_interner.get(elem_layout);
|
||||
|
||||
// A "Box" layout (heap pointer to a single list element)
|
||||
let box_union_layout = UnionLayout::NonNullableUnwrapped(root.arena.alloc([*elem_layout]));
|
||||
let box_union_layout = UnionLayout::NonNullableUnwrapped(root.arena.alloc([elem_layout]));
|
||||
let box_layout = Layout::Union(box_union_layout);
|
||||
|
||||
// Compare lengths
|
||||
|
@ -754,14 +754,14 @@ fn eq_list<'a>(
|
|||
tag_id: 0,
|
||||
index: 0,
|
||||
};
|
||||
let elem1_stmt = |next| Stmt::Let(elem1, elem1_expr, *elem_layout, next);
|
||||
let elem2_stmt = |next| Stmt::Let(elem2, elem2_expr, *elem_layout, next);
|
||||
let elem1_stmt = |next| Stmt::Let(elem1, elem1_expr, elem_layout, next);
|
||||
let elem2_stmt = |next| Stmt::Let(elem2, elem2_expr, elem_layout, next);
|
||||
|
||||
// Compare the two current elements
|
||||
let eq_elems = root.create_symbol(ident_ids, "eq_elems");
|
||||
let eq_elems_args = root.arena.alloc([elem1, elem2]);
|
||||
let eq_elems_expr = root
|
||||
.call_specialized_op(ident_ids, ctx, layout_interner, *elem_layout, eq_elems_args)
|
||||
.call_specialized_op(ident_ids, ctx, layout_interner, elem_layout, eq_elems_args)
|
||||
.unwrap();
|
||||
|
||||
let eq_elems_stmt = |next| Stmt::Let(eq_elems, eq_elems_expr, LAYOUT_BOOL, next);
|
||||
|
|
|
@ -446,8 +446,8 @@ impl<'a> CodeGenHelp<'a> {
|
|||
) -> Layout<'a> {
|
||||
match layout {
|
||||
Layout::Builtin(Builtin::List(v)) => {
|
||||
let v = self.replace_rec_ptr(ctx, layout_interner, *layout_interner.get(v));
|
||||
let v = layout_interner.insert(self.arena.alloc(v));
|
||||
let v = self.replace_rec_ptr(ctx, layout_interner, layout_interner.get(v));
|
||||
let v = layout_interner.insert(v);
|
||||
Layout::Builtin(Builtin::List(v))
|
||||
}
|
||||
|
||||
|
@ -487,9 +487,7 @@ impl<'a> CodeGenHelp<'a> {
|
|||
|
||||
Layout::Boxed(inner) => {
|
||||
let inner = layout_interner.get(inner);
|
||||
let inner = self
|
||||
.arena
|
||||
.alloc(self.replace_rec_ptr(ctx, layout_interner, *inner));
|
||||
let inner = self.replace_rec_ptr(ctx, layout_interner, inner);
|
||||
let inner = layout_interner.insert(inner);
|
||||
Layout::Boxed(inner)
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ pub fn refcount_generic<'a>(
|
|||
ctx,
|
||||
layout_interner,
|
||||
&layout,
|
||||
inner_layout,
|
||||
&inner_layout,
|
||||
structure,
|
||||
)
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ where
|
|||
match layout {
|
||||
Layout::Builtin(Builtin::List(elem_layout)) => {
|
||||
let elem_layout = interner.get(*elem_layout);
|
||||
is_rc_implemented_yet(interner, elem_layout)
|
||||
is_rc_implemented_yet(interner, &elem_layout)
|
||||
}
|
||||
Layout::Builtin(_) => true,
|
||||
Layout::Struct { field_layouts, .. } => field_layouts
|
||||
|
@ -775,7 +775,7 @@ fn refcount_list<'a>(
|
|||
let elem_layout = layout_interner.get(elem_layout);
|
||||
|
||||
// A "Box" layout (heap pointer to a single list element)
|
||||
let box_union_layout = UnionLayout::NonNullableUnwrapped(arena.alloc([*elem_layout]));
|
||||
let box_union_layout = UnionLayout::NonNullableUnwrapped(arena.alloc([elem_layout]));
|
||||
let box_layout = Layout::Union(box_union_layout);
|
||||
|
||||
//
|
||||
|
@ -843,7 +843,7 @@ fn refcount_list<'a>(
|
|||
ident_ids,
|
||||
ctx,
|
||||
layout_interner,
|
||||
elem_layout,
|
||||
&elem_layout,
|
||||
LAYOUT_UNIT,
|
||||
box_union_layout,
|
||||
len,
|
||||
|
@ -1684,8 +1684,8 @@ fn refcount_boxed<'a>(
|
|||
ident_ids: &mut IdentIds,
|
||||
ctx: &mut Context<'a>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout: &Layout,
|
||||
inner_layout: &'a Layout,
|
||||
layout: &Layout<'a>,
|
||||
inner_layout: &Layout<'a>,
|
||||
outer: Symbol,
|
||||
) -> Stmt<'a> {
|
||||
let arena = root.arena;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue