Downstream: zig-utils/zig-js#62
Related: #3
Problem
The exact live-payload hash index is maintained for every cell so broad maybe-managed pointers can be rejected without dereferencing wild memory. For embedders whose GC backing allocator already owns fixed-size aligned slab ranges, that duplicates ownership metadata and makes hash insertion/probing the dominant cell-allocation cost. The hash-function-only experiment in #3 did not help.
Design
- add an optional binding hook that validates whether an allocation-start address lies on an issued slot boundary owned by the heap's backing slabs;
- let
headerForPayload ask the hook before dereferencing the candidate header, then require the normal header magic;
- skip per-cell hash insertion/removal only for allocations the hook positively identifies; retain the current exact index and authoritative all-list fallback for every other allocation/embedder;
- clear header magic before returning a swept slab slot so stale pointers cannot validate;
- preserve generic zig-gc behavior byte-for-byte when the hook is absent.
Acceptance criteria
Downstream: zig-utils/zig-js#62
Related: #3
Problem
The exact live-payload hash index is maintained for every cell so broad maybe-managed pointers can be rejected without dereferencing wild memory. For embedders whose GC backing allocator already owns fixed-size aligned slab ranges, that duplicates ownership metadata and makes hash insertion/probing the dominant cell-allocation cost. The hash-function-only experiment in #3 did not help.
Design
headerForPayloadask the hook before dereferencing the candidate header, then require the normal header magic;Acceptance criteria