diff --git a/compiler/builtins/bitcode/src/list.zig b/compiler/builtins/bitcode/src/list.zig index a45e6564dd..602b680d21 100644 --- a/compiler/builtins/bitcode/src/list.zig +++ b/compiler/builtins/bitcode/src/list.zig @@ -626,7 +626,6 @@ pub fn listWalkUntil( output: Opaque, ) callconv(.C) void { // [ Continue a, Stop a ] - const CONTINUE: usize = 0; if (accum_width == 0) { return; @@ -922,7 +921,7 @@ inline fn swapHelp(width: usize, temporary: [*]u8, ptr1: [*]u8, ptr2: [*]u8) voi } fn swap(width_initial: usize, p1: [*]u8, p2: [*]u8) void { - const threshold: comptime usize = 64; + const threshold: usize = 64; var width = width_initial; @@ -948,11 +947,6 @@ fn swap(width_initial: usize, p1: [*]u8, p2: [*]u8) void { } fn swapElements(source_ptr: [*]u8, element_width: usize, index_1: usize, index_2: usize) void { - const threshold: comptime usize = 64; - - var buffer_actual: [threshold]u8 = undefined; - var buffer: [*]u8 = buffer_actual[0..]; - var element_at_i = source_ptr + (index_1 * element_width); var element_at_j = source_ptr + (index_2 * element_width); @@ -1029,8 +1023,6 @@ pub fn listConcat(list_a: RocList, list_b: RocList, alignment: u32, element_widt pub fn listSetInPlace( bytes: ?[*]u8, - length: usize, - alignment: u32, index: usize, element: Opaque, element_width: usize, @@ -1043,7 +1035,7 @@ pub fn listSetInPlace( // so we don't do a bounds check here. Hence, the list is also non-empty, // because inserting into an empty list is always out of bounds - return listSetInPlaceHelp(bytes, length, alignment, index, element, element_width, dec); + return listSetInPlaceHelp(bytes, index, element, element_width, dec); } pub fn listSet( @@ -1064,7 +1056,7 @@ pub fn listSet( const ptr: [*]usize = @ptrCast([*]usize, @alignCast(8, bytes)); if ((ptr - 1)[0] == utils.REFCOUNT_ONE) { - return listSetInPlaceHelp(bytes, length, alignment, index, element, element_width, dec); + return listSetInPlaceHelp(bytes, index, element, element_width, dec); } else { return listSetImmutable(bytes, length, alignment, index, element, element_width, dec); } @@ -1072,8 +1064,6 @@ pub fn listSet( inline fn listSetInPlaceHelp( bytes: ?[*]u8, - length: usize, - alignment: u32, index: usize, element: Opaque, element_width: usize, diff --git a/compiler/gen_llvm/src/llvm/build_list.rs b/compiler/gen_llvm/src/llvm/build_list.rs index a6b6456557..7aa7e07ead 100644 --- a/compiler/gen_llvm/src/llvm/build_list.rs +++ b/compiler/gen_llvm/src/llvm/build_list.rs @@ -361,25 +361,33 @@ pub fn list_set<'a, 'ctx, 'env>( env.context.i8_type().ptr_type(AddressSpace::Generic), ); - let symbol = match update_mode { - UpdateMode::InPlace => bitcode::LIST_SET_IN_PLACE, - UpdateMode::Immutable => bitcode::LIST_SET, + let new_bytes = match update_mode { + UpdateMode::InPlace => call_bitcode_fn( + env, + &[ + bytes.into(), + index.into(), + pass_element_as_opaque(env, element), + layout_width(env, element_layout), + dec_element_fn.as_global_value().as_pointer_value().into(), + ], + bitcode::LIST_SET_IN_PLACE, + ), + UpdateMode::Immutable => call_bitcode_fn( + env, + &[ + bytes.into(), + length.into(), + env.alignment_intvalue(&element_layout), + index.into(), + pass_element_as_opaque(env, element), + layout_width(env, element_layout), + dec_element_fn.as_global_value().as_pointer_value().into(), + ], + bitcode::LIST_SET, + ), }; - let new_bytes = call_bitcode_fn( - env, - &[ - bytes.into(), - length.into(), - env.alignment_intvalue(&element_layout), - index.into(), - pass_element_as_opaque(env, element), - layout_width(env, element_layout), - dec_element_fn.as_global_value().as_pointer_value().into(), - ], - &symbol, - ); - store_list(env, new_bytes.into_pointer_value(), length) }