mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
make sure to check raw capacity when decrementing refcounts
This commit is contained in:
parent
5d87ba3441
commit
b94a046b0d
3 changed files with 15 additions and 14 deletions
|
@ -393,19 +393,18 @@ pub(crate) fn list_len<'ctx>(
|
|||
.into_int_value()
|
||||
}
|
||||
|
||||
/// List.capacity : List * -> Nat
|
||||
pub(crate) fn list_capacity<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
pub(crate) fn list_capacity_or_ref_ptr<'ctx>(
|
||||
builder: &Builder<'ctx>,
|
||||
wrapper_struct: StructValue<'ctx>,
|
||||
) -> IntValue<'ctx> {
|
||||
call_list_bitcode_fn(
|
||||
env,
|
||||
&[wrapper_struct],
|
||||
&[],
|
||||
BitcodeReturns::Basic,
|
||||
bitcode::LIST_CAPACITY,
|
||||
)
|
||||
.into_int_value()
|
||||
builder
|
||||
.build_extract_value(
|
||||
wrapper_struct,
|
||||
Builtin::WRAPPER_CAPACITY,
|
||||
"list_capacity_or_ref_ptr",
|
||||
)
|
||||
.unwrap()
|
||||
.into_int_value()
|
||||
}
|
||||
|
||||
// Gets a pointer to just after the refcount for a list or seamless slice.
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::llvm::build::{
|
|||
FAST_CALL_CONV,
|
||||
};
|
||||
use crate::llvm::build_list::{
|
||||
incrementing_elem_loop, list_capacity, list_refcount_ptr, load_list,
|
||||
incrementing_elem_loop, list_capacity_or_ref_ptr, list_refcount_ptr, load_list,
|
||||
};
|
||||
use crate::llvm::convert::{basic_type_from_layout, zig_str_type, RocUnion};
|
||||
use bumpalo::collections::Vec;
|
||||
|
@ -693,7 +693,8 @@ fn modify_refcount_list_help<'a, 'ctx, 'env>(
|
|||
let parent = fn_val;
|
||||
let original_wrapper = arg_val.into_struct_value();
|
||||
|
||||
let capacity = list_capacity(env, original_wrapper);
|
||||
// We use the raw capacity to ensure we always decrement the refcount of seamless slices.
|
||||
let capacity = list_capacity_or_ref_ptr(builder, original_wrapper);
|
||||
|
||||
let is_non_empty = builder.build_int_compare(
|
||||
IntPredicate::UGT,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue