mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
move around hostexposedalias logic
This commit is contained in:
parent
5d3c7a9363
commit
7fb4b60b21
11 changed files with 120 additions and 123 deletions
|
@ -6,8 +6,8 @@ use roc_module::symbol::{IdentIds, ModuleId, Symbol};
|
|||
use roc_target::TargetInfo;
|
||||
|
||||
use crate::ir::{
|
||||
BranchInfo, Call, CallSpecId, CallType, Expr, HostExposedLayouts, JoinPointId, Literal,
|
||||
ModifyRc, PassedFunction, Proc, ProcLayout, SelfRecursive, Stmt, UpdateModeId,
|
||||
BranchInfo, Call, CallSpecId, CallType, Expr, JoinPointId, Literal, ModifyRc, PassedFunction,
|
||||
Proc, ProcLayout, SelfRecursive, Stmt, UpdateModeId,
|
||||
};
|
||||
use crate::layout::{
|
||||
Builtin, InLayout, LambdaName, Layout, LayoutInterner, LayoutRepr, LayoutWrapper, Niche,
|
||||
|
@ -452,7 +452,7 @@ impl<'a> CodeGenHelp<'a> {
|
|||
closure_data_layout: None,
|
||||
ret_layout,
|
||||
is_self_recursive: SelfRecursive::NotSelfRecursive,
|
||||
host_exposed_layouts: HostExposedLayouts::NotHostExposed,
|
||||
is_host_exposed: false,
|
||||
is_erased: false,
|
||||
});
|
||||
|
||||
|
@ -772,7 +772,7 @@ impl<'a> CallerProc<'a> {
|
|||
closure_data_layout: None,
|
||||
ret_layout: Layout::UNIT,
|
||||
is_self_recursive: SelfRecursive::NotSelfRecursive,
|
||||
host_exposed_layouts: HostExposedLayouts::NotHostExposed,
|
||||
is_host_exposed: false,
|
||||
is_erased: false,
|
||||
};
|
||||
|
||||
|
@ -888,10 +888,7 @@ pub fn test_helper<'a>(
|
|||
closure_data_layout: None,
|
||||
ret_layout: output_layout,
|
||||
is_self_recursive: main_proc.is_self_recursive,
|
||||
host_exposed_layouts: HostExposedLayouts::HostExposed {
|
||||
rigids: Default::default(),
|
||||
aliases: Default::default(),
|
||||
},
|
||||
is_host_exposed: true,
|
||||
is_erased: false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ pub struct Proc<'a> {
|
|||
pub closure_data_layout: Option<InLayout<'a>>,
|
||||
pub ret_layout: InLayout<'a>,
|
||||
pub is_self_recursive: SelfRecursive,
|
||||
pub host_exposed_layouts: HostExposedLayouts<'a>,
|
||||
pub is_host_exposed: bool,
|
||||
pub is_erased: bool,
|
||||
}
|
||||
|
||||
|
@ -905,12 +905,16 @@ impl<'a> SpecializationStack<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub type HostExposedLambdaSets<'a> =
|
||||
std::vec::Vec<(LambdaName<'a>, Symbol, HostExposedLambdaSet<'a>)>;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Procs<'a> {
|
||||
pub partial_procs: PartialProcs<'a>,
|
||||
ability_member_aliases: AbilityAliases,
|
||||
pending_specializations: PendingSpecializations<'a>,
|
||||
specialized: Specialized<'a>,
|
||||
host_exposed_lambda_sets: HostExposedLambdaSets<'a>,
|
||||
pub runtime_errors: BumpMap<Symbol, &'a str>,
|
||||
pub externals_we_need: BumpMap<ModuleId, ExternalSpecializations<'a>>,
|
||||
symbol_specializations: SymbolSpecializations<'a>,
|
||||
|
@ -930,6 +934,7 @@ impl<'a> Procs<'a> {
|
|||
specialized: Specialized::default(),
|
||||
runtime_errors: BumpMap::new_in(arena),
|
||||
externals_we_need: BumpMap::new_in(arena),
|
||||
host_exposed_lambda_sets: std::vec::Vec::new(),
|
||||
symbol_specializations: Default::default(),
|
||||
specialization_stack: SpecializationStack(Vec::with_capacity_in(16, arena)),
|
||||
|
||||
|
@ -995,7 +1000,11 @@ impl<'a> Procs<'a> {
|
|||
|
||||
pub fn get_specialized_procs_without_rc(
|
||||
self,
|
||||
) -> (MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>, ProcsBase<'a>) {
|
||||
) -> (
|
||||
MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
|
||||
HostExposedLambdaSets<'a>,
|
||||
ProcsBase<'a>,
|
||||
) {
|
||||
let mut specialized_procs =
|
||||
MutMap::with_capacity_and_hasher(self.specialized.len(), default_hasher());
|
||||
|
||||
|
@ -1013,7 +1022,11 @@ impl<'a> Procs<'a> {
|
|||
imported_module_thunks: self.imported_module_thunks,
|
||||
};
|
||||
|
||||
(specialized_procs, restored_procs_base)
|
||||
(
|
||||
specialized_procs,
|
||||
self.host_exposed_lambda_sets,
|
||||
restored_procs_base,
|
||||
)
|
||||
}
|
||||
|
||||
// TODO trim these down
|
||||
|
@ -3062,9 +3075,9 @@ fn specialize_host_specializations<'a>(
|
|||
|
||||
let offset_variable = StorageSubs::merge_into(store, env.subs);
|
||||
|
||||
for (symbol, from_app, opt_from_platform) in it {
|
||||
for (lambda_name, from_app, opt_from_platform) in it {
|
||||
let from_app = offset_variable(from_app);
|
||||
let index = specialize_external_help(env, procs, layout_cache, symbol, from_app);
|
||||
let index = specialize_external_help(env, procs, layout_cache, lambda_name, from_app);
|
||||
|
||||
let Some(from_platform) = opt_from_platform else { continue };
|
||||
|
||||
|
@ -3095,8 +3108,6 @@ fn specialize_host_specializations<'a>(
|
|||
}
|
||||
}
|
||||
|
||||
let mut aliases = BumpMap::default();
|
||||
|
||||
for (var, id) in hels {
|
||||
let symbol = env.unique_symbol();
|
||||
let lambda_name = LambdaName::no_niche(symbol);
|
||||
|
@ -3128,20 +3139,10 @@ fn specialize_host_specializations<'a>(
|
|||
raw_function_layout,
|
||||
};
|
||||
|
||||
aliases.insert(key, hels);
|
||||
}
|
||||
let in_progress = &mut procs.specialized.procedures[index.0];
|
||||
let InProgressProc::Done(proc) = in_progress else { unreachable!() };
|
||||
|
||||
let in_progress = &mut procs.specialized.procedures[index.0];
|
||||
let InProgressProc::Done(proc) = in_progress else { unreachable!() };
|
||||
|
||||
match &mut proc.host_exposed_layouts {
|
||||
HostExposedLayouts::HostExposed { aliases: old, .. } => old.extend(aliases),
|
||||
hep @ HostExposedLayouts::NotHostExposed => {
|
||||
*hep = HostExposedLayouts::HostExposed {
|
||||
aliases,
|
||||
rigids: Default::default(),
|
||||
};
|
||||
}
|
||||
procs.host_exposed_lambda_sets.push((proc.name, key, hels));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3308,7 +3309,7 @@ fn generate_runtime_error_function<'a>(
|
|||
closure_data_layout: None,
|
||||
ret_layout,
|
||||
is_self_recursive: SelfRecursive::NotSelfRecursive,
|
||||
host_exposed_layouts: HostExposedLayouts::NotHostExposed,
|
||||
is_host_exposed: false,
|
||||
is_erased,
|
||||
}
|
||||
}
|
||||
|
@ -3404,7 +3405,7 @@ fn generate_host_exposed_function<'a>(
|
|||
closure_data_layout: None,
|
||||
ret_layout: result,
|
||||
is_self_recursive: SelfRecursive::NotSelfRecursive,
|
||||
host_exposed_layouts: HostExposedLayouts::NotHostExposed,
|
||||
is_host_exposed: false,
|
||||
is_erased: false,
|
||||
};
|
||||
|
||||
|
@ -3469,7 +3470,7 @@ fn generate_host_exposed_lambda_set<'a>(
|
|||
closure_data_layout: None,
|
||||
ret_layout: return_layout,
|
||||
is_self_recursive: SelfRecursive::NotSelfRecursive,
|
||||
host_exposed_layouts: HostExposedLayouts::NotHostExposed,
|
||||
is_host_exposed: false,
|
||||
is_erased: false,
|
||||
};
|
||||
|
||||
|
@ -3533,9 +3534,6 @@ fn specialize_proc_help<'a>(
|
|||
let body = partial_proc.body.clone();
|
||||
let body_var = partial_proc.body_var;
|
||||
|
||||
// host-exposed functions are tagged on later
|
||||
let host_exposed_layouts = HostExposedLayouts::NotHostExposed;
|
||||
|
||||
let mut specialized_body = from_can(env, body_var, body, procs, layout_cache);
|
||||
|
||||
let specialized_proc = match specialized {
|
||||
|
@ -3567,7 +3565,7 @@ fn specialize_proc_help<'a>(
|
|||
closure_data_layout: Some(closure_data_layout),
|
||||
ret_layout,
|
||||
is_self_recursive: recursivity,
|
||||
host_exposed_layouts,
|
||||
is_host_exposed: false,
|
||||
is_erased,
|
||||
}
|
||||
}
|
||||
|
@ -3770,7 +3768,7 @@ fn specialize_proc_help<'a>(
|
|||
closure_data_layout,
|
||||
ret_layout,
|
||||
is_self_recursive: recursivity,
|
||||
host_exposed_layouts,
|
||||
is_host_exposed: false,
|
||||
is_erased,
|
||||
}
|
||||
}
|
||||
|
@ -10330,7 +10328,7 @@ where
|
|||
closure_data_layout: None,
|
||||
ret_layout: *field,
|
||||
is_self_recursive: SelfRecursive::NotSelfRecursive,
|
||||
host_exposed_layouts: HostExposedLayouts::NotHostExposed,
|
||||
is_host_exposed: false,
|
||||
is_erased: false,
|
||||
};
|
||||
|
||||
|
@ -10426,7 +10424,7 @@ where
|
|||
closure_data_layout: None,
|
||||
ret_layout: *field,
|
||||
is_self_recursive: SelfRecursive::NotSelfRecursive,
|
||||
host_exposed_layouts: HostExposedLayouts::NotHostExposed,
|
||||
is_host_exposed: false,
|
||||
is_erased: false,
|
||||
};
|
||||
|
||||
|
|
|
@ -802,7 +802,7 @@ impl<'a> TrmcEnv<'a> {
|
|||
closure_data_layout: proc.closure_data_layout,
|
||||
ret_layout: proc.ret_layout,
|
||||
is_self_recursive: SelfRecursive::NotSelfRecursive,
|
||||
host_exposed_layouts: proc.host_exposed_layouts.clone(),
|
||||
is_host_exposed: proc.is_host_exposed,
|
||||
is_erased: proc.is_erased,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue