const pageCachePages … type pageCache … // empty reports whether the page cache has no free pages. func (c *pageCache) empty() bool { … } // alloc allocates npages from the page cache and is the main entry // point for allocation. // // Returns a base address and the amount of scavenged memory in the // allocated region in bytes. // // Returns a base address of zero on failure, in which case the // amount of scavenged memory should be ignored. func (c *pageCache) alloc(npages uintptr) (uintptr, uintptr) { … } // allocN is a helper which attempts to allocate npages worth of pages // from the cache. It represents the general case for allocating from // the page cache. // // Returns a base address and the amount of scavenged memory in the // allocated region in bytes. func (c *pageCache) allocN(npages uintptr) (uintptr, uintptr) { … } // flush empties out unallocated free pages in the given cache // into s. Then, it clears the cache, such that empty returns // true. // // p.mheapLock must be held. // // Must run on the system stack because p.mheapLock must be held. // //go:systemstack func (c *pageCache) flush(p *pageAlloc) { … } // allocToCache acquires a pageCachePages-aligned chunk of free pages which // may not be contiguous, and returns a pageCache structure which owns the // chunk. // // p.mheapLock must be held. // // Must run on the system stack because p.mheapLock must be held. // //go:systemstack func (p *pageAlloc) allocToCache() pageCache { … }