mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-25 06:24:27 +08:00
A collection pass copied every buffered candidate from the generation root buffers into its candidate list, so it held two buffers of every candidate, and each work vector kept its largest size for the rest of the program. A pass now takes the fullest root buffer as its candidate list and appends the others; that generation gets the previous candidate buffer, empty. The vectors a pass fills and leaves empty (pending, white, promote, restore and cross-generation lists) record how many entries the pass held at most. When a pass ends, any of them that holds more than 65536 entries is freed if the pass used less than a quarter of it, and so is the candidate list's buffer when this pass's candidates filled less than a quarter of it. Passes of a steady size keep reusing their buffers; a spike in one pass no longer keeps its buffers for the rest of the program. When an older generation's buffer is the fullest, candidates are visited, and a pass's garbage is freed, in a different order; the set of objects a pass frees does not change.