turn module_thunks into a slice

This commit is contained in:
Folkert 2021-10-22 22:59:00 +02:00
parent 6a6ea64323
commit 2e773e5f66
2 changed files with 14 additions and 7 deletions

View file

@ -3952,7 +3952,7 @@ fn make_specializations<'a>(
let mut procs = Procs::new_in(arena);
procs.partial_procs = procs_base.partial_procs;
procs.module_thunks.extend(procs_base.module_thunks);
procs.module_thunks = procs_base.module_thunks;
procs.runtime_errors = procs_base.runtime_errors;
procs.imported_module_thunks = procs_base.imported_module_thunks;
@ -3990,7 +3990,7 @@ fn make_specializations<'a>(
#[derive(Clone, Debug)]
struct ProcsBase<'a> {
partial_procs: BumpMap<Symbol, PartialProc<'a>>,
module_thunks: std::vec::Vec<Symbol>,
module_thunks: &'a [Symbol],
pending_specializations: BumpMap<Symbol, MutMap<ProcLayout<'a>, PendingSpecialization<'a>>>,
runtime_errors: BumpMap<Symbol, &'a str>,
imported_module_thunks: &'a [Symbol],
@ -4028,9 +4028,11 @@ fn build_pending_specializations<'a>(
) -> Msg<'a> {
let find_specializations_start = SystemTime::now();
let mut module_thunks = bumpalo::collections::Vec::new_in(arena);
let mut procs_base = ProcsBase {
partial_procs: BumpMap::default(),
module_thunks: std::vec::Vec::new(),
module_thunks: &[],
pending_specializations: BumpMap::default(),
runtime_errors: BumpMap::default(),
imported_module_thunks,
@ -4058,6 +4060,7 @@ fn build_pending_specializations<'a>(
Declare(def) | Builtin(def) => add_def_to_module(
&mut layout_cache,
&mut procs_base,
&mut module_thunks,
&mut mono_env,
def,
&exposed_to_host,
@ -4068,6 +4071,7 @@ fn build_pending_specializations<'a>(
add_def_to_module(
&mut layout_cache,
&mut procs_base,
&mut module_thunks,
&mut mono_env,
def,
&exposed_to_host,
@ -4082,6 +4086,8 @@ fn build_pending_specializations<'a>(
}
}
procs_base.module_thunks = module_thunks.into_bump_slice();
let problems = mono_env.problems.to_vec();
let find_specializations_end = SystemTime::now();
@ -4103,6 +4109,7 @@ fn build_pending_specializations<'a>(
fn add_def_to_module<'a>(
layout_cache: &mut LayoutCache<'a>,
procs: &mut ProcsBase<'a>,
module_thunks: &mut bumpalo::collections::Vec<'a, Symbol>,
mono_env: &mut roc_mono::ir::Env<'a, '_>,
def: roc_can::def::Def,
exposed_to_host: &MutMap<Symbol, Variable>,
@ -4193,7 +4200,7 @@ fn add_def_to_module<'a>(
}
body => {
// mark this symbols as a top-level thunk before any other work on the procs
procs.module_thunks.push(symbol);
module_thunks.push(symbol);
// If this is an exposed symbol, we need to
// register it as such. Otherwise, since it

View file

@ -8,7 +8,7 @@ use crate::layout::{
};
use bumpalo::collections::Vec;
use bumpalo::Bump;
use roc_collections::all::{default_hasher, BumpMap, BumpMapDefault, BumpSet, MutMap, MutSet};
use roc_collections::all::{default_hasher, BumpMap, BumpMapDefault, MutMap, MutSet};
use roc_module::ident::{ForeignSymbol, Lowercase, TagName};
use roc_module::low_level::LowLevel;
use roc_module::symbol::{IdentIds, ModuleId, Symbol};
@ -418,7 +418,7 @@ impl<'a> ExternalSpecializations<'a> {
pub struct Procs<'a> {
pub partial_procs: BumpMap<Symbol, PartialProc<'a>>,
pub imported_module_thunks: &'a [Symbol],
pub module_thunks: BumpSet<Symbol>,
pub module_thunks: &'a [Symbol],
pub pending_specializations:
Option<BumpMap<Symbol, MutMap<ProcLayout<'a>, PendingSpecialization<'a>>>>,
pub specialized: BumpMap<(Symbol, ProcLayout<'a>), InProgressProc<'a>>,
@ -432,7 +432,7 @@ impl<'a> Procs<'a> {
Self {
partial_procs: BumpMap::new_in(arena),
imported_module_thunks: &[],
module_thunks: BumpSet::new_in(arena),
module_thunks: &[],
pending_specializations: Some(BumpMap::new_in(arena)),
specialized: BumpMap::new_in(arena),
runtime_errors: BumpMap::new_in(arena),