mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-10 18:08:55 +03:00
pipe a list of expects to llvm codegen
This commit is contained in:
parent
5df489ba23
commit
67cbe6a590
@ -10,7 +10,7 @@ use crate::num::{
|
||||
use crate::pattern::{canonicalize_pattern, BindingsFromPattern, Pattern};
|
||||
use crate::procedure::References;
|
||||
use crate::scope::Scope;
|
||||
use roc_collections::soa::{Index, Slice};
|
||||
use roc_collections::soa::Index;
|
||||
use roc_collections::{SendMap, VecMap, VecSet};
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_module::called_via::CalledVia;
|
||||
|
@ -4180,24 +4180,10 @@ pub fn build_procedures_return_main<'a, 'ctx, 'env>(
|
||||
pub fn build_procedures_expose_expects<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
opt_level: OptLevel,
|
||||
expects: &[Symbol],
|
||||
procedures: MutMap<(Symbol, ProcLayout<'a>), roc_mono::ir::Proc<'a>>,
|
||||
entry_point: EntryPoint<'a>,
|
||||
) -> Vec<'a, &'a str> {
|
||||
use bumpalo::collections::CollectIn;
|
||||
|
||||
// this is not entirely accurate: it will treat every top-level bool value (turned into a
|
||||
// zero-argument thunk) as an expect.
|
||||
let expects: Vec<_> = procedures
|
||||
.keys()
|
||||
.filter_map(|(symbol, proc_layout)| {
|
||||
if proc_layout.arguments.is_empty() && proc_layout.result == Layout::UNIT {
|
||||
Some(*symbol)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect_in(env.arena);
|
||||
|
||||
let mod_solutions = build_procedures_help(
|
||||
env,
|
||||
opt_level,
|
||||
|
@ -628,6 +628,7 @@ pub struct MonomorphizedModule<'a> {
|
||||
pub can_problems: MutMap<ModuleId, Vec<roc_problem::can::Problem>>,
|
||||
pub type_problems: MutMap<ModuleId, Vec<solve::TypeError>>,
|
||||
pub procedures: MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
|
||||
pub toplevel_expects: Vec<Symbol>,
|
||||
pub entry_point: EntryPoint<'a>,
|
||||
pub exposed_to_host: ExposedToHost,
|
||||
pub sources: MutMap<ModuleId, (PathBuf, Box<str>)>,
|
||||
@ -710,6 +711,7 @@ enum Msg<'a> {
|
||||
solved_subs: Solved<Subs>,
|
||||
module_timing: ModuleTiming,
|
||||
abilities_store: AbilitiesStore,
|
||||
toplevel_expects: std::vec::Vec<Symbol>,
|
||||
},
|
||||
MadeSpecializations {
|
||||
module_id: ModuleId,
|
||||
@ -797,6 +799,7 @@ struct State<'a> {
|
||||
pub module_cache: ModuleCache<'a>,
|
||||
pub dependencies: Dependencies<'a>,
|
||||
pub procedures: MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
|
||||
pub toplevel_expects: Vec<Symbol>,
|
||||
pub exposed_to_host: ExposedToHost,
|
||||
|
||||
/// This is the "final" list of IdentIds, after canonicalization and constraint gen
|
||||
@ -863,6 +866,7 @@ impl<'a> State<'a> {
|
||||
module_cache: ModuleCache::default(),
|
||||
dependencies: Dependencies::default(),
|
||||
procedures: MutMap::default(),
|
||||
toplevel_expects: Vec::new(),
|
||||
exposed_to_host: ExposedToHost::default(),
|
||||
exposed_types,
|
||||
arc_modules,
|
||||
@ -2321,11 +2325,14 @@ fn update<'a>(
|
||||
layout_cache,
|
||||
module_timing,
|
||||
abilities_store,
|
||||
toplevel_expects,
|
||||
} => {
|
||||
log!("found specializations for {:?}", module_id);
|
||||
|
||||
let subs = solved_subs.into_inner();
|
||||
|
||||
state.toplevel_expects.extend(toplevel_expects);
|
||||
|
||||
state
|
||||
.module_cache
|
||||
.top_level_thunks
|
||||
@ -2627,6 +2634,7 @@ fn finish_specialization(
|
||||
};
|
||||
|
||||
let State {
|
||||
toplevel_expects,
|
||||
procedures,
|
||||
module_cache,
|
||||
output_path,
|
||||
@ -2715,6 +2723,7 @@ fn finish_specialization(
|
||||
entry_point,
|
||||
sources,
|
||||
timings: state.timings,
|
||||
toplevel_expects,
|
||||
})
|
||||
}
|
||||
|
||||
@ -4517,13 +4526,14 @@ fn build_pending_specializations<'a>(
|
||||
mut module_timing: ModuleTiming,
|
||||
mut layout_cache: LayoutCache<'a>,
|
||||
target_info: TargetInfo,
|
||||
exposed_to_host: ExposedToHost, // TODO remove
|
||||
exposed_to_host: ExposedToHost,
|
||||
abilities_store: AbilitiesStore,
|
||||
derived_symbols: GlobalDerivedSymbols,
|
||||
) -> Msg<'a> {
|
||||
let find_specializations_start = SystemTime::now();
|
||||
|
||||
let mut module_thunks = bumpalo::collections::Vec::new_in(arena);
|
||||
let mut toplevel_expects = std::vec::Vec::new();
|
||||
|
||||
let mut procs_base = ProcsBase {
|
||||
partial_procs: BumpMap::default(),
|
||||
@ -4821,6 +4831,7 @@ fn build_pending_specializations<'a>(
|
||||
is_self_recursive: false,
|
||||
};
|
||||
|
||||
toplevel_expects.push(symbol);
|
||||
procs_base.partial_procs.insert(symbol, proc);
|
||||
}
|
||||
}
|
||||
@ -4841,6 +4852,7 @@ fn build_pending_specializations<'a>(
|
||||
procs_base,
|
||||
module_timing,
|
||||
abilities_store,
|
||||
toplevel_expects,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,6 +201,7 @@ pub fn expect_mono_module_to_dylib<'a>(
|
||||
let target_info = TargetInfo::from(&target);
|
||||
|
||||
let MonomorphizedModule {
|
||||
toplevel_expects,
|
||||
procedures,
|
||||
entry_point,
|
||||
interns,
|
||||
@ -241,6 +242,7 @@ pub fn expect_mono_module_to_dylib<'a>(
|
||||
let expects = roc_gen_llvm::llvm::build::build_procedures_expose_expects(
|
||||
&env,
|
||||
opt_level,
|
||||
&toplevel_expects,
|
||||
procedures,
|
||||
entry_point,
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user