diff options
| author | Taylan Kammer <taylan.kammer@gmail.com> | 2026-07-27 07:11:46 +0200 |
|---|---|---|
| committer | Taylan Kammer <taylan.kammer@gmail.com> | 2026-07-27 07:11:46 +0200 |
| commit | c83bdec108bc00f6a266eba31eccb894fae76e97 (patch) | |
| tree | 669aebf063283e9c20f05951223be3e7e1733beb /src/zisp/gc.zig | |
| parent | a8d40828eb6c7ace41e7102ac18dc7b406b094eb (diff) | |
Cleanup, fixes, NaN-packing improvement.
Diffstat (limited to 'src/zisp/gc.zig')
| -rw-r--r-- | src/zisp/gc.zig | 22 |
1 files changed, 12 insertions, 10 deletions
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; } |
