mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-26 06:34:20 +08:00
InternTable keys can be arrays of numbers or of strings, compared by their elements: numbers by SameValueZero, strings by content, and holes equal to each other only. The runtime stores an array key as one byte string that encodes its elements; the Node.js implementation encodes it into a Map key the same way. Replaced table indexes are now freed. Every thread that uses a table records the epoch it read at the start of each lookup and insert, and an index retired in an earlier epoch than every recorded one is freed. Worker threads stop holding retirements back when they exit. Number indexes keep a tag byte per slot ahead of the key and value pairs, so a lookup of an absent key reads the dense tag bytes instead of pairs. getOrInsertComputed lowers an arrow callback with an expression body in place, with its parameter bound to the key, so interning through `(key) => new T(...)` creates no closure.