mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
start using the solutions
This commit is contained in:
parent
61f0fe0927
commit
2a61c3108e
4 changed files with 37 additions and 10 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -3218,6 +3218,7 @@ dependencies = [
|
||||||
"indoc 0.3.6",
|
"indoc 0.3.6",
|
||||||
"inlinable_string",
|
"inlinable_string",
|
||||||
"maplit",
|
"maplit",
|
||||||
|
"morphic_lib",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pretty_assertions 0.5.1",
|
"pretty_assertions 0.5.1",
|
||||||
|
|
|
@ -19,6 +19,7 @@ roc_parse = { path = "../parse" }
|
||||||
roc_solve = { path = "../solve" }
|
roc_solve = { path = "../solve" }
|
||||||
roc_mono = { path = "../mono" }
|
roc_mono = { path = "../mono" }
|
||||||
roc_reporting = { path = "../reporting" }
|
roc_reporting = { path = "../reporting" }
|
||||||
|
morphic_lib = { path = "../../vendor/morphic_lib" }
|
||||||
ven_pretty = { path = "../../vendor/pretty" }
|
ven_pretty = { path = "../../vendor/pretty" }
|
||||||
bumpalo = { version = "3.6.1", features = ["collections"] }
|
bumpalo = { version = "3.6.1", features = ["collections"] }
|
||||||
inlinable_string = "0.1"
|
inlinable_string = "0.1"
|
||||||
|
|
|
@ -706,6 +706,7 @@ pub struct MonomorphizedModule<'a> {
|
||||||
pub type_problems: MutMap<ModuleId, Vec<solve::TypeError>>,
|
pub type_problems: MutMap<ModuleId, Vec<solve::TypeError>>,
|
||||||
pub mono_problems: MutMap<ModuleId, Vec<roc_mono::ir::MonoProblem>>,
|
pub mono_problems: MutMap<ModuleId, Vec<roc_mono::ir::MonoProblem>>,
|
||||||
pub procedures: MutMap<(Symbol, TopLevelFunctionLayout<'a>), Proc<'a>>,
|
pub procedures: MutMap<(Symbol, TopLevelFunctionLayout<'a>), Proc<'a>>,
|
||||||
|
pub alias_analysis_solutions: AliasAnalysisSolutions,
|
||||||
pub exposed_to_host: MutMap<Symbol, Variable>,
|
pub exposed_to_host: MutMap<Symbol, Variable>,
|
||||||
pub header_sources: MutMap<ModuleId, (PathBuf, Box<str>)>,
|
pub header_sources: MutMap<ModuleId, (PathBuf, Box<str>)>,
|
||||||
pub sources: MutMap<ModuleId, (PathBuf, Box<str>)>,
|
pub sources: MutMap<ModuleId, (PathBuf, Box<str>)>,
|
||||||
|
@ -863,6 +864,19 @@ struct State<'a> {
|
||||||
pub layout_caches: std::vec::Vec<LayoutCache<'a>>,
|
pub layout_caches: std::vec::Vec<LayoutCache<'a>>,
|
||||||
|
|
||||||
pub procs: Procs<'a>,
|
pub procs: Procs<'a>,
|
||||||
|
|
||||||
|
pub alias_analysis_solutions: AliasAnalysisSolutions,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum AliasAnalysisSolutions {
|
||||||
|
NotAvailable,
|
||||||
|
Available(morphic_lib::Solutions),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for AliasAnalysisSolutions {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "AliasAnalysisSolutions {{}}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -1472,6 +1486,7 @@ where
|
||||||
specializations_in_flight: 0,
|
specializations_in_flight: 0,
|
||||||
layout_caches: std::vec::Vec::with_capacity(num_cpus::get()),
|
layout_caches: std::vec::Vec::with_capacity(num_cpus::get()),
|
||||||
procs: Procs::new_in(arena),
|
procs: Procs::new_in(arena),
|
||||||
|
alias_analysis_solutions: AliasAnalysisSolutions::NotAvailable,
|
||||||
};
|
};
|
||||||
|
|
||||||
// We've now distributed one worker queue to each thread.
|
// We've now distributed one worker queue to each thread.
|
||||||
|
@ -2061,14 +2076,6 @@ fn update<'a>(
|
||||||
println!("{}", result);
|
println!("{}", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if false {
|
|
||||||
let it = state.procedures.iter().map(|x| x.1);
|
|
||||||
|
|
||||||
if let Err(e) = roc_mono::alias_analysis::spec_program(it) {
|
|
||||||
println!("Error in alias analysis: {:?}", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Proc::insert_refcount_operations(arena, &mut state.procedures);
|
Proc::insert_refcount_operations(arena, &mut state.procedures);
|
||||||
|
|
||||||
Proc::optimize_refcount_operations(
|
Proc::optimize_refcount_operations(
|
||||||
|
@ -2078,6 +2085,18 @@ fn update<'a>(
|
||||||
&mut state.procedures,
|
&mut state.procedures,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if true {
|
||||||
|
let it = state.procedures.iter().map(|x| x.1);
|
||||||
|
|
||||||
|
match roc_mono::alias_analysis::spec_program(it) {
|
||||||
|
Err(e) => panic!("Error in alias analysis: {:?}", e),
|
||||||
|
Ok(solutions) => {
|
||||||
|
state.alias_analysis_solutions =
|
||||||
|
AliasAnalysisSolutions::Available(solutions)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
state.constrained_ident_ids.insert(module_id, ident_ids);
|
state.constrained_ident_ids.insert(module_id, ident_ids);
|
||||||
|
|
||||||
for (module_id, requested) in external_specializations_requested {
|
for (module_id, requested) in external_specializations_requested {
|
||||||
|
@ -2157,6 +2176,7 @@ fn finish_specialization(
|
||||||
|
|
||||||
let State {
|
let State {
|
||||||
procedures,
|
procedures,
|
||||||
|
alias_analysis_solutions,
|
||||||
module_cache,
|
module_cache,
|
||||||
output_path,
|
output_path,
|
||||||
platform_path,
|
platform_path,
|
||||||
|
@ -2218,6 +2238,7 @@ fn finish_specialization(
|
||||||
subs,
|
subs,
|
||||||
interns,
|
interns,
|
||||||
procedures,
|
procedures,
|
||||||
|
alias_analysis_solutions,
|
||||||
sources,
|
sources,
|
||||||
header_sources,
|
header_sources,
|
||||||
timings: state.timings,
|
timings: state.timings,
|
||||||
|
|
|
@ -16,7 +16,7 @@ use bumpalo::Bump;
|
||||||
|
|
||||||
// just using one module for now
|
// just using one module for now
|
||||||
const MOD_LIST: ModName = ModName(b"UserApp");
|
const MOD_LIST: ModName = ModName(b"UserApp");
|
||||||
const MOD_APP: ModName = ModName(b"UserApp");
|
pub const MOD_APP: ModName = ModName(b"UserApp");
|
||||||
|
|
||||||
pub fn spec_program<'a, I>(procs: I) -> Result<morphic_lib::Solutions>
|
pub fn spec_program<'a, I>(procs: I) -> Result<morphic_lib::Solutions>
|
||||||
where
|
where
|
||||||
|
@ -182,7 +182,7 @@ fn stmt_spec(
|
||||||
}
|
}
|
||||||
Ret(symbol) => Ok(env.symbols[symbol]),
|
Ret(symbol) => Ok(env.symbols[symbol]),
|
||||||
Refcounting(modify_rc, continuation) => match modify_rc {
|
Refcounting(modify_rc, continuation) => match modify_rc {
|
||||||
ModifyRc::Inc(symbol, _) | ModifyRc::Dec(symbol) | ModifyRc::DecRef(symbol) => {
|
ModifyRc::Inc(symbol, _) | ModifyRc::Dec(symbol) => {
|
||||||
let result_type = builder.add_tuple_type(&[])?;
|
let result_type = builder.add_tuple_type(&[])?;
|
||||||
let argument = env.symbols[symbol];
|
let argument = env.symbols[symbol];
|
||||||
|
|
||||||
|
@ -191,6 +191,10 @@ fn stmt_spec(
|
||||||
|
|
||||||
stmt_spec(builder, env, block, layout, continuation)
|
stmt_spec(builder, env, block, layout, continuation)
|
||||||
}
|
}
|
||||||
|
ModifyRc::DecRef(_symbol) => {
|
||||||
|
// TODO a decref is a non-recursive decrement of a structure
|
||||||
|
stmt_spec(builder, env, block, layout, continuation)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Join {
|
Join {
|
||||||
id,
|
id,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue