mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
remove passed_by_pointer infrastructure
This commit is contained in:
parent
0d64d5ac1b
commit
0cdea4e36a
3 changed files with 7 additions and 52 deletions
|
@ -751,7 +751,6 @@ enum Msg<'a> {
|
||||||
layout_cache: LayoutCache<'a>,
|
layout_cache: LayoutCache<'a>,
|
||||||
external_specializations_requested: MutMap<ModuleId, ExternalSpecializations>,
|
external_specializations_requested: MutMap<ModuleId, ExternalSpecializations>,
|
||||||
procedures: MutMap<(Symbol, Layout<'a>), Proc<'a>>,
|
procedures: MutMap<(Symbol, Layout<'a>), Proc<'a>>,
|
||||||
passed_by_pointer: MutMap<(Symbol, Layout<'a>), Symbol>,
|
|
||||||
problems: Vec<roc_mono::ir::MonoProblem>,
|
problems: Vec<roc_mono::ir::MonoProblem>,
|
||||||
module_timing: ModuleTiming,
|
module_timing: ModuleTiming,
|
||||||
subs: Subs,
|
subs: Subs,
|
||||||
|
@ -782,7 +781,6 @@ struct State<'a> {
|
||||||
pub module_cache: ModuleCache<'a>,
|
pub module_cache: ModuleCache<'a>,
|
||||||
pub dependencies: Dependencies<'a>,
|
pub dependencies: Dependencies<'a>,
|
||||||
pub procedures: MutMap<(Symbol, Layout<'a>), Proc<'a>>,
|
pub procedures: MutMap<(Symbol, Layout<'a>), Proc<'a>>,
|
||||||
pub passed_by_pointer: MutMap<(Symbol, Layout<'a>), Symbol>,
|
|
||||||
pub exposed_to_host: MutMap<Symbol, Variable>,
|
pub exposed_to_host: MutMap<Symbol, Variable>,
|
||||||
|
|
||||||
/// This is the "final" list of IdentIds, after canonicalization and constraint gen
|
/// This is the "final" list of IdentIds, after canonicalization and constraint gen
|
||||||
|
@ -1405,7 +1403,6 @@ where
|
||||||
module_cache: ModuleCache::default(),
|
module_cache: ModuleCache::default(),
|
||||||
dependencies: Dependencies::default(),
|
dependencies: Dependencies::default(),
|
||||||
procedures: MutMap::default(),
|
procedures: MutMap::default(),
|
||||||
passed_by_pointer: MutMap::default(),
|
|
||||||
exposed_to_host: MutMap::default(),
|
exposed_to_host: MutMap::default(),
|
||||||
exposed_types,
|
exposed_types,
|
||||||
headers_parsed,
|
headers_parsed,
|
||||||
|
@ -1934,7 +1931,6 @@ fn update<'a>(
|
||||||
mut ident_ids,
|
mut ident_ids,
|
||||||
subs,
|
subs,
|
||||||
procedures,
|
procedures,
|
||||||
passed_by_pointer,
|
|
||||||
external_specializations_requested,
|
external_specializations_requested,
|
||||||
problems,
|
problems,
|
||||||
module_timing,
|
module_timing,
|
||||||
|
@ -1949,17 +1945,12 @@ fn update<'a>(
|
||||||
.notify(module_id, Phase::MakeSpecializations);
|
.notify(module_id, Phase::MakeSpecializations);
|
||||||
|
|
||||||
state.procedures.extend(procedures);
|
state.procedures.extend(procedures);
|
||||||
state.passed_by_pointer.extend(passed_by_pointer);
|
|
||||||
state.timings.insert(module_id, module_timing);
|
state.timings.insert(module_id, module_timing);
|
||||||
|
|
||||||
if state.dependencies.solved_all() && state.goal_phase == Phase::MakeSpecializations {
|
if state.dependencies.solved_all() && state.goal_phase == Phase::MakeSpecializations {
|
||||||
debug_assert!(work.is_empty(), "still work remaining {:?}", &work);
|
debug_assert!(work.is_empty(), "still work remaining {:?}", &work);
|
||||||
|
|
||||||
Proc::insert_refcount_operations(
|
Proc::insert_refcount_operations(arena, &mut state.procedures);
|
||||||
arena,
|
|
||||||
&mut state.procedures,
|
|
||||||
&state.passed_by_pointer,
|
|
||||||
);
|
|
||||||
|
|
||||||
Proc::optimize_refcount_operations(
|
Proc::optimize_refcount_operations(
|
||||||
arena,
|
arena,
|
||||||
|
@ -3630,7 +3621,7 @@ fn make_specializations<'a>(
|
||||||
);
|
);
|
||||||
|
|
||||||
let external_specializations_requested = procs.externals_we_need.clone();
|
let external_specializations_requested = procs.externals_we_need.clone();
|
||||||
let (procedures, passed_by_pointer) = procs.get_specialized_procs_without_rc(mono_env.arena);
|
let procedures = procs.get_specialized_procs_without_rc(mono_env.arena);
|
||||||
|
|
||||||
let make_specializations_end = SystemTime::now();
|
let make_specializations_end = SystemTime::now();
|
||||||
module_timing.make_specializations = make_specializations_end
|
module_timing.make_specializations = make_specializations_end
|
||||||
|
@ -3642,7 +3633,6 @@ fn make_specializations<'a>(
|
||||||
ident_ids,
|
ident_ids,
|
||||||
layout_cache,
|
layout_cache,
|
||||||
procedures,
|
procedures,
|
||||||
passed_by_pointer,
|
|
||||||
problems: mono_problems,
|
problems: mono_problems,
|
||||||
subs,
|
subs,
|
||||||
external_specializations_requested,
|
external_specializations_requested,
|
||||||
|
|
|
@ -16,7 +16,6 @@ fn should_borrow_layout(layout: &Layout) -> bool {
|
||||||
pub fn infer_borrow<'a>(
|
pub fn infer_borrow<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
procs: &MutMap<(Symbol, Layout<'a>), Proc<'a>>,
|
procs: &MutMap<(Symbol, Layout<'a>), Proc<'a>>,
|
||||||
_passed_by_pointer: &MutMap<(Symbol, Layout<'a>), Symbol>,
|
|
||||||
) -> ParamMap<'a> {
|
) -> ParamMap<'a> {
|
||||||
let mut param_map = ParamMap {
|
let mut param_map = ParamMap {
|
||||||
items: MutMap::default(),
|
items: MutMap::default(),
|
||||||
|
|
|
@ -196,28 +196,8 @@ impl<'a> Proc<'a> {
|
||||||
pub fn insert_refcount_operations(
|
pub fn insert_refcount_operations(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
procs: &mut MutMap<(Symbol, Layout<'a>), Proc<'a>>,
|
procs: &mut MutMap<(Symbol, Layout<'a>), Proc<'a>>,
|
||||||
_passed_by_pointer: &MutMap<(Symbol, Layout<'a>), Symbol>,
|
|
||||||
) {
|
) {
|
||||||
// currently we ignore the passed-by-pointerness
|
let borrow_params = arena.alloc(crate::borrow::infer_borrow(arena, procs));
|
||||||
let passed_by_pointer = &Default::default();
|
|
||||||
|
|
||||||
let borrow_params =
|
|
||||||
arena.alloc(crate::borrow::infer_borrow(arena, procs, passed_by_pointer));
|
|
||||||
|
|
||||||
for (key, other) in passed_by_pointer {
|
|
||||||
if let Some(proc) = procs.get(key) {
|
|
||||||
let mut proc: Proc = proc.clone();
|
|
||||||
proc.name = *other;
|
|
||||||
|
|
||||||
let layout = key.1.clone();
|
|
||||||
procs.insert((*other, layout), proc);
|
|
||||||
} else {
|
|
||||||
unreachable!(
|
|
||||||
"we need a by-pointer version of {:?}, but its by-name version does not exist",
|
|
||||||
key.0
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (key, proc) in procs.iter_mut() {
|
for (key, proc) in procs.iter_mut() {
|
||||||
crate::inc_dec::visit_proc(arena, borrow_params, proc, key.1.clone());
|
crate::inc_dec::visit_proc(arena, borrow_params, proc, key.1.clone());
|
||||||
|
@ -299,7 +279,6 @@ pub struct Procs<'a> {
|
||||||
pub runtime_errors: MutMap<Symbol, &'a str>,
|
pub runtime_errors: MutMap<Symbol, &'a str>,
|
||||||
pub externals_others_need: ExternalSpecializations,
|
pub externals_others_need: ExternalSpecializations,
|
||||||
pub externals_we_need: MutMap<ModuleId, ExternalSpecializations>,
|
pub externals_we_need: MutMap<ModuleId, ExternalSpecializations>,
|
||||||
pub passed_by_pointer: MutMap<(Symbol, Layout<'a>), Symbol>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for Procs<'a> {
|
impl<'a> Default for Procs<'a> {
|
||||||
|
@ -312,7 +291,6 @@ impl<'a> Default for Procs<'a> {
|
||||||
runtime_errors: MutMap::default(),
|
runtime_errors: MutMap::default(),
|
||||||
externals_we_need: MutMap::default(),
|
externals_we_need: MutMap::default(),
|
||||||
externals_others_need: ExternalSpecializations::default(),
|
externals_others_need: ExternalSpecializations::default(),
|
||||||
passed_by_pointer: MutMap::default(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,14 +335,10 @@ impl<'a> Procs<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
|
||||||
pub fn get_specialized_procs_without_rc(
|
pub fn get_specialized_procs_without_rc(
|
||||||
self,
|
self,
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
) -> (
|
) -> MutMap<(Symbol, Layout<'a>), Proc<'a>> {
|
||||||
MutMap<(Symbol, Layout<'a>), Proc<'a>>,
|
|
||||||
MutMap<(Symbol, Layout<'a>), Symbol>,
|
|
||||||
) {
|
|
||||||
let mut result = MutMap::with_capacity_and_hasher(self.specialized.len(), default_hasher());
|
let mut result = MutMap::with_capacity_and_hasher(self.specialized.len(), default_hasher());
|
||||||
|
|
||||||
for (key, in_prog_proc) in self.specialized.into_iter() {
|
for (key, in_prog_proc) in self.specialized.into_iter() {
|
||||||
|
@ -387,7 +361,7 @@ impl<'a> Procs<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(result, self.passed_by_pointer)
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO investigate make this an iterator?
|
// TODO investigate make this an iterator?
|
||||||
|
@ -416,11 +390,7 @@ impl<'a> Procs<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let borrow_params = arena.alloc(crate::borrow::infer_borrow(
|
let borrow_params = arena.alloc(crate::borrow::infer_borrow(arena, &result));
|
||||||
arena,
|
|
||||||
&result,
|
|
||||||
&self.passed_by_pointer,
|
|
||||||
));
|
|
||||||
|
|
||||||
for (key, proc) in result.iter_mut() {
|
for (key, proc) in result.iter_mut() {
|
||||||
crate::inc_dec::visit_proc(arena, borrow_params, proc, key.1.clone());
|
crate::inc_dec::visit_proc(arena, borrow_params, proc, key.1.clone());
|
||||||
|
@ -460,11 +430,7 @@ impl<'a> Procs<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let borrow_params = arena.alloc(crate::borrow::infer_borrow(
|
let borrow_params = arena.alloc(crate::borrow::infer_borrow(arena, &result));
|
||||||
arena,
|
|
||||||
&result,
|
|
||||||
&self.passed_by_pointer,
|
|
||||||
));
|
|
||||||
|
|
||||||
for (key, proc) in result.iter_mut() {
|
for (key, proc) in result.iter_mut() {
|
||||||
crate::inc_dec::visit_proc(arena, borrow_params, proc, key.1.clone());
|
crate::inc_dec::visit_proc(arena, borrow_params, proc, key.1.clone());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue