remove clone

This commit is contained in:
Folkert 2024-06-29 13:31:54 +02:00
parent 413d6621c0
commit 14b02c5827
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 12 additions and 18 deletions

View file

@ -86,10 +86,10 @@ pub(crate) struct BorrowSignatures<'a> {
pub(crate) procs: MutMap<(Symbol, ProcLayout<'a>), BorrowSignature>, pub(crate) procs: MutMap<(Symbol, ProcLayout<'a>), BorrowSignature>,
} }
pub(crate) fn infer_borrow_signatures<'a, 'b: 'a>( pub(crate) fn infer_borrow_signatures<'a>(
arena: &'a Bump, arena: &'a Bump,
interner: &impl LayoutInterner<'a>, interner: &impl LayoutInterner<'a>,
procs: &'b MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>, procs: &MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
) -> BorrowSignatures<'a> { ) -> BorrowSignatures<'a> {
let mut borrow_signatures: BorrowSignatures = BorrowSignatures { let mut borrow_signatures: BorrowSignatures = BorrowSignatures {
procs: procs procs: procs
@ -193,12 +193,12 @@ fn infer_borrow_signature<'a>(
state.borrow_signature state.borrow_signature
} }
struct State<'a> { struct State<'state, 'arena> {
/// Argument symbols with a layout of `List *` or `Str`, i.e. the layouts /// Argument symbols with a layout of `List *` or `Str`, i.e. the layouts
/// for which borrow inference might decide to pass as borrowed /// for which borrow inference might decide to pass as borrowed
args: &'a [(InLayout<'a>, Symbol)], args: &'state [(InLayout<'arena>, Symbol)],
borrow_signature: BorrowSignature, borrow_signature: BorrowSignature,
join_point_stack: Vec<'a, (JoinPointId, &'a [Param<'a>])>, join_point_stack: Vec<'arena, (JoinPointId, &'state [Param<'arena>])>,
join_points: MutMap<JoinPointId, BorrowSignature>, join_points: MutMap<JoinPointId, BorrowSignature>,
modified: bool, modified: bool,
} }
@ -217,12 +217,12 @@ fn layout_to_ownership<'a>(
} }
} }
impl<'a> State<'a> { impl<'state, 'a> State<'state, 'a> {
fn new( fn new(
arena: &'a Bump, arena: &'a Bump,
interner: &impl LayoutInterner<'a>, interner: &impl LayoutInterner<'a>,
borrow_signatures: &mut BorrowSignatures<'a>, borrow_signatures: &mut BorrowSignatures<'a>,
proc: &'a Proc<'a>, proc: &Proc<'a>,
) -> Self { ) -> Self {
let key = (proc.name.name(), proc.proc_layout(arena)); let key = (proc.name.name(), proc.proc_layout(arena));
@ -269,7 +269,7 @@ impl<'a> State<'a> {
&mut self, &mut self,
interner: &impl LayoutInterner<'a>, interner: &impl LayoutInterner<'a>,
borrow_signatures: &mut BorrowSignatures<'a>, borrow_signatures: &mut BorrowSignatures<'a>,
stmt: &'a Stmt<'a>, stmt: &Stmt<'a>,
) { ) {
match stmt { match stmt {
Stmt::Let(_, expr, _, stmt) => { Stmt::Let(_, expr, _, stmt) => {
@ -338,13 +338,13 @@ impl<'a> State<'a> {
} }
} }
fn inspect_expr(&mut self, borrow_signatures: &mut BorrowSignatures<'a>, expr: &'a Expr<'a>) { fn inspect_expr(&mut self, borrow_signatures: &mut BorrowSignatures<'a>, expr: &Expr<'a>) {
if let Expr::Call(call) = expr { if let Expr::Call(call) = expr {
self.inspect_call(borrow_signatures, call) self.inspect_call(borrow_signatures, call)
} }
} }
fn inspect_call(&mut self, borrow_signatures: &mut BorrowSignatures<'a>, call: &'a Call<'a>) { fn inspect_call(&mut self, borrow_signatures: &mut BorrowSignatures<'a>, call: &Call<'a>) {
let Call { let Call {
call_type, call_type,
arguments, arguments,

View file

@ -32,16 +32,10 @@ pub fn insert_inc_dec_operations<'a>(
layout_interner: &STLayoutInterner<'a>, layout_interner: &STLayoutInterner<'a>,
procedures: &mut HashMap<(Symbol, ProcLayout<'a>), Proc<'a>, BuildHasherDefault<WyHash>>, procedures: &mut HashMap<(Symbol, ProcLayout<'a>), Proc<'a>, BuildHasherDefault<WyHash>>,
) { ) {
// TODO remove this clone? let borrow_signatures =
let ps = arena.alloc(procedures.clone()); crate::borrow::infer_borrow_signatures(arena, layout_interner, &procedures);
let borrow_signatures = crate::borrow::infer_borrow_signatures(arena, layout_interner, ps);
let borrow_signatures = arena.alloc(borrow_signatures); let borrow_signatures = arena.alloc(borrow_signatures);
// for ((s, _), sig) in borrow_signatures.procs.iter() {
// dbg!((s, sig));
// }
// All calls to lowlevels are wrapped in another function to help with type inference and return/parameter layouts. // All calls to lowlevels are wrapped in another function to help with type inference and return/parameter layouts.
// But this lowlevel might get inlined into the caller of the wrapper and thus removing any reference counting operations. // But this lowlevel might get inlined into the caller of the wrapper and thus removing any reference counting operations.
// Thus, these rc operations are performed on the caller of the wrapper instead, and we skip rc on the lowlevel. // Thus, these rc operations are performed on the caller of the wrapper instead, and we skip rc on the lowlevel.