mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 00:01:16 +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,
|
ident_ids,
|
||||||
} = typechecked;
|
} = 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 {
|
BuildTask::BuildPendingSpecializations {
|
||||||
layout_cache,
|
layout_cache,
|
||||||
module_id,
|
module_id,
|
||||||
module_timing,
|
module_timing,
|
||||||
solved_subs,
|
solved_subs,
|
||||||
|
imported_module_thunks,
|
||||||
decls,
|
decls,
|
||||||
ident_ids,
|
ident_ids,
|
||||||
exposed_to_host: state.exposed_to_host.clone(),
|
exposed_to_host: state.exposed_to_host.clone(),
|
||||||
|
@ -950,6 +963,7 @@ enum BuildTask<'a> {
|
||||||
module_timing: ModuleTiming,
|
module_timing: ModuleTiming,
|
||||||
layout_cache: LayoutCache<'a>,
|
layout_cache: LayoutCache<'a>,
|
||||||
solved_subs: Solved<Subs>,
|
solved_subs: Solved<Subs>,
|
||||||
|
imported_module_thunks: MutSet<Symbol>,
|
||||||
module_id: ModuleId,
|
module_id: ModuleId,
|
||||||
ident_ids: IdentIds,
|
ident_ids: IdentIds,
|
||||||
decls: Vec<Declaration>,
|
decls: Vec<Declaration>,
|
||||||
|
@ -3666,6 +3680,7 @@ fn make_specializations<'a>(
|
||||||
fn build_pending_specializations<'a>(
|
fn build_pending_specializations<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
solved_subs: Solved<Subs>,
|
solved_subs: Solved<Subs>,
|
||||||
|
imported_module_thunks: MutSet<Symbol>,
|
||||||
home: ModuleId,
|
home: ModuleId,
|
||||||
mut ident_ids: IdentIds,
|
mut ident_ids: IdentIds,
|
||||||
decls: Vec<Declaration>,
|
decls: Vec<Declaration>,
|
||||||
|
@ -3678,6 +3693,9 @@ fn build_pending_specializations<'a>(
|
||||||
let find_specializations_start = SystemTime::now();
|
let find_specializations_start = SystemTime::now();
|
||||||
let mut procs = Procs::default();
|
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 mono_problems = std::vec::Vec::new();
|
||||||
let mut subs = solved_subs.into_inner();
|
let mut subs = solved_subs.into_inner();
|
||||||
let mut mono_env = roc_mono::ir::Env {
|
let mut mono_env = roc_mono::ir::Env {
|
||||||
|
@ -3959,10 +3977,12 @@ where
|
||||||
module_timing,
|
module_timing,
|
||||||
layout_cache,
|
layout_cache,
|
||||||
solved_subs,
|
solved_subs,
|
||||||
|
imported_module_thunks,
|
||||||
exposed_to_host,
|
exposed_to_host,
|
||||||
} => Ok(build_pending_specializations(
|
} => Ok(build_pending_specializations(
|
||||||
arena,
|
arena,
|
||||||
solved_subs,
|
solved_subs,
|
||||||
|
imported_module_thunks,
|
||||||
module_id,
|
module_id,
|
||||||
ident_ids,
|
ident_ids,
|
||||||
decls,
|
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
|
// 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
|
// so we're safe rather than sorry for now. Hopefully we can figure out how to call by name
|
||||||
// more in the future
|
// more in the future
|
||||||
|
let is_thunk =
|
||||||
|
procs.module_thunks.contains(&symbol) || procs.imported_module_thunks.contains(&symbol);
|
||||||
|
|
||||||
match layout {
|
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()) {
|
if arg_layouts.iter().any(|l| l.contains_refcounted()) {
|
||||||
let name = env.unique_symbol();
|
let name = env.unique_symbol();
|
||||||
let mut args = Vec::with_capacity_in(arg_layouts.len(), env.arena);
|
let mut args = Vec::with_capacity_in(arg_layouts.len(), env.arena);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue