Merge remote-tracking branch 'origin/trunk' into partialproc-by-reference

This commit is contained in:
Folkert 2021-11-03 15:24:58 +01:00
commit c5005d3dd1
77 changed files with 4144 additions and 3003 deletions

View file

@ -1181,6 +1181,10 @@ pub enum CallType<'a> {
/// specialization id of the function argument, used for name generation
specialization_id: CallSpecId,
/// update mode of the higher order lowlevel itself
update_mode: UpdateModeId,
/// function layout, used for name generation
arg_layouts: &'a [Layout<'a>],
ret_layout: Layout<'a>,
@ -4016,11 +4020,12 @@ pub fn with_hole<'a>(
lambda_set,
op,
closure_data_symbol,
|top_level_function, closure_data, closure_env_layout, specialization_id| self::Call {
|(top_level_function, closure_data, closure_env_layout, specialization_id, update_mode)| self::Call {
call_type: CallType::HigherOrderLowLevel {
op: crate::low_level::HigherOrder::$ho { $($x,)* },
closure_env_layout,
specialization_id,
update_mode,
function_owns_closure_data: false,
function_env: closure_data_symbol,
function_name: top_level_function,
@ -4144,6 +4149,16 @@ pub fn with_hole<'a>(
match_on_closure_argument!(ListMap3, [xs, ys, zs])
}
ListMap4 => {
debug_assert_eq!(arg_symbols.len(), 5);
let xs = arg_symbols[0];
let ys = arg_symbols[1];
let zs = arg_symbols[2];
let ws = arg_symbols[3];
match_on_closure_argument!(ListMap4, [xs, ys, zs, ws])
}
_ => {
let call = self::Call {
call_type: CallType::LowLevel {
@ -6192,7 +6207,7 @@ fn reuse_function_symbol<'a>(
// and closures by unification. Here we record whether this function captures
// anything.
let captures = partial_proc.captured_symbols.captures();
let captured = partial_proc.captured_symbols.clone();
let captured = partial_proc.captured_symbols;
match res_layout {
RawFunctionLayout::Function(_, lambda_set, _) => {
@ -7903,6 +7918,8 @@ pub fn num_argument_to_int_or_float(
}
}
type ToLowLevelCallArguments<'a> = (Symbol, Symbol, Option<Layout<'a>>, CallSpecId, UpdateModeId);
/// Use the lambda set to figure out how to make a lowlevel call
#[allow(clippy::too_many_arguments)]
fn lowlevel_match_on_lambda_set<'a, ToLowLevelCall>(
@ -7916,7 +7933,7 @@ fn lowlevel_match_on_lambda_set<'a, ToLowLevelCall>(
hole: &'a Stmt<'a>,
) -> Stmt<'a>
where
ToLowLevelCall: Fn(Symbol, Symbol, Option<Layout<'a>>, CallSpecId) -> Call<'a> + Copy,
ToLowLevelCall: Fn(ToLowLevelCallArguments<'a>) -> Call<'a> + Copy,
{
match lambda_set.runtime_representation() {
Layout::Union(union_layout) => {
@ -7951,12 +7968,14 @@ where
Layout::Struct(_) => match lambda_set.set.get(0) {
Some((function_symbol, _)) => {
let call_spec_id = env.next_call_specialization_id();
let call = to_lowlevel_call(
let update_mode = env.next_update_mode_id();
let call = to_lowlevel_call((
*function_symbol,
closure_data_symbol,
lambda_set.is_represented(),
call_spec_id,
);
update_mode,
));
build_call(env, call, assigned, return_layout, env.arena.alloc(hole))
}
@ -8021,7 +8040,7 @@ fn lowlevel_union_lambda_set_to_switch<'a, ToLowLevelCall>(
hole: &'a Stmt<'a>,
) -> Stmt<'a>
where
ToLowLevelCall: Fn(Symbol, Symbol, Option<Layout<'a>>, CallSpecId) -> Call<'a> + Copy,
ToLowLevelCall: Fn(ToLowLevelCallArguments<'a>) -> Call<'a> + Copy,
{
debug_assert!(!lambda_set.is_empty());
@ -8035,12 +8054,14 @@ where
let hole = Stmt::Jump(join_point_id, env.arena.alloc([assigned]));
let call_spec_id = env.next_call_specialization_id();
let call = to_lowlevel_call(
let update_mode = env.next_update_mode_id();
let call = to_lowlevel_call((
*function_symbol,
closure_data_symbol,
closure_env_layout,
call_spec_id,
);
update_mode,
));
let stmt = build_call(env, call, assigned, return_layout, env.arena.alloc(hole));
branches.push((i as u64, BranchInfo::None, stmt));
@ -8458,7 +8479,7 @@ fn lowlevel_enum_lambda_set_to_switch<'a, ToLowLevelCall>(
hole: &'a Stmt<'a>,
) -> Stmt<'a>
where
ToLowLevelCall: Fn(Symbol, Symbol, Option<Layout<'a>>, CallSpecId) -> Call<'a> + Copy,
ToLowLevelCall: Fn(ToLowLevelCallArguments<'a>) -> Call<'a> + Copy,
{
debug_assert!(!lambda_set.is_empty());
@ -8472,12 +8493,14 @@ where
let hole = Stmt::Jump(join_point_id, env.arena.alloc([result_symbol]));
let call_spec_id = env.next_call_specialization_id();
let call = to_lowlevel_call(
let update_mode = env.next_update_mode_id();
let call = to_lowlevel_call((
*function_symbol,
closure_data_symbol,
closure_env_layout,
call_spec_id,
);
update_mode,
));
let stmt = build_call(
env,
call,