rename function

This commit is contained in:
Folkert 2021-11-19 23:49:09 +01:00
parent c6a3da2be2
commit 991420731d
2 changed files with 20 additions and 16 deletions

View file

@ -355,7 +355,7 @@ struct ModuleCache<'a> {
constrained: MutMap<ModuleId, ConstrainedModule>, constrained: MutMap<ModuleId, ConstrainedModule>,
typechecked: MutMap<ModuleId, TypeCheckedModule<'a>>, typechecked: MutMap<ModuleId, TypeCheckedModule<'a>>,
found_specializations: MutMap<ModuleId, FoundSpecializationsModule<'a>>, found_specializations: MutMap<ModuleId, FoundSpecializationsModule<'a>>,
external_specializations_requested: MutMap<ModuleId, Vec<ExternalSpecializations<'a>>>, external_specializations_requested: MutMap<ModuleId, Vec<ExternalSpecializations>>,
/// Various information /// Various information
imports: MutMap<ModuleId, MutSet<ModuleId>>, imports: MutMap<ModuleId, MutSet<ModuleId>>,
@ -830,7 +830,7 @@ enum Msg<'a> {
module_id: ModuleId, module_id: ModuleId,
ident_ids: IdentIds, ident_ids: IdentIds,
layout_cache: LayoutCache<'a>, layout_cache: LayoutCache<'a>,
external_specializations_requested: BumpMap<ModuleId, ExternalSpecializations<'a>>, external_specializations_requested: BumpMap<ModuleId, ExternalSpecializations>,
procedures: MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>, procedures: MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
problems: Vec<roc_mono::ir::MonoProblem>, problems: Vec<roc_mono::ir::MonoProblem>,
module_timing: ModuleTiming, module_timing: ModuleTiming,
@ -1050,7 +1050,7 @@ enum BuildTask<'a> {
subs: Subs, subs: Subs,
procs_base: ProcsBase<'a>, procs_base: ProcsBase<'a>,
layout_cache: LayoutCache<'a>, layout_cache: LayoutCache<'a>,
specializations_we_must_make: Vec<ExternalSpecializations<'a>>, specializations_we_must_make: Vec<ExternalSpecializations>,
module_timing: ModuleTiming, module_timing: ModuleTiming,
}, },
} }
@ -3920,7 +3920,7 @@ fn make_specializations<'a>(
mut subs: Subs, mut subs: Subs,
procs_base: ProcsBase<'a>, procs_base: ProcsBase<'a>,
mut layout_cache: LayoutCache<'a>, mut layout_cache: LayoutCache<'a>,
specializations_we_must_make: Vec<ExternalSpecializations<'a>>, specializations_we_must_make: Vec<ExternalSpecializations>,
mut module_timing: ModuleTiming, mut module_timing: ModuleTiming,
ptr_bytes: u32, ptr_bytes: u32,
) -> Msg<'a> { ) -> Msg<'a> {

View file

@ -435,23 +435,27 @@ impl HostSpecializations {
/// Specializations of this module's symbols that other modules need /// Specializations of this module's symbols that other modules need
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct ExternalSpecializations<'a> { pub struct ExternalSpecializations {
/// Not a bumpalo vec because bumpalo is not thread safe /// Not a bumpalo vec because bumpalo is not thread safe
/// Separate array so we can search for membership quickly /// Separate array so we can search for membership quickly
symbols: std::vec::Vec<Symbol>, symbols: std::vec::Vec<Symbol>,
storage_subs: StorageSubs, storage_subs: StorageSubs,
/// For each symbol, what types to specialize it for, points into the storage_subs /// For each symbol, what types to specialize it for, points into the storage_subs
types_to_specialize: std::vec::Vec<std::vec::Vec<Variable>>, types_to_specialize: std::vec::Vec<std::vec::Vec<Variable>>,
_lifetime: std::marker::PhantomData<&'a u8>,
} }
impl<'a> ExternalSpecializations<'a> { impl Default for ExternalSpecializations {
pub fn new_in(_arena: &'a Bump) -> Self { fn default() -> Self {
Self::new()
}
}
impl ExternalSpecializations {
pub fn new() -> Self {
Self { Self {
symbols: std::vec::Vec::new(), symbols: std::vec::Vec::new(),
storage_subs: StorageSubs::new(Subs::default()), storage_subs: StorageSubs::new(Subs::default()),
types_to_specialize: std::vec::Vec::new(), types_to_specialize: std::vec::Vec::new(),
_lifetime: std::marker::PhantomData,
} }
} }
@ -656,7 +660,7 @@ pub struct Procs<'a> {
pending_specializations: PendingSpecializations<'a>, pending_specializations: PendingSpecializations<'a>,
specialized: Specialized<'a>, specialized: Specialized<'a>,
pub runtime_errors: BumpMap<Symbol, &'a str>, pub runtime_errors: BumpMap<Symbol, &'a str>,
pub externals_we_need: BumpMap<ModuleId, ExternalSpecializations<'a>>, pub externals_we_need: BumpMap<ModuleId, ExternalSpecializations>,
} }
impl<'a> Procs<'a> { impl<'a> Procs<'a> {
@ -1983,7 +1987,7 @@ fn specialize_suspended<'a>(
pub fn specialize_all<'a>( pub fn specialize_all<'a>(
env: &mut Env<'a, '_>, env: &mut Env<'a, '_>,
mut procs: Procs<'a>, mut procs: Procs<'a>,
externals_others_need: std::vec::Vec<ExternalSpecializations<'a>>, externals_others_need: std::vec::Vec<ExternalSpecializations>,
specializations_for_host: HostSpecializations, specializations_for_host: HostSpecializations,
layout_cache: &mut LayoutCache<'a>, layout_cache: &mut LayoutCache<'a>,
) -> Procs<'a> { ) -> Procs<'a> {
@ -2021,7 +2025,7 @@ fn specialize_host_specializations<'a>(
let offset_variable = StorageSubs::merge_into(store, env.subs); let offset_variable = StorageSubs::merge_into(store, env.subs);
for (symbol, variable, host_exposed_aliases) in it { for (symbol, variable, host_exposed_aliases) in it {
barfoo( specialize_external_help(
env, env,
procs, procs,
layout_cache, layout_cache,
@ -2036,7 +2040,7 @@ fn specialize_external_specializations<'a>(
env: &mut Env<'a, '_>, env: &mut Env<'a, '_>,
procs: &mut Procs<'a>, procs: &mut Procs<'a>,
layout_cache: &mut LayoutCache<'a>, layout_cache: &mut LayoutCache<'a>,
externals_others_need: ExternalSpecializations<'a>, externals_others_need: ExternalSpecializations,
) { ) {
let (store, it) = externals_others_need.decompose(); let (store, it) = externals_others_need.decompose();
@ -2049,7 +2053,7 @@ fn specialize_external_specializations<'a>(
// duplicate specializations, and the insertion into a hash map // duplicate specializations, and the insertion into a hash map
// below will deduplicate them. // below will deduplicate them.
barfoo( specialize_external_help(
env, env,
procs, procs,
layout_cache, layout_cache,
@ -2061,7 +2065,7 @@ fn specialize_external_specializations<'a>(
} }
} }
fn barfoo<'a>( fn specialize_external_help<'a>(
env: &mut Env<'a, '_>, env: &mut Env<'a, '_>,
procs: &mut Procs<'a>, procs: &mut Procs<'a>,
layout_cache: &mut LayoutCache<'a>, layout_cache: &mut LayoutCache<'a>,
@ -6489,7 +6493,7 @@ fn add_needed_external<'a>(
use hashbrown::hash_map::Entry::{Occupied, Vacant}; use hashbrown::hash_map::Entry::{Occupied, Vacant};
let existing = match procs.externals_we_need.entry(name.module_id()) { let existing = match procs.externals_we_need.entry(name.module_id()) {
Vacant(entry) => entry.insert(ExternalSpecializations::new_in(env.arena)), Vacant(entry) => entry.insert(ExternalSpecializations::new()),
Occupied(entry) => entry.into_mut(), Occupied(entry) => entry.into_mut(),
}; };