asmjit::JitAllocator Class Reference [¶]
A simple implementation of memory manager that uses asmjit::VirtMem
functions to manage virtual memory for JIT compiled code.
Implementation notes:
- Granularity of allocated blocks is different than granularity for a typical C malloc. In addition, the allocator can use several memory pools having a different granularity to minimize the maintenance overhead. Multiple pools feature requires
kFlagUseMultiplePools
flag to be set. - The allocator doesn't store any information in executable memory, instead, the implementation uses two bit-vectors to manage allocated memory of each allocator-block. The first bit-vector called 'used' is used to track used memory (where each bit represents memory size defined by granularity) and the second bit vector called 'stop' is used as a sentinel to mark where the allocated area ends.
- Internally, the allocator also uses RB tree to keep track of all blocks across all pools. Each inserted block is added to the tree so it can be matched fast during
release()
andshrink()
.