mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
List.releaseExcessCapacity
This commit is contained in:
parent
4e29652f0d
commit
a48618e34a
2 changed files with 51 additions and 16 deletions
|
@ -1330,8 +1330,6 @@ trait Backend<'a> {
|
||||||
layout_usize,
|
layout_usize,
|
||||||
];
|
];
|
||||||
|
|
||||||
dbg!(arg_layouts);
|
|
||||||
|
|
||||||
let intrinsic = bitcode::LIST_SUBLIST.to_string();
|
let intrinsic = bitcode::LIST_SUBLIST.to_string();
|
||||||
self.build_fn_call(sym, intrinsic, &args, &arg_layouts, &list_layout);
|
self.build_fn_call(sym, intrinsic, &args, &arg_layouts, &list_layout);
|
||||||
}
|
}
|
||||||
|
@ -1382,6 +1380,43 @@ trait Backend<'a> {
|
||||||
ret_layout,
|
ret_layout,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
LowLevel::ListReleaseExcessCapacity => {
|
||||||
|
let list = args[0];
|
||||||
|
|
||||||
|
let list_layout = arg_layouts[0];
|
||||||
|
let element_layout = match self.interner().get(list_layout) {
|
||||||
|
Layout::Builtin(Builtin::List(e)) => e,
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let (element_width_int, alignment_int) =
|
||||||
|
self.interner().stack_size_and_alignment(element_layout);
|
||||||
|
|
||||||
|
let alignment = self.debug_symbol("alignment");
|
||||||
|
self.load_literal_i32(&alignment, Ord::max(alignment_int, 8) as i32);
|
||||||
|
|
||||||
|
let element_width = self.debug_symbol("element_width");
|
||||||
|
self.load_literal_i64(&element_width, element_width_int as i64);
|
||||||
|
|
||||||
|
let update_mode = self.debug_symbol("update_mode");
|
||||||
|
self.load_literal_i8(&update_mode, UpdateMode::Immutable as i8);
|
||||||
|
|
||||||
|
let layout_usize = Layout::U64;
|
||||||
|
|
||||||
|
// list: RocList,
|
||||||
|
// alignment: u32,
|
||||||
|
// element_width: usize,
|
||||||
|
// update_mode: UpdateMode,
|
||||||
|
|
||||||
|
self.build_fn_call(
|
||||||
|
sym,
|
||||||
|
bitcode::LIST_RELEASE_EXCESS_CAPACITY.to_string(),
|
||||||
|
&[list, alignment, element_width, update_mode],
|
||||||
|
&[list_layout, Layout::U32, layout_usize, Layout::U8],
|
||||||
|
ret_layout,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
x => todo!("low level, {:?}", x),
|
x => todo!("low level, {:?}", x),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3428,7 +3428,7 @@ fn list_starts_with_nonempty() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn monomorphized_lists() {
|
fn monomorphized_lists() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
@ -3525,7 +3525,7 @@ fn reserve_unchanged() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn release_excess_capacity() {
|
fn release_excess_capacity() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
@ -3541,7 +3541,7 @@ fn release_excess_capacity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn release_excess_capacity_with_len() {
|
fn release_excess_capacity_with_len() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
@ -3557,7 +3557,7 @@ fn release_excess_capacity_with_len() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn release_excess_capacity_empty() {
|
fn release_excess_capacity_empty() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
@ -3572,7 +3572,7 @@ fn release_excess_capacity_empty() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn call_function_in_empty_list() {
|
fn call_function_in_empty_list() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
@ -3588,7 +3588,7 @@ fn call_function_in_empty_list() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn call_function_in_empty_list_unbound() {
|
fn call_function_in_empty_list_unbound() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
@ -3635,7 +3635,7 @@ fn issue_3571_lowlevel_call_function_with_bool_lambda_set() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn issue_3530_uninitialized_capacity_in_list_literal() {
|
fn issue_3530_uninitialized_capacity_in_list_literal() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
@ -3650,7 +3650,7 @@ fn issue_3530_uninitialized_capacity_in_list_literal() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn list_infer_usage() {
|
fn list_infer_usage() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
@ -3670,7 +3670,7 @@ fn list_infer_usage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn list_walk_backwards_implements_position() {
|
fn list_walk_backwards_implements_position() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
r#"
|
r#"
|
||||||
|
@ -3698,7 +3698,7 @@ fn list_walk_backwards_implements_position() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn list_walk_backwards_until_sum() {
|
fn list_walk_backwards_until_sum() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
r#"List.walkBackwardsUntil [1, 2] 0 \a,b -> Continue (a + b)"#,
|
r#"List.walkBackwardsUntil [1, 2] 0 \a,b -> Continue (a + b)"#,
|
||||||
|
@ -3708,7 +3708,7 @@ fn list_walk_backwards_until_sum() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn list_walk_backwards_until_even_prefix_sum() {
|
fn list_walk_backwards_until_even_prefix_sum() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
r#"
|
r#"
|
||||||
|
@ -3726,7 +3726,7 @@ fn list_walk_backwards_until_even_prefix_sum() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn list_walk_from_until_sum() {
|
fn list_walk_from_until_sum() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
r#"List.walkFromUntil [1, 2, 3, 4] 2 0 \a,b -> Continue (a + b)"#,
|
r#"List.walkFromUntil [1, 2, 3, 4] 2 0 \a,b -> Continue (a + b)"#,
|
||||||
|
@ -3736,7 +3736,7 @@ fn list_walk_from_until_sum() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn concat_unique_to_nonunique_overlapping_issue_4697() {
|
fn concat_unique_to_nonunique_overlapping_issue_4697() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
r#"
|
r#"
|
||||||
|
@ -3757,7 +3757,7 @@ fn concat_unique_to_nonunique_overlapping_issue_4697() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn list_walk_from_even_prefix_sum() {
|
fn list_walk_from_even_prefix_sum() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
r#"
|
r#"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue