mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
thread fx expects to the runner
This commit is contained in:
parent
7e6a3ddc15
commit
82c07590db
2 changed files with 54 additions and 16 deletions
|
@ -689,6 +689,12 @@ struct LateSpecializationsModule<'a> {
|
||||||
procs_base: ProcsBase<'a>,
|
procs_base: ProcsBase<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default)]
|
||||||
|
pub struct ToplevelExpects {
|
||||||
|
pub pure: VecMap<Symbol, Region>,
|
||||||
|
pub fx: VecMap<Symbol, Region>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MonomorphizedModule<'a> {
|
pub struct MonomorphizedModule<'a> {
|
||||||
pub module_id: ModuleId,
|
pub module_id: ModuleId,
|
||||||
|
@ -698,7 +704,7 @@ pub struct MonomorphizedModule<'a> {
|
||||||
pub can_problems: MutMap<ModuleId, Vec<roc_problem::can::Problem>>,
|
pub can_problems: MutMap<ModuleId, Vec<roc_problem::can::Problem>>,
|
||||||
pub type_problems: MutMap<ModuleId, Vec<TypeError>>,
|
pub type_problems: MutMap<ModuleId, Vec<TypeError>>,
|
||||||
pub procedures: MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
|
pub procedures: MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
|
||||||
pub toplevel_expects: VecMap<Symbol, Region>,
|
pub toplevel_expects: ToplevelExpects,
|
||||||
pub entry_point: EntryPoint<'a>,
|
pub entry_point: EntryPoint<'a>,
|
||||||
pub exposed_to_host: ExposedToHost,
|
pub exposed_to_host: ExposedToHost,
|
||||||
pub sources: MutMap<ModuleId, (PathBuf, Box<str>)>,
|
pub sources: MutMap<ModuleId, (PathBuf, Box<str>)>,
|
||||||
|
@ -803,7 +809,7 @@ enum Msg<'a> {
|
||||||
solved_subs: Solved<Subs>,
|
solved_subs: Solved<Subs>,
|
||||||
module_timing: ModuleTiming,
|
module_timing: ModuleTiming,
|
||||||
abilities_store: AbilitiesStore,
|
abilities_store: AbilitiesStore,
|
||||||
toplevel_expects: VecMap<Symbol, Region>,
|
toplevel_expects: ToplevelExpects,
|
||||||
},
|
},
|
||||||
MadeSpecializations {
|
MadeSpecializations {
|
||||||
module_id: ModuleId,
|
module_id: ModuleId,
|
||||||
|
@ -890,7 +896,7 @@ struct State<'a> {
|
||||||
pub module_cache: ModuleCache<'a>,
|
pub module_cache: ModuleCache<'a>,
|
||||||
pub dependencies: Dependencies<'a>,
|
pub dependencies: Dependencies<'a>,
|
||||||
pub procedures: MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
|
pub procedures: MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
|
||||||
pub toplevel_expects: VecMap<Symbol, Region>,
|
pub toplevel_expects: ToplevelExpects,
|
||||||
pub exposed_to_host: ExposedToHost,
|
pub exposed_to_host: ExposedToHost,
|
||||||
|
|
||||||
/// This is the "final" list of IdentIds, after canonicalization and constraint gen
|
/// This is the "final" list of IdentIds, after canonicalization and constraint gen
|
||||||
|
@ -963,7 +969,7 @@ impl<'a> State<'a> {
|
||||||
module_cache: ModuleCache::default(),
|
module_cache: ModuleCache::default(),
|
||||||
dependencies,
|
dependencies,
|
||||||
procedures: MutMap::default(),
|
procedures: MutMap::default(),
|
||||||
toplevel_expects: VecMap::default(),
|
toplevel_expects: ToplevelExpects::default(),
|
||||||
exposed_to_host: ExposedToHost::default(),
|
exposed_to_host: ExposedToHost::default(),
|
||||||
exposed_types,
|
exposed_types,
|
||||||
arc_modules,
|
arc_modules,
|
||||||
|
@ -2465,7 +2471,8 @@ fn update<'a>(
|
||||||
|
|
||||||
let subs = solved_subs.into_inner();
|
let subs = solved_subs.into_inner();
|
||||||
|
|
||||||
state.toplevel_expects.extend(toplevel_expects);
|
state.toplevel_expects.pure.extend(toplevel_expects.pure);
|
||||||
|
state.toplevel_expects.fx.extend(toplevel_expects.fx);
|
||||||
|
|
||||||
state
|
state
|
||||||
.module_cache
|
.module_cache
|
||||||
|
@ -4756,7 +4763,7 @@ fn build_pending_specializations<'a>(
|
||||||
let find_specializations_start = Instant::now();
|
let find_specializations_start = Instant::now();
|
||||||
|
|
||||||
let mut module_thunks = bumpalo::collections::Vec::new_in(arena);
|
let mut module_thunks = bumpalo::collections::Vec::new_in(arena);
|
||||||
let mut toplevel_expects = VecMap::default();
|
let mut toplevel_expects = ToplevelExpects::default();
|
||||||
|
|
||||||
let mut procs_base = ProcsBase {
|
let mut procs_base = ProcsBase {
|
||||||
partial_procs: BumpMap::default(),
|
partial_procs: BumpMap::default(),
|
||||||
|
@ -5067,7 +5074,7 @@ fn build_pending_specializations<'a>(
|
||||||
let expr_region = declarations.expressions[index].region;
|
let expr_region = declarations.expressions[index].region;
|
||||||
let region = Region::span_across(&name_region, &expr_region);
|
let region = Region::span_across(&name_region, &expr_region);
|
||||||
|
|
||||||
toplevel_expects.insert(symbol, region);
|
toplevel_expects.pure.insert(symbol, region);
|
||||||
procs_base.partial_procs.insert(symbol, proc);
|
procs_base.partial_procs.insert(symbol, proc);
|
||||||
}
|
}
|
||||||
ExpectationFx => {
|
ExpectationFx => {
|
||||||
|
@ -5141,7 +5148,7 @@ fn build_pending_specializations<'a>(
|
||||||
let expr_region = declarations.expressions[index].region;
|
let expr_region = declarations.expressions[index].region;
|
||||||
let region = Region::span_across(&name_region, &expr_region);
|
let region = Region::span_across(&name_region, &expr_region);
|
||||||
|
|
||||||
toplevel_expects.insert(symbol, region);
|
toplevel_expects.fx.insert(symbol, region);
|
||||||
procs_base.partial_procs.insert(symbol, proc);
|
procs_base.partial_procs.insert(symbol, proc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,13 @@ pub fn run_expects<W: std::io::Write>(
|
||||||
lib: &libloading::Library,
|
lib: &libloading::Library,
|
||||||
expectations: &mut VecMap<ModuleId, Expectations>,
|
expectations: &mut VecMap<ModuleId, Expectations>,
|
||||||
shared_ptr: *mut u8,
|
shared_ptr: *mut u8,
|
||||||
expects: bumpalo::collections::Vec<'_, ToplevelExpect<'_>>,
|
expects: ExpectFunctions<'_>,
|
||||||
) -> std::io::Result<(usize, usize)> {
|
) -> std::io::Result<(usize, usize)> {
|
||||||
let mut failed = 0;
|
let mut failed = 0;
|
||||||
let mut passed = 0;
|
let mut passed = 0;
|
||||||
|
|
||||||
for expect in expects {
|
for expect in expects.pure {
|
||||||
let result = run_expect(
|
let result = run_expect_pure(
|
||||||
writer,
|
writer,
|
||||||
render_target,
|
render_target,
|
||||||
arena,
|
arena,
|
||||||
|
@ -48,7 +48,7 @@ pub fn run_expects<W: std::io::Write>(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn run_expect<W: std::io::Write>(
|
fn run_expect_pure<W: std::io::Write>(
|
||||||
writer: &mut W,
|
writer: &mut W,
|
||||||
render_target: RenderTarget,
|
render_target: RenderTarget,
|
||||||
arena: &Bump,
|
arena: &Bump,
|
||||||
|
@ -251,13 +251,19 @@ pub struct ToplevelExpect<'a> {
|
||||||
pub region: Region,
|
pub region: Region,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ExpectFunctions<'a> {
|
||||||
|
pub pure: BumpVec<'a, ToplevelExpect<'a>>,
|
||||||
|
pub fx: BumpVec<'a, ToplevelExpect<'a>>,
|
||||||
|
}
|
||||||
|
|
||||||
pub fn expect_mono_module_to_dylib<'a>(
|
pub fn expect_mono_module_to_dylib<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
target: Triple,
|
target: Triple,
|
||||||
loaded: MonomorphizedModule<'a>,
|
loaded: MonomorphizedModule<'a>,
|
||||||
opt_level: OptLevel,
|
opt_level: OptLevel,
|
||||||
mode: LlvmBackendMode,
|
mode: LlvmBackendMode,
|
||||||
) -> Result<(libloading::Library, BumpVec<'a, ToplevelExpect<'a>>), libloading::Error> {
|
) -> Result<(libloading::Library, ExpectFunctions<'a>), libloading::Error> {
|
||||||
let target_info = TargetInfo::from(&target);
|
let target_info = TargetInfo::from(&target);
|
||||||
|
|
||||||
let MonomorphizedModule {
|
let MonomorphizedModule {
|
||||||
|
@ -306,18 +312,25 @@ pub fn expect_mono_module_to_dylib<'a>(
|
||||||
EntryPoint::Test => None,
|
EntryPoint::Test => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let capacity = toplevel_expects.pure.len() + toplevel_expects.fx.len();
|
||||||
|
let mut expect_symbols = BumpVec::with_capacity_in(capacity, env.arena);
|
||||||
|
|
||||||
|
expect_symbols.extend(toplevel_expects.pure.keys().copied());
|
||||||
|
expect_symbols.extend(toplevel_expects.fx.keys().copied());
|
||||||
|
|
||||||
let expect_names = roc_gen_llvm::llvm::build::build_procedures_expose_expects(
|
let expect_names = roc_gen_llvm::llvm::build::build_procedures_expose_expects(
|
||||||
&env,
|
&env,
|
||||||
opt_level,
|
opt_level,
|
||||||
toplevel_expects.unzip_slices().0,
|
&expect_symbols,
|
||||||
procedures,
|
procedures,
|
||||||
opt_entry_point,
|
opt_entry_point,
|
||||||
);
|
);
|
||||||
|
|
||||||
let expects = bumpalo::collections::Vec::from_iter_in(
|
let expects_fx = bumpalo::collections::Vec::from_iter_in(
|
||||||
toplevel_expects
|
toplevel_expects
|
||||||
|
.fx
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.zip(expect_names.into_iter())
|
.zip(expect_names.iter().skip(toplevel_expects.pure.len()))
|
||||||
.map(|((symbol, region), name)| ToplevelExpect {
|
.map(|((symbol, region), name)| ToplevelExpect {
|
||||||
symbol,
|
symbol,
|
||||||
region,
|
region,
|
||||||
|
@ -326,6 +339,24 @@ pub fn expect_mono_module_to_dylib<'a>(
|
||||||
env.arena,
|
env.arena,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let expects_pure = bumpalo::collections::Vec::from_iter_in(
|
||||||
|
toplevel_expects
|
||||||
|
.pure
|
||||||
|
.into_iter()
|
||||||
|
.zip(expect_names.iter())
|
||||||
|
.map(|((symbol, region), name)| ToplevelExpect {
|
||||||
|
symbol,
|
||||||
|
region,
|
||||||
|
name,
|
||||||
|
}),
|
||||||
|
env.arena,
|
||||||
|
);
|
||||||
|
|
||||||
|
let expects = ExpectFunctions {
|
||||||
|
pure: expects_pure,
|
||||||
|
fx: expects_fx,
|
||||||
|
};
|
||||||
|
|
||||||
env.dibuilder.finalize();
|
env.dibuilder.finalize();
|
||||||
|
|
||||||
// we don't use the debug info, and it causes weird errors.
|
// we don't use the debug info, and it causes weird errors.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue