mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 05:34:11 +03:00
bumpalo allocator sadness; revert later
This commit is contained in:
parent
2032ef9b52
commit
cd1103df64
@ -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 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 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 BumpMap<K, V> = hashbrown::HashMap<K, V, BuildHasher>;
|
||||
pub type BumpSet<K> = hashbrown::HashSet<K, BuildHasher>;
|
||||
|
||||
pub trait BumpMapDefault<'a> {
|
||||
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;
|
||||
}
|
||||
|
||||
impl<'a, K, V> BumpMapDefault<'a> for BumpMap<'a, K, V> {
|
||||
fn new_in(arena: &'a bumpalo::Bump) -> Self {
|
||||
hashbrown::HashMap::with_hasher_in(default_hasher(), hashbrown::BumpWrapper(arena))
|
||||
impl<'a, K, V> BumpMapDefault<'a> for BumpMap<K, V> {
|
||||
fn new_in(_arena: &'a bumpalo::Bump) -> Self {
|
||||
// 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 {
|
||||
hashbrown::HashMap::with_capacity_and_hasher_in(
|
||||
capacity,
|
||||
default_hasher(),
|
||||
hashbrown::BumpWrapper(arena),
|
||||
)
|
||||
fn with_capacity_in(capacity: usize, _arena: &'a bumpalo::Bump) -> Self {
|
||||
// hashbrown::HashMap::with_capacity_and_hasher_in(
|
||||
// capacity,
|
||||
// default_hasher(),
|
||||
// hashbrown::BumpWrapper(arena),
|
||||
// )
|
||||
hashbrown::HashMap::with_capacity_and_hasher(capacity, default_hasher())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K> BumpMapDefault<'a> for BumpSet<'a, K> {
|
||||
fn new_in(arena: &'a bumpalo::Bump) -> Self {
|
||||
hashbrown::HashSet::with_hasher_in(default_hasher(), hashbrown::BumpWrapper(arena))
|
||||
impl<'a, K> BumpMapDefault<'a> for BumpSet<K> {
|
||||
fn new_in(_arena: &'a bumpalo::Bump) -> Self {
|
||||
// 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 {
|
||||
hashbrown::HashSet::with_capacity_and_hasher_in(
|
||||
capacity,
|
||||
default_hasher(),
|
||||
hashbrown::BumpWrapper(arena),
|
||||
)
|
||||
fn with_capacity_in(capacity: usize, _arena: &'a bumpalo::Bump) -> Self {
|
||||
// hashbrown::HashSet::with_capacity_and_hasher_in(
|
||||
// capacity,
|
||||
// default_hasher(),
|
||||
// hashbrown::BumpWrapper(arena),
|
||||
// )
|
||||
hashbrown::HashSet::with_capacity_and_hasher(capacity, default_hasher())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -774,7 +774,7 @@ enum Msg<'a> {
|
||||
module_id: ModuleId,
|
||||
ident_ids: IdentIds,
|
||||
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>>,
|
||||
problems: Vec<roc_mono::ir::MonoProblem>,
|
||||
module_timing: ModuleTiming,
|
||||
@ -976,7 +976,7 @@ enum BuildTask<'a> {
|
||||
module_timing: ModuleTiming,
|
||||
layout_cache: LayoutCache<'a>,
|
||||
solved_subs: Solved<Subs>,
|
||||
imported_module_thunks: BumpSet<'a, Symbol>,
|
||||
imported_module_thunks: BumpSet<Symbol>,
|
||||
module_id: ModuleId,
|
||||
ident_ids: IdentIds,
|
||||
decls: Vec<Declaration>,
|
||||
@ -3831,7 +3831,7 @@ fn make_specializations<'a>(
|
||||
fn build_pending_specializations<'a>(
|
||||
arena: &'a Bump,
|
||||
solved_subs: Solved<Subs>,
|
||||
imported_module_thunks: BumpSet<'a, Symbol>,
|
||||
imported_module_thunks: BumpSet<Symbol>,
|
||||
home: ModuleId,
|
||||
mut ident_ids: IdentIds,
|
||||
decls: Vec<Declaration>,
|
||||
|
@ -73,7 +73,8 @@ impl<'a> CapturedSymbols<'a> {
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct PendingSpecialization<'a> {
|
||||
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> {
|
||||
@ -82,6 +83,7 @@ impl<'a> PendingSpecialization<'a> {
|
||||
PendingSpecialization {
|
||||
solved_type,
|
||||
host_exposed_aliases: BumpMap::new_in(arena),
|
||||
_lifetime: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,6 +106,7 @@ impl<'a> PendingSpecialization<'a> {
|
||||
PendingSpecialization {
|
||||
solved_type,
|
||||
host_exposed_aliases,
|
||||
_lifetime: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -124,8 +127,8 @@ pub struct Proc<'a> {
|
||||
pub enum HostExposedLayouts<'a> {
|
||||
NotHostExposed,
|
||||
HostExposed {
|
||||
rigids: BumpMap<'a, Lowercase, Layout<'a>>,
|
||||
aliases: BumpMap<'a, Symbol, Layout<'a>>,
|
||||
rigids: BumpMap<Lowercase, Layout<'a>>,
|
||||
aliases: BumpMap<Symbol, Layout<'a>>,
|
||||
},
|
||||
}
|
||||
|
||||
@ -239,13 +242,15 @@ impl<'a> Proc<'a> {
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
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> {
|
||||
pub fn new_in(arena: &'a Bump) -> Self {
|
||||
Self {
|
||||
specs: BumpMap::new_in(arena),
|
||||
_lifetime: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,16 +281,16 @@ impl<'a> ExternalSpecializations<'a> {
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Procs<'a> {
|
||||
pub partial_procs: BumpMap<'a, Symbol, PartialProc<'a>>,
|
||||
pub imported_module_thunks: BumpSet<'a, Symbol>,
|
||||
pub module_thunks: BumpSet<'a, Symbol>,
|
||||
pub partial_procs: BumpMap<Symbol, PartialProc<'a>>,
|
||||
pub imported_module_thunks: BumpSet<Symbol>,
|
||||
pub module_thunks: BumpSet<Symbol>,
|
||||
pub pending_specializations:
|
||||
Option<BumpMap<'a, Symbol, MutMap<Layout<'a>, PendingSpecialization<'a>>>>,
|
||||
pub specialized: BumpMap<'a, (Symbol, Layout<'a>), InProgressProc<'a>>,
|
||||
pub runtime_errors: BumpMap<'a, Symbol, &'a str>,
|
||||
pub call_by_pointer_wrappers: BumpMap<'a, Symbol, Symbol>,
|
||||
Option<BumpMap<Symbol, MutMap<Layout<'a>, PendingSpecialization<'a>>>>,
|
||||
pub specialized: BumpMap<(Symbol, Layout<'a>), InProgressProc<'a>>,
|
||||
pub runtime_errors: BumpMap<Symbol, &'a str>,
|
||||
pub call_by_pointer_wrappers: BumpMap<Symbol, Symbol>,
|
||||
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> {
|
||||
@ -681,11 +686,7 @@ impl<'a> Procs<'a> {
|
||||
}
|
||||
|
||||
fn add_pending<'a>(
|
||||
pending_specializations: &mut BumpMap<
|
||||
'a,
|
||||
Symbol,
|
||||
MutMap<Layout<'a>, PendingSpecialization<'a>>,
|
||||
>,
|
||||
pending_specializations: &mut BumpMap<Symbol, MutMap<Layout<'a>, PendingSpecialization<'a>>>,
|
||||
symbol: Symbol,
|
||||
layout: Layout<'a>,
|
||||
pending: PendingSpecialization<'a>,
|
||||
@ -1860,10 +1861,7 @@ fn specialize_external<'a>(
|
||||
}
|
||||
|
||||
HostExposedLayouts::HostExposed {
|
||||
rigids: hashbrown::HashMap::with_hasher_in(
|
||||
default_hasher(),
|
||||
hashbrown::BumpWrapper(env.arena),
|
||||
),
|
||||
rigids: BumpMap::new_in(env.arena),
|
||||
aliases,
|
||||
}
|
||||
};
|
||||
@ -2314,6 +2312,7 @@ fn specialize<'a>(
|
||||
let PendingSpecialization {
|
||||
solved_type,
|
||||
host_exposed_aliases,
|
||||
..
|
||||
} = pending;
|
||||
|
||||
specialize_solved_type(
|
||||
|
@ -32,7 +32,7 @@ pub enum Constraint<'a> {
|
||||
pub struct LetConstraint<'a> {
|
||||
pub rigid_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 ret_constraint: Constraint<'a>,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user