mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
make a real fixed point
This commit is contained in:
parent
48ddbec9d1
commit
f361d79249
2 changed files with 10 additions and 34 deletions
|
@ -9,7 +9,7 @@ use crate::{
|
||||||
layout::{Builtin, InLayout, LayoutInterner, LayoutRepr, Niche},
|
layout::{Builtin, InLayout, LayoutInterner, LayoutRepr, Niche},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub(crate) struct BorrowSignature(u64);
|
pub(crate) struct BorrowSignature(u64);
|
||||||
|
|
||||||
impl std::fmt::Debug for BorrowSignature {
|
impl std::fmt::Debug for BorrowSignature {
|
||||||
|
@ -83,8 +83,6 @@ pub(crate) fn infer_borrow_signatures<'a, 'b: 'a>(
|
||||||
interner: &impl LayoutInterner<'a>,
|
interner: &impl LayoutInterner<'a>,
|
||||||
procs: &'b MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
|
procs: &'b MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
|
||||||
) -> BorrowSignatures<'a> {
|
) -> BorrowSignatures<'a> {
|
||||||
// let host_exposed_procs = &[];
|
|
||||||
|
|
||||||
let mut borrow_signatures: BorrowSignatures = procs
|
let mut borrow_signatures: BorrowSignatures = procs
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_key, proc)| {
|
.map(|(_key, proc)| {
|
||||||
|
@ -116,32 +114,9 @@ pub(crate) fn infer_borrow_signatures<'a, 'b: 'a>(
|
||||||
//
|
//
|
||||||
// when the signatures no longer change, the analysis stops and returns the signatures
|
// when the signatures no longer change, the analysis stops and returns the signatures
|
||||||
|
|
||||||
// // initialize borrow signatures for everyone
|
|
||||||
// for index in group.iter_ones() {
|
|
||||||
// let (key, proc) = procs.iter().nth(index).unwrap();
|
|
||||||
//
|
|
||||||
// if proc.args.is_empty() {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // host-exposed functions must always own their arguments.
|
|
||||||
// let is_host_exposed = host_exposed_procs.contains(&key.0);
|
|
||||||
//
|
|
||||||
// let key = (proc.name.name(), proc.proc_layout(arena));
|
|
||||||
//
|
|
||||||
// // initialize the borrow signature based on the layout if first time
|
|
||||||
// borrow_signatures.entry(key).or_insert_with(|| {
|
|
||||||
// let mut borrow_signature = BorrowSignature::new(proc.args.len());
|
|
||||||
//
|
|
||||||
// for (i, in_layout) in key.1.arguments.iter().enumerate() {
|
|
||||||
// borrow_signature.set(i, layout_to_ownership(*in_layout, interner));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// borrow_signature
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
let mut modified = false;
|
||||||
|
|
||||||
for index in group.iter_ones() {
|
for index in group.iter_ones() {
|
||||||
let (_, proc) = procs.iter().nth(index).unwrap();
|
let (_, proc) = procs.iter().nth(index).unwrap();
|
||||||
let key = (proc.name.name(), proc.proc_layout(arena));
|
let key = (proc.name.name(), proc.proc_layout(arena));
|
||||||
|
@ -157,12 +132,14 @@ pub(crate) fn infer_borrow_signatures<'a, 'b: 'a>(
|
||||||
|
|
||||||
state.inspect_stmt(&mut borrow_signatures, &proc.body);
|
state.inspect_stmt(&mut borrow_signatures, &proc.body);
|
||||||
|
|
||||||
borrow_signatures.insert(key, state.borrow_signature);
|
let Some(old) = borrow_signatures.insert(key, state.borrow_signature) else {
|
||||||
|
unreachable!("key should be present");
|
||||||
|
};
|
||||||
|
|
||||||
|
modified |= old != state.borrow_signature
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there were no modifications, we're done
|
if !modified {
|
||||||
// if !env.modified {
|
|
||||||
if true {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,12 @@ use roc_module::low_level::LowLevel;
|
||||||
use roc_module::{low_level::LowLevelWrapperType, symbol::Symbol};
|
use roc_module::{low_level::LowLevelWrapperType, symbol::Symbol};
|
||||||
|
|
||||||
use crate::ir::ErasedField;
|
use crate::ir::ErasedField;
|
||||||
use crate::layout::{LambdaName, Niche};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ir::{
|
ir::{
|
||||||
BranchInfo, Call, CallType, Expr, HigherOrderLowLevel, JoinPointId, ListLiteralElement,
|
BranchInfo, Call, CallType, Expr, HigherOrderLowLevel, JoinPointId, ListLiteralElement,
|
||||||
ModifyRc, Param, Proc, ProcLayout, Stmt,
|
ModifyRc, Param, Proc, ProcLayout, Stmt,
|
||||||
},
|
},
|
||||||
layout::{InLayout, LayoutInterner, STLayoutInterner},
|
layout::{InLayout, LayoutInterner, Niche, STLayoutInterner},
|
||||||
low_level::HigherOrder,
|
low_level::HigherOrder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue