authorgravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2024-10-12 12:55:35+02:00
committergravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2024-10-12 12:55:35+02:00
logb1eaed6c8d439f5e5cbd69af5186af68f1e65e34
tree4e365a647602c8fca343fa56ecee3f4beb96a184
parent278eb06b988db69062d864632a24b444b2b45bc6

Remove packed_int_array usage from WasmPageAllocator and BigInt


2 files changed, 10 insertions(+), 13 deletions(-)

lib/std/heap/WasmPageAllocator.zig+4-6
......@@ -28,8 +28,6 @@ const PageStatus = enum(u1) {
2828const FreeBlock = struct {
2929 data: []u128,
3030
31 const Io = std.packed_int_array.PackedIntIo(u1, .little);
32
3331 fn totalPages(self: FreeBlock) usize {
3432 return self.data.len * 128;
3533 }
......@@ -39,15 +37,15 @@ const FreeBlock = struct {
3937 }
4038
4139 fn getBit(self: FreeBlock, idx: usize) PageStatus {
42 const bit_offset = 0;
43 return @as(PageStatus, @enumFromInt(Io.get(mem.sliceAsBytes(self.data), idx, bit_offset)));
40 const bit = mem.readPackedInt(u1, mem.sliceAsBytes(self.data), 8 * idx, .little);
41 return @as(PageStatus, @enumFromInt(bit));
4442 }
4543
4644 fn setBits(self: FreeBlock, start_idx: usize, len: usize, val: PageStatus) void {
47 const bit_offset = 0;
4845 var i: usize = 0;
46 const bytes = mem.sliceAsBytes(self.data);
4947 while (i < len) : (i += 1) {
50 Io.set(mem.sliceAsBytes(self.data), start_idx + i, bit_offset, @intFromEnum(val));
48 mem.writePackedInt(u1, bytes, 8 * (start_idx + i), @intFromEnum(val), .little);
5149 }
5250 }
5351
lib/std/math/big/int.zig+6-7
......@@ -795,7 +795,6 @@ pub const Mutable = struct {
795795 const endian_mask: usize = (@sizeOf(Limb) - 1) << 3;
796796
797797 const bytes = std.mem.sliceAsBytes(r.limbs);
798 var bits = std.packed_int_array.PackedIntSliceEndian(u1, .little).init(bytes, limbs_required * @bitSizeOf(Limb));
799798
800799 var k: usize = 0;
801800 while (k < ((bit_count + 1) / 2)) : (k += 1) {
......@@ -809,17 +808,17 @@ pub const Mutable = struct {
809808 rev_i ^= endian_mask;
810809 }
811810
812 const bit_i = bits.get(i);
813 const bit_rev_i = bits.get(rev_i);
814 bits.set(i, bit_rev_i);
815 bits.set(rev_i, bit_i);
811 const bit_i = std.mem.readPackedInt(u1, bytes, i, .little);
812 const bit_rev_i = std.mem.readPackedInt(u1, bytes, rev_i, .little);
813 std.mem.writePackedInt(u1, bytes, i, bit_rev_i, .little);
814 std.mem.writePackedInt(u1, bytes, rev_i, bit_i, .little);
816815 }
817816
818817 // Calculate signed-magnitude representation for output
819818 if (signedness == .signed) {
820819 const last_bit = switch (native_endian) {
821 .little => bits.get(bit_count - 1),
822 .big => bits.get((bit_count - 1) ^ endian_mask),
820 .little => std.mem.readPackedInt(u1, bytes, bit_count - 1, .little),
821 .big => std.mem.readPackedInt(u1, bytes, (bit_count - 1) ^ endian_mask, .little),
823822 };
824823 if (last_bit == 1) {
825824 r.bitNotWrap(r.toConst(), .unsigned, bit_count); // Bitwise NOT.