//===-- release.h -----------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef SCUDO_RELEASE_H_ #define SCUDO_RELEASE_H_ #include "common.h" #include "list.h" #include "mem_map.h" #include "mutex.h" #include "thread_annotations.h" namespace scudo { template <typename MemMapT> class RegionReleaseRecorder { … }; class ReleaseRecorder { … }; class FragmentationRecorder { … }; template <uptr GroupSize, uptr NumGroups> class MemoryGroupFragmentationRecorder { … }; // A buffer pool which holds a fixed number of static buffers of `uptr` elements // for fast buffer allocation. If the request size is greater than // `StaticBufferNumElements` or if all the static buffers are in use, it'll // delegate the allocation to map(). template <uptr StaticBufferCount, uptr StaticBufferNumElements> class BufferPool { … }; // A Region page map is used to record the usage of pages in the regions. It // implements a packed array of Counters. Each counter occupies 2^N bits, enough // to store counter's MaxValue. Ctor will try to use a static buffer first, and // if that fails (the buffer is too small or already locked), will allocate the // required Buffer via map(). The caller is expected to check whether the // initialization was successful by checking isAllocated() result. For // performance sake, none of the accessors check the validity of the arguments, // It is assumed that Index is always in [0, N) range and the value is not // incremented past MaxValue. class RegionPageMap { … }; template <class ReleaseRecorderT> class FreePagesRangeTracker { … }; struct PageReleaseContext { … }; // Try to release the page which doesn't have any in-used block, i.e., they are // all free blocks. The `PageMap` will record the number of free blocks in each // page. template <class ReleaseRecorderT, typename SkipRegionT> NOINLINE void releaseFreeMemoryToOS(PageReleaseContext &Context, ReleaseRecorderT &Recorder, SkipRegionT SkipRegion) { … } } // namespace scudo #endif // SCUDO_RELEASE_H_