mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-19 06:40:20 +03:00
start using the solutions
This commit is contained in:
parent
61f0fe0927
commit
2a61c3108e
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -3218,6 +3218,7 @@ dependencies = [
|
||||
"indoc 0.3.6",
|
||||
"inlinable_string",
|
||||
"maplit",
|
||||
"morphic_lib",
|
||||
"num_cpus",
|
||||
"parking_lot",
|
||||
"pretty_assertions 0.5.1",
|
||||
|
@ -19,6 +19,7 @@ roc_parse = { path = "../parse" }
|
||||
roc_solve = { path = "../solve" }
|
||||
roc_mono = { path = "../mono" }
|
||||
roc_reporting = { path = "../reporting" }
|
||||
morphic_lib = { path = "../../vendor/morphic_lib" }
|
||||
ven_pretty = { path = "../../vendor/pretty" }
|
||||
bumpalo = { version = "3.6.1", features = ["collections"] }
|
||||
inlinable_string = "0.1"
|
||||
|
@ -706,6 +706,7 @@ pub struct MonomorphizedModule<'a> {
|
||||
pub type_problems: MutMap<ModuleId, Vec<solve::TypeError>>,
|
||||
pub mono_problems: MutMap<ModuleId, Vec<roc_mono::ir::MonoProblem>>,
|
||||
pub procedures: MutMap<(Symbol, TopLevelFunctionLayout<'a>), Proc<'a>>,
|
||||
pub alias_analysis_solutions: AliasAnalysisSolutions,
|
||||
pub exposed_to_host: MutMap<Symbol, Variable>,
|
||||
pub header_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 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)]
|
||||
@ -1472,6 +1486,7 @@ where
|
||||
specializations_in_flight: 0,
|
||||
layout_caches: std::vec::Vec::with_capacity(num_cpus::get()),
|
||||
procs: Procs::new_in(arena),
|
||||
alias_analysis_solutions: AliasAnalysisSolutions::NotAvailable,
|
||||
};
|
||||
|
||||
// We've now distributed one worker queue to each thread.
|
||||
@ -2061,14 +2076,6 @@ fn update<'a>(
|
||||
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::optimize_refcount_operations(
|
||||
@ -2078,6 +2085,18 @@ fn update<'a>(
|
||||
&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);
|
||||
|
||||
for (module_id, requested) in external_specializations_requested {
|
||||
@ -2157,6 +2176,7 @@ fn finish_specialization(
|
||||
|
||||
let State {
|
||||
procedures,
|
||||
alias_analysis_solutions,
|
||||
module_cache,
|
||||
output_path,
|
||||
platform_path,
|
||||
@ -2218,6 +2238,7 @@ fn finish_specialization(
|
||||
subs,
|
||||
interns,
|
||||
procedures,
|
||||
alias_analysis_solutions,
|
||||
sources,
|
||||
header_sources,
|
||||
timings: state.timings,
|
||||
|
@ -16,7 +16,7 @@ use bumpalo::Bump;
|
||||
|
||||
// just using one module for now
|
||||
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>
|
||||
where
|
||||
@ -182,7 +182,7 @@ fn stmt_spec(
|
||||
}
|
||||
Ret(symbol) => Ok(env.symbols[symbol]),
|
||||
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 argument = env.symbols[symbol];
|
||||
|
||||
@ -191,6 +191,10 @@ fn stmt_spec(
|
||||
|
||||
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 {
|
||||
id,
|
||||
|
Loading…
Reference in New Issue
Block a user