mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Merge remote-tracking branch 'upstream/main' into rust-docs
This commit is contained in:
commit
2c2a70b8e7
132 changed files with 1819 additions and 1795 deletions
|
@ -411,16 +411,16 @@ fn build_rc_wrapper<'a, 'ctx, 'env>(
|
|||
match rc_operation {
|
||||
Mode::Inc => {
|
||||
let n = 1;
|
||||
increment_refcount_layout(env, function_value, layout_ids, n, value, layout);
|
||||
increment_refcount_layout(env, layout_ids, n, value, layout);
|
||||
}
|
||||
Mode::IncN => {
|
||||
let n = it.next().unwrap().into_int_value();
|
||||
n.set_name(Symbol::ARG_2.as_str(&env.interns));
|
||||
|
||||
increment_n_refcount_layout(env, function_value, layout_ids, n, value, layout);
|
||||
increment_n_refcount_layout(env, layout_ids, n, value, layout);
|
||||
}
|
||||
Mode::Dec => {
|
||||
decrement_refcount_layout(env, function_value, layout_ids, value, layout);
|
||||
decrement_refcount_layout(env, layout_ids, value, layout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ impl<'ctx> Iterator for FunctionIterator<'ctx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq)]
|
||||
#[derive(Default, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Scope<'a, 'ctx> {
|
||||
symbols: ImMap<Symbol, (Layout<'a>, BasicValueEnum<'ctx>)>,
|
||||
pub top_level_thunks: ImMap<Symbol, (ProcLayout<'a>, FunctionValue<'ctx>)>,
|
||||
|
@ -973,7 +973,7 @@ pub fn build_exp_literal<'a, 'ctx, 'env>(
|
|||
_ => unreachable!("incorrect small_str_bytes"),
|
||||
}
|
||||
} else {
|
||||
let ptr = define_global_str_literal_ptr(env, *str_literal);
|
||||
let ptr = define_global_str_literal_ptr(env, str_literal);
|
||||
let number_of_elements = env.ptr_int().const_int(str_literal.len() as u64, false);
|
||||
|
||||
let alloca =
|
||||
|
@ -2723,14 +2723,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
|
|||
let layout = *layout;
|
||||
|
||||
if layout.contains_refcounted(env.layout_interner) {
|
||||
increment_refcount_layout(
|
||||
env,
|
||||
parent,
|
||||
layout_ids,
|
||||
*inc_amount,
|
||||
value,
|
||||
&layout,
|
||||
);
|
||||
increment_refcount_layout(env, layout_ids, *inc_amount, value, &layout);
|
||||
}
|
||||
|
||||
build_exp_stmt(env, layout_ids, func_spec_solutions, scope, parent, cont)
|
||||
|
@ -2739,7 +2732,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
|
|||
let (value, layout) = load_symbol_and_layout(scope, symbol);
|
||||
|
||||
if layout.contains_refcounted(env.layout_interner) {
|
||||
decrement_refcount_layout(env, parent, layout_ids, value, layout);
|
||||
decrement_refcount_layout(env, layout_ids, value, layout);
|
||||
}
|
||||
|
||||
build_exp_stmt(env, layout_ids, func_spec_solutions, scope, parent, cont)
|
||||
|
@ -3847,12 +3840,9 @@ fn expose_function_to_host_help_c_abi_v2<'a, 'ctx, 'env>(
|
|||
arg_type.into_pointer_type().get_element_type(),
|
||||
);
|
||||
// C return pointer goes at the beginning of params, and we must skip it if it exists.
|
||||
let param_index = (i
|
||||
+ (if matches!(cc_return, CCReturn::ByPointer) {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
})) as u32;
|
||||
let returns_pointer = matches!(cc_return, CCReturn::ByPointer);
|
||||
let param_index = i as u32 + returns_pointer as u32;
|
||||
|
||||
c_function.add_attribute(AttributeLoc::Param(param_index), byval);
|
||||
c_function.add_attribute(AttributeLoc::Param(param_index), nonnull);
|
||||
}
|
||||
|
@ -4554,7 +4544,7 @@ fn build_procedures_help<'a, 'ctx, 'env>(
|
|||
fn_val.print_to_stderr();
|
||||
|
||||
if let Some(app_ll_file) = debug_output_file {
|
||||
env.module.print_to_file(&app_ll_file).unwrap();
|
||||
env.module.print_to_file(app_ll_file).unwrap();
|
||||
|
||||
panic!(
|
||||
r"😱 LLVM errors when defining function {:?}; I wrote the full LLVM IR to {:?}",
|
||||
|
@ -6209,14 +6199,7 @@ fn run_low_level<'a, 'ctx, 'env>(
|
|||
|
||||
let element_layout = list_element_layout!(list_layout);
|
||||
|
||||
list_get_unsafe(
|
||||
env,
|
||||
layout_ids,
|
||||
parent,
|
||||
element_layout,
|
||||
elem_index,
|
||||
wrapper_struct,
|
||||
)
|
||||
list_get_unsafe(env, layout_ids, element_layout, elem_index, wrapper_struct)
|
||||
}
|
||||
ListReplaceUnsafe => {
|
||||
let list = load_symbol(scope, &args[0]);
|
||||
|
|
|
@ -121,7 +121,6 @@ pub(crate) fn list_with_capacity<'a, 'ctx, 'env>(
|
|||
pub(crate) fn list_get_unsafe<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
parent: FunctionValue<'ctx>,
|
||||
element_layout: &Layout<'a>,
|
||||
elem_index: IntValue<'ctx>,
|
||||
wrapper_struct: StructValue<'ctx>,
|
||||
|
@ -140,7 +139,7 @@ pub(crate) fn list_get_unsafe<'a, 'ctx, 'env>(
|
|||
|
||||
let result = load_roc_value(env, *element_layout, elem_ptr, "list_get_load_element");
|
||||
|
||||
increment_refcount_layout(env, parent, layout_ids, 1, result, element_layout);
|
||||
increment_refcount_layout(env, layout_ids, 1, result, element_layout);
|
||||
|
||||
result
|
||||
}
|
||||
|
|
|
@ -327,8 +327,6 @@ fn modify_refcount_struct_help<'a, 'ctx, 'env>(
|
|||
|
||||
arg_val.set_name(arg_symbol.as_str(&env.interns));
|
||||
|
||||
let parent = fn_val;
|
||||
|
||||
let wrapper_struct = arg_val.into_struct_value();
|
||||
|
||||
for (i, field_layout) in layouts.iter().enumerate() {
|
||||
|
@ -347,7 +345,6 @@ fn modify_refcount_struct_help<'a, 'ctx, 'env>(
|
|||
|
||||
modify_refcount_layout_help(
|
||||
env,
|
||||
parent,
|
||||
layout_ids,
|
||||
mode.to_call_mode(fn_val),
|
||||
when_recursive,
|
||||
|
@ -362,42 +359,32 @@ fn modify_refcount_struct_help<'a, 'ctx, 'env>(
|
|||
|
||||
pub fn increment_refcount_layout<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
parent: FunctionValue<'ctx>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
inc_amount: u64,
|
||||
value: BasicValueEnum<'ctx>,
|
||||
layout: &Layout<'a>,
|
||||
) {
|
||||
let amount = env.ptr_int().const_int(inc_amount, false);
|
||||
increment_n_refcount_layout(env, parent, layout_ids, amount, value, layout);
|
||||
increment_n_refcount_layout(env, layout_ids, amount, value, layout);
|
||||
}
|
||||
|
||||
pub fn increment_n_refcount_layout<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
parent: FunctionValue<'ctx>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
amount: IntValue<'ctx>,
|
||||
value: BasicValueEnum<'ctx>,
|
||||
layout: &Layout<'a>,
|
||||
) {
|
||||
modify_refcount_layout(
|
||||
env,
|
||||
parent,
|
||||
layout_ids,
|
||||
CallMode::Inc(amount),
|
||||
value,
|
||||
layout,
|
||||
);
|
||||
modify_refcount_layout(env, layout_ids, CallMode::Inc(amount), value, layout);
|
||||
}
|
||||
|
||||
pub fn decrement_refcount_layout<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
parent: FunctionValue<'ctx>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
value: BasicValueEnum<'ctx>,
|
||||
layout: &Layout<'a>,
|
||||
) {
|
||||
modify_refcount_layout(env, parent, layout_ids, CallMode::Dec, value, layout);
|
||||
modify_refcount_layout(env, layout_ids, CallMode::Dec, value, layout);
|
||||
}
|
||||
|
||||
fn modify_refcount_builtin<'a, 'ctx, 'env>(
|
||||
|
@ -435,7 +422,6 @@ fn modify_refcount_builtin<'a, 'ctx, 'env>(
|
|||
|
||||
fn modify_refcount_layout<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
parent: FunctionValue<'ctx>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
call_mode: CallMode<'ctx>,
|
||||
value: BasicValueEnum<'ctx>,
|
||||
|
@ -443,7 +429,6 @@ fn modify_refcount_layout<'a, 'ctx, 'env>(
|
|||
) {
|
||||
modify_refcount_layout_help(
|
||||
env,
|
||||
parent,
|
||||
layout_ids,
|
||||
call_mode,
|
||||
&WhenRecursive::Unreachable,
|
||||
|
@ -460,7 +445,6 @@ enum WhenRecursive<'a> {
|
|||
|
||||
fn modify_refcount_layout_help<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
parent: FunctionValue<'ctx>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
call_mode: CallMode<'ctx>,
|
||||
when_recursive: &WhenRecursive<'a>,
|
||||
|
@ -474,7 +458,6 @@ fn modify_refcount_layout_help<'a, 'ctx, 'env>(
|
|||
|
||||
let function = match modify_refcount_layout_build_function(
|
||||
env,
|
||||
parent,
|
||||
layout_ids,
|
||||
mode,
|
||||
when_recursive,
|
||||
|
@ -538,7 +521,6 @@ fn call_help<'a, 'ctx, 'env>(
|
|||
|
||||
fn modify_refcount_layout_build_function<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
parent: FunctionValue<'ctx>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
mode: Mode,
|
||||
when_recursive: &WhenRecursive<'a>,
|
||||
|
@ -603,7 +585,6 @@ fn modify_refcount_layout_build_function<'a, 'ctx, 'env>(
|
|||
|
||||
let function = modify_refcount_layout_build_function(
|
||||
env,
|
||||
parent,
|
||||
layout_ids,
|
||||
mode,
|
||||
when_recursive,
|
||||
|
@ -615,7 +596,6 @@ fn modify_refcount_layout_build_function<'a, 'ctx, 'env>(
|
|||
},
|
||||
LambdaSet(lambda_set) => modify_refcount_layout_build_function(
|
||||
env,
|
||||
parent,
|
||||
layout_ids,
|
||||
mode,
|
||||
when_recursive,
|
||||
|
@ -731,7 +711,6 @@ fn modify_refcount_list_help<'a, 'ctx, 'env>(
|
|||
let loop_fn = |_index, element| {
|
||||
modify_refcount_layout_help(
|
||||
env,
|
||||
parent,
|
||||
layout_ids,
|
||||
mode.to_call_mode(fn_val),
|
||||
when_recursive,
|
||||
|
@ -1302,7 +1281,6 @@ fn build_rec_union_recursive_decrement<'a, 'ctx, 'env>(
|
|||
for (field, field_layout) in deferred_nonrec {
|
||||
modify_refcount_layout_help(
|
||||
env,
|
||||
parent,
|
||||
layout_ids,
|
||||
mode.to_call_mode(decrement_fn),
|
||||
when_recursive,
|
||||
|
@ -1366,7 +1344,7 @@ fn union_layout_tags<'a>(
|
|||
match union_layout {
|
||||
NullableWrapped {
|
||||
other_tags: tags, ..
|
||||
} => *tags,
|
||||
} => tags,
|
||||
NullableUnwrapped { other_fields, .. } => arena.alloc([*other_fields]),
|
||||
NonNullableUnwrapped(fields) => arena.alloc([*fields]),
|
||||
Recursive(tags) => tags,
|
||||
|
@ -1687,7 +1665,6 @@ fn modify_refcount_union_help<'a, 'ctx, 'env>(
|
|||
|
||||
modify_refcount_layout_help(
|
||||
env,
|
||||
parent,
|
||||
layout_ids,
|
||||
mode.to_call_mode(fn_val),
|
||||
when_recursive,
|
||||
|
@ -1709,7 +1686,6 @@ fn modify_refcount_union_help<'a, 'ctx, 'env>(
|
|||
|
||||
modify_refcount_layout_help(
|
||||
env,
|
||||
parent,
|
||||
layout_ids,
|
||||
mode.to_call_mode(fn_val),
|
||||
when_recursive,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue