mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
An array's element ops are a registry id in `spare` instead of a pointer field: descriptors get their id on their first array (emitted descriptors are writable for it), and a program with more element types than the id holds keeps the rest in the array's out-of-line storage. The out-of-line storage (sparse indices, noncanonical numeric properties, match metadata) is no longer a header field. An array that has it keeps its pointer in the 8 bytes before its dense allocation and sets SCR_ARR_HAS_EXT; such an array always has a dense allocation of its own (inline slots move out, an empty array gets the prefix alone), and every allocation, reallocation and free of the dense storage accounts for the prefix. Loops over elements look the ops up once, and the state lookup below the dense capacity reads no out-of-line storage.