mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
use imported module thunks for pointer calling
This commit is contained in:
parent
a361148380
commit
6bd10ddc05
2 changed files with 24 additions and 1 deletions
|
@ -546,11 +546,24 @@ fn start_phase<'a>(module_id: ModuleId, phase: Phase, state: &mut State<'a>) ->
|
|||
ident_ids,
|
||||
} = typechecked;
|
||||
|
||||
let mut imported_module_thunks = MutSet::default();
|
||||
|
||||
if let Some(imports) = state.module_cache.imports.get(&module_id) {
|
||||
for imported in imports.iter() {
|
||||
imported_module_thunks.extend(
|
||||
state.module_cache.top_level_thunks[imported]
|
||||
.iter()
|
||||
.copied(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
BuildTask::BuildPendingSpecializations {
|
||||
layout_cache,
|
||||
module_id,
|
||||
module_timing,
|
||||
solved_subs,
|
||||
imported_module_thunks,
|
||||
decls,
|
||||
ident_ids,
|
||||
exposed_to_host: state.exposed_to_host.clone(),
|
||||
|
@ -950,6 +963,7 @@ enum BuildTask<'a> {
|
|||
module_timing: ModuleTiming,
|
||||
layout_cache: LayoutCache<'a>,
|
||||
solved_subs: Solved<Subs>,
|
||||
imported_module_thunks: MutSet<Symbol>,
|
||||
module_id: ModuleId,
|
||||
ident_ids: IdentIds,
|
||||
decls: Vec<Declaration>,
|
||||
|
@ -3666,6 +3680,7 @@ fn make_specializations<'a>(
|
|||
fn build_pending_specializations<'a>(
|
||||
arena: &'a Bump,
|
||||
solved_subs: Solved<Subs>,
|
||||
imported_module_thunks: MutSet<Symbol>,
|
||||
home: ModuleId,
|
||||
mut ident_ids: IdentIds,
|
||||
decls: Vec<Declaration>,
|
||||
|
@ -3678,6 +3693,9 @@ fn build_pending_specializations<'a>(
|
|||
let find_specializations_start = SystemTime::now();
|
||||
let mut procs = Procs::default();
|
||||
|
||||
debug_assert!(procs.imported_module_thunks.is_empty());
|
||||
procs.imported_module_thunks = imported_module_thunks;
|
||||
|
||||
let mut mono_problems = std::vec::Vec::new();
|
||||
let mut subs = solved_subs.into_inner();
|
||||
let mut mono_env = roc_mono::ir::Env {
|
||||
|
@ -3959,10 +3977,12 @@ where
|
|||
module_timing,
|
||||
layout_cache,
|
||||
solved_subs,
|
||||
imported_module_thunks,
|
||||
exposed_to_host,
|
||||
} => Ok(build_pending_specializations(
|
||||
arena,
|
||||
solved_subs,
|
||||
imported_module_thunks,
|
||||
module_id,
|
||||
ident_ids,
|
||||
decls,
|
||||
|
|
|
@ -5725,8 +5725,11 @@ fn call_by_pointer<'a>(
|
|||
// cause issues. The caller (which is here) doesn't know whether the called is a closure
|
||||
// so we're safe rather than sorry for now. Hopefully we can figure out how to call by name
|
||||
// more in the future
|
||||
let is_thunk =
|
||||
procs.module_thunks.contains(&symbol) || procs.imported_module_thunks.contains(&symbol);
|
||||
|
||||
match layout {
|
||||
Layout::FunctionPointer(arg_layouts, ret_layout) if false => {
|
||||
Layout::FunctionPointer(arg_layouts, ret_layout) if !is_thunk => {
|
||||
if arg_layouts.iter().any(|l| l.contains_refcounted()) {
|
||||
let name = env.unique_symbol();
|
||||
let mut args = Vec::with_capacity_in(arg_layouts.len(), env.arena);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue