From c83bdec108bc00f6a266eba31eccb894fae76e97 Mon Sep 17 00:00:00 2001 From: Taylan Kammer Date: Mon, 27 Jul 2026 07:11:46 +0200 Subject: Cleanup, fixes, NaN-packing improvement. --- src/zisp/gc.zig | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/zisp/gc.zig') diff --git a/src/zisp/gc.zig b/src/zisp/gc.zig index b36628f..9cb66d1 100644 --- a/src/zisp/gc.zig +++ b/src/zisp/gc.zig @@ -13,35 +13,37 @@ const HeapType = value.HeapType; var main_alloc: Alloc = undefined; -var list_heap_start: usize = undefined; -var main_heap_start: usize = undefined; -var istr_heap_start: usize = undefined; +const u32max = std.math.maxInt(u32); + +var list_heap: *[u32max]Value = undefined; +var main_heap: *[u32max]u64 = undefined; +var istr_heap: *[u32max]u8 = undefined; var main_list_pool: ListPool = undefined; var main_istr_pool: IstrPool = undefined; pub fn listPtrFromIdx(idx: u32) [*]Value { - return @ptrFromInt(list_heap_start + idx * 8); + return &list_heap[idx]; } pub fn heapPtrFromIdx(comptime typ: HeapType, idx: u32) typ.PtrType() { - return @ptrFromInt(main_heap_start + idx * 8); + return @ptrCast(&main_heap[idx]); } pub fn istrPtrFromIdx(idx: u32) [*]const u8 { - return @ptrFromInt(istr_heap_start + idx); + return &istr_heap[idx]; } pub fn listIdxFromPtr(ptr: [*]Value) u32 { - return @intCast(@intFromPtr(ptr - list_heap_start) / 8); + return @intCast(ptr - list_heap); } pub fn heapIdxFromPtr(ptr: HeapPtr) u32 { - return @intCast(@intFromPtr(ptr - main_heap_start) / 8); + return @intCast(ptr - main_heap); } pub fn istrIdxFromPtr(ptr: [*]const u8) u32 { - return @intCast(@intFromPtr(ptr - istr_heap_start)); + return @intCast(ptr - istr_heap); } pub fn allocHeap(comptime typ: HeapType, len: usize) !typ.PtrType() { @@ -92,5 +94,5 @@ pub fn mainListPool() *ListPool { pub fn mainIstrPool() *IstrPool { init() catch @panic("OOM"); // TODO this is only here for the test suite - return &main_istr_set; + return &main_istr_pool; } -- cgit v1.2.3