mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
bumpalo allocator sadness; revert later
This commit is contained in:
parent
2032ef9b52
commit
cd1103df64
4 changed files with 51 additions and 45 deletions
|
@ -28,8 +28,11 @@ pub type SendMap<K, V> = im::hashmap::HashMap<K, V, BuildHasher>;
|
||||||
|
|
||||||
pub type SendSet<K> = im::hashset::HashSet<K, BuildHasher>;
|
pub type SendSet<K> = im::hashset::HashSet<K, BuildHasher>;
|
||||||
|
|
||||||
pub type BumpMap<'a, K, V> = hashbrown::HashMap<K, V, BuildHasher, hashbrown::BumpWrapper<'a>>;
|
// pub type BumpMap<'a, K, V> = hashbrown::HashMap<K, V, BuildHasher, hashbrown::BumpWrapper<'a>>;
|
||||||
pub type BumpSet<'a, K> = hashbrown::HashSet<K, BuildHasher, hashbrown::BumpWrapper<'a>>;
|
// pub type BumpSet<'a, K> = hashbrown::HashSet<K, BuildHasher, hashbrown::BumpWrapper<'a>>;
|
||||||
|
|
||||||
|
pub type BumpMap<K, V> = hashbrown::HashMap<K, V, BuildHasher>;
|
||||||
|
pub type BumpSet<K> = hashbrown::HashSet<K, BuildHasher>;
|
||||||
|
|
||||||
pub trait BumpMapDefault<'a> {
|
pub trait BumpMapDefault<'a> {
|
||||||
fn new_in(arena: &'a bumpalo::Bump) -> Self;
|
fn new_in(arena: &'a bumpalo::Bump) -> Self;
|
||||||
|
@ -37,31 +40,35 @@ pub trait BumpMapDefault<'a> {
|
||||||
fn with_capacity_in(capacity: usize, arena: &'a bumpalo::Bump) -> Self;
|
fn with_capacity_in(capacity: usize, arena: &'a bumpalo::Bump) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, K, V> BumpMapDefault<'a> for BumpMap<'a, K, V> {
|
impl<'a, K, V> BumpMapDefault<'a> for BumpMap<K, V> {
|
||||||
fn new_in(arena: &'a bumpalo::Bump) -> Self {
|
fn new_in(_arena: &'a bumpalo::Bump) -> Self {
|
||||||
hashbrown::HashMap::with_hasher_in(default_hasher(), hashbrown::BumpWrapper(arena))
|
// hashbrown::HashMap::with_hasher_in(default_hasher(), hashbrown::BumpWrapper(arena))
|
||||||
|
hashbrown::HashMap::with_hasher(default_hasher())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_capacity_in(capacity: usize, arena: &'a bumpalo::Bump) -> Self {
|
fn with_capacity_in(capacity: usize, _arena: &'a bumpalo::Bump) -> Self {
|
||||||
hashbrown::HashMap::with_capacity_and_hasher_in(
|
// hashbrown::HashMap::with_capacity_and_hasher_in(
|
||||||
capacity,
|
// capacity,
|
||||||
default_hasher(),
|
// default_hasher(),
|
||||||
hashbrown::BumpWrapper(arena),
|
// hashbrown::BumpWrapper(arena),
|
||||||
)
|
// )
|
||||||
|
hashbrown::HashMap::with_capacity_and_hasher(capacity, default_hasher())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, K> BumpMapDefault<'a> for BumpSet<'a, K> {
|
impl<'a, K> BumpMapDefault<'a> for BumpSet<K> {
|
||||||
fn new_in(arena: &'a bumpalo::Bump) -> Self {
|
fn new_in(_arena: &'a bumpalo::Bump) -> Self {
|
||||||
hashbrown::HashSet::with_hasher_in(default_hasher(), hashbrown::BumpWrapper(arena))
|
// hashbrown::HashSet::with_hasher_in(default_hasher(), hashbrown::BumpWrapper(arena))
|
||||||
|
hashbrown::HashSet::with_hasher(default_hasher())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_capacity_in(capacity: usize, arena: &'a bumpalo::Bump) -> Self {
|
fn with_capacity_in(capacity: usize, _arena: &'a bumpalo::Bump) -> Self {
|
||||||
hashbrown::HashSet::with_capacity_and_hasher_in(
|
// hashbrown::HashSet::with_capacity_and_hasher_in(
|
||||||
capacity,
|
// capacity,
|
||||||
default_hasher(),
|
// default_hasher(),
|
||||||
hashbrown::BumpWrapper(arena),
|
// hashbrown::BumpWrapper(arena),
|
||||||
)
|
// )
|
||||||
|
hashbrown::HashSet::with_capacity_and_hasher(capacity, default_hasher())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -774,7 +774,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<'a, ModuleId, ExternalSpecializations<'a>>,
|
external_specializations_requested: BumpMap<ModuleId, ExternalSpecializations<'a>>,
|
||||||
procedures: MutMap<(Symbol, Layout<'a>), Proc<'a>>,
|
procedures: MutMap<(Symbol, Layout<'a>), Proc<'a>>,
|
||||||
problems: Vec<roc_mono::ir::MonoProblem>,
|
problems: Vec<roc_mono::ir::MonoProblem>,
|
||||||
module_timing: ModuleTiming,
|
module_timing: ModuleTiming,
|
||||||
|
@ -976,7 +976,7 @@ enum BuildTask<'a> {
|
||||||
module_timing: ModuleTiming,
|
module_timing: ModuleTiming,
|
||||||
layout_cache: LayoutCache<'a>,
|
layout_cache: LayoutCache<'a>,
|
||||||
solved_subs: Solved<Subs>,
|
solved_subs: Solved<Subs>,
|
||||||
imported_module_thunks: BumpSet<'a, Symbol>,
|
imported_module_thunks: BumpSet<Symbol>,
|
||||||
module_id: ModuleId,
|
module_id: ModuleId,
|
||||||
ident_ids: IdentIds,
|
ident_ids: IdentIds,
|
||||||
decls: Vec<Declaration>,
|
decls: Vec<Declaration>,
|
||||||
|
@ -3831,7 +3831,7 @@ fn make_specializations<'a>(
|
||||||
fn build_pending_specializations<'a>(
|
fn build_pending_specializations<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
solved_subs: Solved<Subs>,
|
solved_subs: Solved<Subs>,
|
||||||
imported_module_thunks: BumpSet<'a, Symbol>,
|
imported_module_thunks: BumpSet<Symbol>,
|
||||||
home: ModuleId,
|
home: ModuleId,
|
||||||
mut ident_ids: IdentIds,
|
mut ident_ids: IdentIds,
|
||||||
decls: Vec<Declaration>,
|
decls: Vec<Declaration>,
|
||||||
|
|
|
@ -73,7 +73,8 @@ impl<'a> CapturedSymbols<'a> {
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct PendingSpecialization<'a> {
|
pub struct PendingSpecialization<'a> {
|
||||||
solved_type: SolvedType,
|
solved_type: SolvedType,
|
||||||
host_exposed_aliases: BumpMap<'a, Symbol, SolvedType>,
|
host_exposed_aliases: BumpMap<Symbol, SolvedType>,
|
||||||
|
_lifetime: std::marker::PhantomData<&'a u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> PendingSpecialization<'a> {
|
impl<'a> PendingSpecialization<'a> {
|
||||||
|
@ -82,6 +83,7 @@ impl<'a> PendingSpecialization<'a> {
|
||||||
PendingSpecialization {
|
PendingSpecialization {
|
||||||
solved_type,
|
solved_type,
|
||||||
host_exposed_aliases: BumpMap::new_in(arena),
|
host_exposed_aliases: BumpMap::new_in(arena),
|
||||||
|
_lifetime: std::marker::PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +106,7 @@ impl<'a> PendingSpecialization<'a> {
|
||||||
PendingSpecialization {
|
PendingSpecialization {
|
||||||
solved_type,
|
solved_type,
|
||||||
host_exposed_aliases,
|
host_exposed_aliases,
|
||||||
|
_lifetime: std::marker::PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,8 +127,8 @@ pub struct Proc<'a> {
|
||||||
pub enum HostExposedLayouts<'a> {
|
pub enum HostExposedLayouts<'a> {
|
||||||
NotHostExposed,
|
NotHostExposed,
|
||||||
HostExposed {
|
HostExposed {
|
||||||
rigids: BumpMap<'a, Lowercase, Layout<'a>>,
|
rigids: BumpMap<Lowercase, Layout<'a>>,
|
||||||
aliases: BumpMap<'a, Symbol, Layout<'a>>,
|
aliases: BumpMap<Symbol, Layout<'a>>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,13 +242,15 @@ impl<'a> Proc<'a> {
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ExternalSpecializations<'a> {
|
pub struct ExternalSpecializations<'a> {
|
||||||
pub specs: BumpMap<'a, Symbol, MutSet<SolvedType>>,
|
pub specs: BumpMap<Symbol, MutSet<SolvedType>>,
|
||||||
|
_lifetime: std::marker::PhantomData<&'a u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ExternalSpecializations<'a> {
|
impl<'a> ExternalSpecializations<'a> {
|
||||||
pub fn new_in(arena: &'a Bump) -> Self {
|
pub fn new_in(arena: &'a Bump) -> Self {
|
||||||
Self {
|
Self {
|
||||||
specs: BumpMap::new_in(arena),
|
specs: BumpMap::new_in(arena),
|
||||||
|
_lifetime: std::marker::PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,16 +281,16 @@ impl<'a> ExternalSpecializations<'a> {
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Procs<'a> {
|
pub struct Procs<'a> {
|
||||||
pub partial_procs: BumpMap<'a, Symbol, PartialProc<'a>>,
|
pub partial_procs: BumpMap<Symbol, PartialProc<'a>>,
|
||||||
pub imported_module_thunks: BumpSet<'a, Symbol>,
|
pub imported_module_thunks: BumpSet<Symbol>,
|
||||||
pub module_thunks: BumpSet<'a, Symbol>,
|
pub module_thunks: BumpSet<Symbol>,
|
||||||
pub pending_specializations:
|
pub pending_specializations:
|
||||||
Option<BumpMap<'a, Symbol, MutMap<Layout<'a>, PendingSpecialization<'a>>>>,
|
Option<BumpMap<Symbol, MutMap<Layout<'a>, PendingSpecialization<'a>>>>,
|
||||||
pub specialized: BumpMap<'a, (Symbol, Layout<'a>), InProgressProc<'a>>,
|
pub specialized: BumpMap<(Symbol, Layout<'a>), InProgressProc<'a>>,
|
||||||
pub runtime_errors: BumpMap<'a, Symbol, &'a str>,
|
pub runtime_errors: BumpMap<Symbol, &'a str>,
|
||||||
pub call_by_pointer_wrappers: BumpMap<'a, Symbol, Symbol>,
|
pub call_by_pointer_wrappers: BumpMap<Symbol, Symbol>,
|
||||||
pub externals_others_need: ExternalSpecializations<'a>,
|
pub externals_others_need: ExternalSpecializations<'a>,
|
||||||
pub externals_we_need: BumpMap<'a, ModuleId, ExternalSpecializations<'a>>,
|
pub externals_we_need: BumpMap<ModuleId, ExternalSpecializations<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Procs<'a> {
|
impl<'a> Procs<'a> {
|
||||||
|
@ -681,11 +686,7 @@ impl<'a> Procs<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_pending<'a>(
|
fn add_pending<'a>(
|
||||||
pending_specializations: &mut BumpMap<
|
pending_specializations: &mut BumpMap<Symbol, MutMap<Layout<'a>, PendingSpecialization<'a>>>,
|
||||||
'a,
|
|
||||||
Symbol,
|
|
||||||
MutMap<Layout<'a>, PendingSpecialization<'a>>,
|
|
||||||
>,
|
|
||||||
symbol: Symbol,
|
symbol: Symbol,
|
||||||
layout: Layout<'a>,
|
layout: Layout<'a>,
|
||||||
pending: PendingSpecialization<'a>,
|
pending: PendingSpecialization<'a>,
|
||||||
|
@ -1860,10 +1861,7 @@ fn specialize_external<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
HostExposedLayouts::HostExposed {
|
HostExposedLayouts::HostExposed {
|
||||||
rigids: hashbrown::HashMap::with_hasher_in(
|
rigids: BumpMap::new_in(env.arena),
|
||||||
default_hasher(),
|
|
||||||
hashbrown::BumpWrapper(env.arena),
|
|
||||||
),
|
|
||||||
aliases,
|
aliases,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -2314,6 +2312,7 @@ fn specialize<'a>(
|
||||||
let PendingSpecialization {
|
let PendingSpecialization {
|
||||||
solved_type,
|
solved_type,
|
||||||
host_exposed_aliases,
|
host_exposed_aliases,
|
||||||
|
..
|
||||||
} = pending;
|
} = pending;
|
||||||
|
|
||||||
specialize_solved_type(
|
specialize_solved_type(
|
||||||
|
|
|
@ -32,7 +32,7 @@ pub enum Constraint<'a> {
|
||||||
pub struct LetConstraint<'a> {
|
pub struct LetConstraint<'a> {
|
||||||
pub rigid_vars: BumpVec<'a, Variable>,
|
pub rigid_vars: BumpVec<'a, Variable>,
|
||||||
pub flex_vars: BumpVec<'a, Variable>,
|
pub flex_vars: BumpVec<'a, Variable>,
|
||||||
pub def_types: BumpMap<'a, Symbol, Located<Type2>>,
|
pub def_types: BumpMap<Symbol, Located<Type2>>,
|
||||||
pub defs_constraint: Constraint<'a>,
|
pub defs_constraint: Constraint<'a>,
|
||||||
pub ret_constraint: Constraint<'a>,
|
pub ret_constraint: Constraint<'a>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue