mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
shrink Call
This commit is contained in:
parent
13713ee6ad
commit
83953b0bba
5 changed files with 39 additions and 39 deletions
|
@ -672,7 +672,7 @@ fn promote_to_main_function<'a, 'ctx, 'env>(
|
||||||
top_level: ProcLayout<'a>,
|
top_level: ProcLayout<'a>,
|
||||||
) -> (&'static str, FunctionValue<'ctx>) {
|
) -> (&'static str, FunctionValue<'ctx>) {
|
||||||
let it = top_level.arguments.iter().copied();
|
let it = top_level.arguments.iter().copied();
|
||||||
let bytes = roc_mono::alias_analysis::func_name_bytes_help(symbol, it, top_level.result);
|
let bytes = roc_mono::alias_analysis::func_name_bytes_help(symbol, it, &top_level.result);
|
||||||
let func_name = FuncName(&bytes);
|
let func_name = FuncName(&bytes);
|
||||||
let func_solutions = mod_solutions.func_solutions(func_name).unwrap();
|
let func_solutions = mod_solutions.func_solutions(func_name).unwrap();
|
||||||
|
|
||||||
|
@ -4150,7 +4150,7 @@ pub fn build_proc<'a, 'ctx, 'env>(
|
||||||
let bytes = roc_mono::alias_analysis::func_name_bytes_help(
|
let bytes = roc_mono::alias_analysis::func_name_bytes_help(
|
||||||
symbol,
|
symbol,
|
||||||
it,
|
it,
|
||||||
top_level.result,
|
&top_level.result,
|
||||||
);
|
);
|
||||||
let func_name = FuncName(&bytes);
|
let func_name = FuncName(&bytes);
|
||||||
let func_solutions = mod_solutions.func_solutions(func_name).unwrap();
|
let func_solutions = mod_solutions.func_solutions(func_name).unwrap();
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub const STATIC_LIST_NAME: ConstName = ConstName(b"THIS IS A STATIC LIST");
|
||||||
const ENTRY_POINT_NAME: &[u8] = b"mainForHost";
|
const ENTRY_POINT_NAME: &[u8] = b"mainForHost";
|
||||||
|
|
||||||
pub fn func_name_bytes(proc: &Proc) -> [u8; SIZE] {
|
pub fn func_name_bytes(proc: &Proc) -> [u8; SIZE] {
|
||||||
func_name_bytes_help(proc.name, proc.args.iter().map(|x| x.0), proc.ret_layout)
|
func_name_bytes_help(proc.name, proc.args.iter().map(|x| x.0), &proc.ret_layout)
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEBUG: bool = false;
|
const DEBUG: bool = false;
|
||||||
|
@ -53,7 +53,7 @@ impl TagUnionId {
|
||||||
pub fn func_name_bytes_help<'a, I>(
|
pub fn func_name_bytes_help<'a, I>(
|
||||||
symbol: Symbol,
|
symbol: Symbol,
|
||||||
argument_layouts: I,
|
argument_layouts: I,
|
||||||
return_layout: Layout<'a>,
|
return_layout: &Layout<'a>,
|
||||||
) -> [u8; SIZE]
|
) -> [u8; SIZE]
|
||||||
where
|
where
|
||||||
I: Iterator<Item = Layout<'a>>,
|
I: Iterator<Item = Layout<'a>>,
|
||||||
|
@ -162,13 +162,13 @@ where
|
||||||
match layout {
|
match layout {
|
||||||
RawFunctionLayout::Function(_, _, _) => {
|
RawFunctionLayout::Function(_, _, _) => {
|
||||||
let it = top_level.arguments.iter().copied();
|
let it = top_level.arguments.iter().copied();
|
||||||
let bytes = func_name_bytes_help(*symbol, it, top_level.result);
|
let bytes = func_name_bytes_help(*symbol, it, &top_level.result);
|
||||||
|
|
||||||
host_exposed_functions.push((bytes, top_level.arguments));
|
host_exposed_functions.push((bytes, top_level.arguments));
|
||||||
}
|
}
|
||||||
RawFunctionLayout::ZeroArgumentThunk(_) => {
|
RawFunctionLayout::ZeroArgumentThunk(_) => {
|
||||||
let it = std::iter::once(Layout::Struct(&[]));
|
let it = std::iter::once(Layout::Struct(&[]));
|
||||||
let bytes = func_name_bytes_help(*symbol, it, top_level.result);
|
let bytes = func_name_bytes_help(*symbol, it, &top_level.result);
|
||||||
|
|
||||||
host_exposed_functions.push((bytes, top_level.arguments));
|
host_exposed_functions.push((bytes, top_level.arguments));
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ where
|
||||||
let roc_main_bytes = func_name_bytes_help(
|
let roc_main_bytes = func_name_bytes_help(
|
||||||
entry_point.symbol,
|
entry_point.symbol,
|
||||||
entry_point.layout.arguments.iter().copied(),
|
entry_point.layout.arguments.iter().copied(),
|
||||||
entry_point.layout.result,
|
&entry_point.layout.result,
|
||||||
);
|
);
|
||||||
let roc_main = FuncName(&roc_main_bytes);
|
let roc_main = FuncName(&roc_main_bytes);
|
||||||
|
|
||||||
|
@ -660,7 +660,7 @@ fn call_spec(
|
||||||
|
|
||||||
let arg_value_id = build_tuple_value(builder, env, block, call.arguments)?;
|
let arg_value_id = build_tuple_value(builder, env, block, call.arguments)?;
|
||||||
let it = arg_layouts.iter().copied();
|
let it = arg_layouts.iter().copied();
|
||||||
let bytes = func_name_bytes_help(*symbol, it, *ret_layout);
|
let bytes = func_name_bytes_help(*symbol, it, ret_layout);
|
||||||
let name = FuncName(&bytes);
|
let name = FuncName(&bytes);
|
||||||
let module = MOD_APP;
|
let module = MOD_APP;
|
||||||
builder.add_call(block, spec_var, module, name, arg_value_id)
|
builder.add_call(block, spec_var, module, name, arg_value_id)
|
||||||
|
@ -708,7 +708,7 @@ fn call_spec(
|
||||||
let update_mode_var = UpdateModeVar(&mode);
|
let update_mode_var = UpdateModeVar(&mode);
|
||||||
|
|
||||||
let it = arg_layouts.iter().copied();
|
let it = arg_layouts.iter().copied();
|
||||||
let bytes = func_name_bytes_help(*function_name, it, *ret_layout);
|
let bytes = func_name_bytes_help(*function_name, it, ret_layout);
|
||||||
let name = FuncName(&bytes);
|
let name = FuncName(&bytes);
|
||||||
let module = MOD_APP;
|
let module = MOD_APP;
|
||||||
|
|
||||||
|
|
|
@ -560,7 +560,7 @@ impl<'a> BorrowInfState<'a> {
|
||||||
arg_layouts,
|
arg_layouts,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
let top_level = ProcLayout::new(self.arena, arg_layouts, *ret_layout);
|
let top_level = ProcLayout::new(self.arena, arg_layouts, **ret_layout);
|
||||||
|
|
||||||
// get the borrow signature of the applied function
|
// get the borrow signature of the applied function
|
||||||
let ps = param_map
|
let ps = param_map
|
||||||
|
@ -795,7 +795,7 @@ impl<'a> BorrowInfState<'a> {
|
||||||
Stmt::Ret(z),
|
Stmt::Ret(z),
|
||||||
) = (v, b)
|
) = (v, b)
|
||||||
{
|
{
|
||||||
let top_level = ProcLayout::new(self.arena, arg_layouts, *ret_layout);
|
let top_level = ProcLayout::new(self.arena, arg_layouts, **ret_layout);
|
||||||
|
|
||||||
if self.current_proc == *g && x == *z {
|
if self.current_proc == *g && x == *z {
|
||||||
// anonymous functions (for which the ps may not be known)
|
// anonymous functions (for which the ps may not be known)
|
||||||
|
|
|
@ -667,7 +667,7 @@ impl<'a> Context<'a> {
|
||||||
arg_layouts,
|
arg_layouts,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
let top_level = ProcLayout::new(self.arena, arg_layouts, *ret_layout);
|
let top_level = ProcLayout::new(self.arena, arg_layouts, **ret_layout);
|
||||||
|
|
||||||
// get the borrow signature
|
// get the borrow signature
|
||||||
let ps = self
|
let ps = self
|
||||||
|
|
|
@ -28,11 +28,11 @@ pub const PRETTY_PRINT_IR_SYMBOLS: bool = false;
|
||||||
// please change it to the lower number.
|
// please change it to the lower number.
|
||||||
// if it went up, maybe check that the change is really required
|
// if it went up, maybe check that the change is really required
|
||||||
static_assertions::assert_eq_size!([u8; 3 * 8], Literal);
|
static_assertions::assert_eq_size!([u8; 3 * 8], Literal);
|
||||||
static_assertions::assert_eq_size!([u8; 13 * 8], Expr);
|
static_assertions::assert_eq_size!([u8; 11 * 8], Expr);
|
||||||
static_assertions::assert_eq_size!([u8; 22 * 8], Stmt);
|
static_assertions::assert_eq_size!([u8; 22 * 8], Stmt);
|
||||||
static_assertions::assert_eq_size!([u8; 7 * 8], ProcLayout);
|
static_assertions::assert_eq_size!([u8; 7 * 8], ProcLayout);
|
||||||
static_assertions::assert_eq_size!([u8; 12 * 8], Call);
|
static_assertions::assert_eq_size!([u8; 8 * 8], Call);
|
||||||
static_assertions::assert_eq_size!([u8; 10 * 8], CallType);
|
static_assertions::assert_eq_size!([u8; 6 * 8], CallType);
|
||||||
|
|
||||||
macro_rules! return_on_layout_error {
|
macro_rules! return_on_layout_error {
|
||||||
($env:expr, $layout_result:expr) => {
|
($env:expr, $layout_result:expr) => {
|
||||||
|
@ -1128,7 +1128,7 @@ impl UpdateModeId {
|
||||||
pub enum CallType<'a> {
|
pub enum CallType<'a> {
|
||||||
ByName {
|
ByName {
|
||||||
name: Symbol,
|
name: Symbol,
|
||||||
ret_layout: Layout<'a>,
|
ret_layout: &'a Layout<'a>,
|
||||||
arg_layouts: &'a [Layout<'a>],
|
arg_layouts: &'a [Layout<'a>],
|
||||||
specialization_id: CallSpecId,
|
specialization_id: CallSpecId,
|
||||||
},
|
},
|
||||||
|
@ -2027,7 +2027,7 @@ fn specialize_external<'a>(
|
||||||
Symbol::ARG_CLOSURE,
|
Symbol::ARG_CLOSURE,
|
||||||
argument_symbols.into_bump_slice(),
|
argument_symbols.into_bump_slice(),
|
||||||
argument_layouts,
|
argument_layouts,
|
||||||
*return_layout,
|
return_layout,
|
||||||
assigned,
|
assigned,
|
||||||
hole,
|
hole,
|
||||||
);
|
);
|
||||||
|
@ -3871,7 +3871,7 @@ pub fn with_hole<'a>(
|
||||||
closure_data_symbol,
|
closure_data_symbol,
|
||||||
arg_symbols,
|
arg_symbols,
|
||||||
arg_layouts,
|
arg_layouts,
|
||||||
*ret_layout,
|
ret_layout,
|
||||||
assigned,
|
assigned,
|
||||||
hole,
|
hole,
|
||||||
);
|
);
|
||||||
|
@ -3898,7 +3898,7 @@ pub fn with_hole<'a>(
|
||||||
closure_data_symbol,
|
closure_data_symbol,
|
||||||
arg_symbols,
|
arg_symbols,
|
||||||
arg_layouts,
|
arg_layouts,
|
||||||
*ret_layout,
|
ret_layout,
|
||||||
assigned,
|
assigned,
|
||||||
hole,
|
hole,
|
||||||
);
|
);
|
||||||
|
@ -6107,7 +6107,7 @@ fn force_thunk<'a>(
|
||||||
let call = self::Call {
|
let call = self::Call {
|
||||||
call_type: CallType::ByName {
|
call_type: CallType::ByName {
|
||||||
name: thunk_name,
|
name: thunk_name,
|
||||||
ret_layout: layout,
|
ret_layout: env.arena.alloc(layout),
|
||||||
arg_layouts: &[],
|
arg_layouts: &[],
|
||||||
specialization_id: env.next_call_specialization_id(),
|
specialization_id: env.next_call_specialization_id(),
|
||||||
},
|
},
|
||||||
|
@ -6472,7 +6472,7 @@ fn call_by_name<'a>(
|
||||||
closure_data_symbol,
|
closure_data_symbol,
|
||||||
arg_symbols,
|
arg_symbols,
|
||||||
arg_layouts,
|
arg_layouts,
|
||||||
*ret_layout,
|
ret_layout,
|
||||||
assigned,
|
assigned,
|
||||||
hole,
|
hole,
|
||||||
);
|
);
|
||||||
|
@ -6596,7 +6596,7 @@ fn call_by_name_help<'a>(
|
||||||
let call = self::Call {
|
let call = self::Call {
|
||||||
call_type: CallType::ByName {
|
call_type: CallType::ByName {
|
||||||
name: proc_name,
|
name: proc_name,
|
||||||
ret_layout: *ret_layout,
|
ret_layout: ret_layout,
|
||||||
arg_layouts: argument_layouts,
|
arg_layouts: argument_layouts,
|
||||||
specialization_id: env.next_call_specialization_id(),
|
specialization_id: env.next_call_specialization_id(),
|
||||||
},
|
},
|
||||||
|
@ -6637,7 +6637,7 @@ fn call_by_name_help<'a>(
|
||||||
let call = self::Call {
|
let call = self::Call {
|
||||||
call_type: CallType::ByName {
|
call_type: CallType::ByName {
|
||||||
name: proc_name,
|
name: proc_name,
|
||||||
ret_layout: *ret_layout,
|
ret_layout: ret_layout,
|
||||||
arg_layouts: argument_layouts,
|
arg_layouts: argument_layouts,
|
||||||
specialization_id: env.next_call_specialization_id(),
|
specialization_id: env.next_call_specialization_id(),
|
||||||
},
|
},
|
||||||
|
@ -6691,7 +6691,7 @@ fn call_by_name_help<'a>(
|
||||||
let call = self::Call {
|
let call = self::Call {
|
||||||
call_type: CallType::ByName {
|
call_type: CallType::ByName {
|
||||||
name: proc_name,
|
name: proc_name,
|
||||||
ret_layout: *ret_layout,
|
ret_layout: ret_layout,
|
||||||
arg_layouts: argument_layouts,
|
arg_layouts: argument_layouts,
|
||||||
specialization_id: env.next_call_specialization_id(),
|
specialization_id: env.next_call_specialization_id(),
|
||||||
},
|
},
|
||||||
|
@ -6939,7 +6939,7 @@ fn call_specialized_proc<'a>(
|
||||||
let call = self::Call {
|
let call = self::Call {
|
||||||
call_type: CallType::ByName {
|
call_type: CallType::ByName {
|
||||||
name: proc_name,
|
name: proc_name,
|
||||||
ret_layout: function_layout.result,
|
ret_layout: env.arena.alloc(function_layout.result),
|
||||||
arg_layouts: function_layout.arguments,
|
arg_layouts: function_layout.arguments,
|
||||||
specialization_id: env.next_call_specialization_id(),
|
specialization_id: env.next_call_specialization_id(),
|
||||||
},
|
},
|
||||||
|
@ -6982,7 +6982,7 @@ fn call_specialized_proc<'a>(
|
||||||
closure_data_symbol,
|
closure_data_symbol,
|
||||||
field_symbols,
|
field_symbols,
|
||||||
argument_layouts.into_bump_slice(),
|
argument_layouts.into_bump_slice(),
|
||||||
function_layout.result,
|
env.arena.alloc(function_layout.result),
|
||||||
assigned,
|
assigned,
|
||||||
hole,
|
hole,
|
||||||
);
|
);
|
||||||
|
@ -7012,7 +7012,7 @@ fn call_specialized_proc<'a>(
|
||||||
let call = self::Call {
|
let call = self::Call {
|
||||||
call_type: CallType::ByName {
|
call_type: CallType::ByName {
|
||||||
name: proc_name,
|
name: proc_name,
|
||||||
ret_layout: function_layout.result,
|
ret_layout: env.arena.alloc(function_layout.result),
|
||||||
arg_layouts: function_layout.arguments,
|
arg_layouts: function_layout.arguments,
|
||||||
specialization_id: env.next_call_specialization_id(),
|
specialization_id: env.next_call_specialization_id(),
|
||||||
},
|
},
|
||||||
|
@ -8096,7 +8096,7 @@ fn match_on_lambda_set<'a>(
|
||||||
closure_data_symbol: Symbol,
|
closure_data_symbol: Symbol,
|
||||||
argument_symbols: &'a [Symbol],
|
argument_symbols: &'a [Symbol],
|
||||||
argument_layouts: &'a [Layout<'a>],
|
argument_layouts: &'a [Layout<'a>],
|
||||||
return_layout: Layout<'a>,
|
return_layout: &'a Layout<'a>,
|
||||||
assigned: Symbol,
|
assigned: Symbol,
|
||||||
hole: &'a Stmt<'a>,
|
hole: &'a Stmt<'a>,
|
||||||
) -> Stmt<'a> {
|
) -> Stmt<'a> {
|
||||||
|
@ -8193,7 +8193,7 @@ fn union_lambda_set_to_switch<'a>(
|
||||||
closure_data_symbol: Symbol,
|
closure_data_symbol: Symbol,
|
||||||
argument_symbols: &'a [Symbol],
|
argument_symbols: &'a [Symbol],
|
||||||
argument_layouts: &'a [Layout<'a>],
|
argument_layouts: &'a [Layout<'a>],
|
||||||
return_layout: Layout<'a>,
|
return_layout: &'a Layout<'a>,
|
||||||
assigned: Symbol,
|
assigned: Symbol,
|
||||||
hole: &'a Stmt<'a>,
|
hole: &'a Stmt<'a>,
|
||||||
) -> Stmt<'a> {
|
) -> Stmt<'a> {
|
||||||
|
@ -8237,12 +8237,12 @@ fn union_lambda_set_to_switch<'a>(
|
||||||
cond_layout: closure_tag_id_layout,
|
cond_layout: closure_tag_id_layout,
|
||||||
branches: branches.into_bump_slice(),
|
branches: branches.into_bump_slice(),
|
||||||
default_branch,
|
default_branch,
|
||||||
ret_layout: return_layout,
|
ret_layout: *return_layout,
|
||||||
};
|
};
|
||||||
|
|
||||||
let param = Param {
|
let param = Param {
|
||||||
symbol: assigned,
|
symbol: assigned,
|
||||||
layout: return_layout,
|
layout: *return_layout,
|
||||||
borrow: false,
|
borrow: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8264,7 +8264,7 @@ fn union_lambda_set_branch<'a>(
|
||||||
closure_data_layout: Layout<'a>,
|
closure_data_layout: Layout<'a>,
|
||||||
argument_symbols_slice: &'a [Symbol],
|
argument_symbols_slice: &'a [Symbol],
|
||||||
argument_layouts_slice: &'a [Layout<'a>],
|
argument_layouts_slice: &'a [Layout<'a>],
|
||||||
return_layout: Layout<'a>,
|
return_layout: &'a Layout<'a>,
|
||||||
) -> Stmt<'a> {
|
) -> Stmt<'a> {
|
||||||
let result_symbol = env.unique_symbol();
|
let result_symbol = env.unique_symbol();
|
||||||
|
|
||||||
|
@ -8293,7 +8293,7 @@ fn union_lambda_set_branch_help<'a>(
|
||||||
closure_data_layout: Layout<'a>,
|
closure_data_layout: Layout<'a>,
|
||||||
argument_symbols_slice: &'a [Symbol],
|
argument_symbols_slice: &'a [Symbol],
|
||||||
argument_layouts_slice: &'a [Layout<'a>],
|
argument_layouts_slice: &'a [Layout<'a>],
|
||||||
return_layout: Layout<'a>,
|
return_layout: &'a Layout<'a>,
|
||||||
assigned: Symbol,
|
assigned: Symbol,
|
||||||
hole: &'a Stmt<'a>,
|
hole: &'a Stmt<'a>,
|
||||||
) -> Stmt<'a> {
|
) -> Stmt<'a> {
|
||||||
|
@ -8339,7 +8339,7 @@ fn union_lambda_set_branch_help<'a>(
|
||||||
arguments: argument_symbols,
|
arguments: argument_symbols,
|
||||||
};
|
};
|
||||||
|
|
||||||
build_call(env, call, assigned, return_layout, hole)
|
build_call(env, call, assigned, *return_layout, hole)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
@ -8351,7 +8351,7 @@ fn enum_lambda_set_to_switch<'a>(
|
||||||
closure_data_symbol: Symbol,
|
closure_data_symbol: Symbol,
|
||||||
argument_symbols: &'a [Symbol],
|
argument_symbols: &'a [Symbol],
|
||||||
argument_layouts: &'a [Layout<'a>],
|
argument_layouts: &'a [Layout<'a>],
|
||||||
return_layout: Layout<'a>,
|
return_layout: &'a Layout<'a>,
|
||||||
assigned: Symbol,
|
assigned: Symbol,
|
||||||
hole: &'a Stmt<'a>,
|
hole: &'a Stmt<'a>,
|
||||||
) -> Stmt<'a> {
|
) -> Stmt<'a> {
|
||||||
|
@ -8388,12 +8388,12 @@ fn enum_lambda_set_to_switch<'a>(
|
||||||
cond_layout: closure_tag_id_layout,
|
cond_layout: closure_tag_id_layout,
|
||||||
branches: branches.into_bump_slice(),
|
branches: branches.into_bump_slice(),
|
||||||
default_branch,
|
default_branch,
|
||||||
ret_layout: return_layout,
|
ret_layout: *return_layout,
|
||||||
};
|
};
|
||||||
|
|
||||||
let param = Param {
|
let param = Param {
|
||||||
symbol: assigned,
|
symbol: assigned,
|
||||||
layout: return_layout,
|
layout: *return_layout,
|
||||||
borrow: false,
|
borrow: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8414,7 +8414,7 @@ fn enum_lambda_set_branch<'a>(
|
||||||
closure_data_layout: Layout<'a>,
|
closure_data_layout: Layout<'a>,
|
||||||
argument_symbols_slice: &'a [Symbol],
|
argument_symbols_slice: &'a [Symbol],
|
||||||
argument_layouts_slice: &'a [Layout<'a>],
|
argument_layouts_slice: &'a [Layout<'a>],
|
||||||
return_layout: Layout<'a>,
|
return_layout: &'a Layout<'a>,
|
||||||
) -> Stmt<'a> {
|
) -> Stmt<'a> {
|
||||||
let result_symbol = env.unique_symbol();
|
let result_symbol = env.unique_symbol();
|
||||||
|
|
||||||
|
@ -8455,7 +8455,7 @@ fn enum_lambda_set_branch<'a>(
|
||||||
},
|
},
|
||||||
arguments: argument_symbols,
|
arguments: argument_symbols,
|
||||||
};
|
};
|
||||||
build_call(env, call, assigned, return_layout, env.arena.alloc(hole))
|
build_call(env, call, assigned, *return_layout, env.arena.alloc(hole))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue