Store capacity in unique list

This commit is contained in:
Chad Stearns 2020-09-13 14:56:01 -04:00
parent 4e7aecc434
commit 9351746952

View file

@ -1701,11 +1701,16 @@ pub fn allocate_list<'a, 'ctx, 'env>(
"make ptr",
);
// the refcount of a new list is initially 1
// we assume that the list is indeed used (dead variables are eliminated)
let ref_count_one = ctx
.i64_type()
.const_int(crate::llvm::refcounting::REFCOUNT_1 as _, false);
let ref_count_one = match inplace {
InPlace::InPlace => length,
InPlace::Clone => {
// the refcount of a new list is initially 1
// we assume that the list is indeed used (dead variables are eliminated)
ctx.i64_type()
.const_int(crate::llvm::refcounting::REFCOUNT_1 as _, false)
}
};
builder.build_store(refcount_ptr, ref_count_one);
list_element_ptr