LLVM 24.0.0git
llvm::orc::MapperJITLinkMemoryManager Class Reference

#include "llvm/ExecutionEngine/Orc/MapperJITLinkMemoryManager.h"

Inheritance diagram for llvm::orc::MapperJITLinkMemoryManager:
[legend]

Classes

class  InFlightAlloc

Public Types

using SlabGrowthPolicy
 Policy invoked before reserving an additional slab for a JITDylib (i.e.

Public Member Functions

 MapperJITLinkMemoryManager (size_t ReservationGranularity, std::unique_ptr< MemoryMapper > Mapper, bool ColocatePerJITDylib=false)
 If ColocatePerJITDylib is true each JITDylib draws from its own pool of reservations, so all of a JITDylib's objects are colocated (kept within range of each other for direct, e.g.
size_t reservationUnits () const
 The reservation granularity passed to the constructor: each slab reserved from the executor address space is a multiple of this.
void allocate (const jitlink::JITLinkDylib *JD, jitlink::LinkGraph &G, OnAllocatedFunction OnAllocated) override
 Start the allocation process.
void deallocate (std::vector< FinalizedAlloc > Allocs, OnDeallocatedFunction OnDeallocated) override
 Deallocate a list of allocation objects.
void denySlabGrowth ()
 Restrict each JITDylib to a single reservation ("slab").
void allowSlabGrowth ()
 Allow each JITDylib to grow into additional reservations on demand (the default).
void setSlabPolicy (SlabGrowthPolicy Policy)
 Set a custom slab-growth policy. See SlabGrowthPolicy above.
void notifyDestroying (jitlink::JITLinkDylib &JD) override
 Called when a registered JITDylib is destroyed (see jitlink::JITLinkDylib::notifyOnDestruction).

Static Public Member Functions

template<class MemoryMapperType, class... Args>
static Expected< std::unique_ptr< MapperJITLinkMemoryManager > > CreateWithMapper (size_t ReservationGranularity, Args &&...A)
static constexpr size_t defaultSlabSize ()
 The default per-slab reservation size used by createColocatingInProcessMemoryManager: 1 GiB on 64-bit hosts, 10 MiB on 32-bit hosts.

Detailed Description

Definition at line 26 of file MapperJITLinkMemoryManager.h.

Member Typedef Documentation

◆ SlabGrowthPolicy

Initial value:
const jitlink::JITLinkDylib *JD, size_t RequestedSize)>
unique_function is a type-erasing functor similar to std::function.

Policy invoked before reserving an additional slab for a JITDylib (i.e.

when its existing reservations can't satisfy a request). JD and RequestedSize identify the JITDylib and reservation size behind the request, for use in diagnostics. Returning an Error fails the triggering allocation.

Definition at line 77 of file MapperJITLinkMemoryManager.h.

Constructor & Destructor Documentation

◆ MapperJITLinkMemoryManager()

llvm::orc::MapperJITLinkMemoryManager::MapperJITLinkMemoryManager ( size_t ReservationGranularity,
std::unique_ptr< MemoryMapper > Mapper,
bool ColocatePerJITDylib = false )

If ColocatePerJITDylib is true each JITDylib draws from its own pool of reservations, so all of a JITDylib's objects are colocated (kept within range of each other for direct, e.g.

32-bit PC-relative, references). If false (the default) a single shared pool is used for all JITDylibs.

Definition at line 57 of file MapperJITLinkMemoryManager.cpp.

References llvm::move().

Referenced by llvm::orc::MapperJITLinkMemoryManager::InFlightAlloc::InFlightAlloc().

Member Function Documentation

◆ allocate()

void llvm::orc::MapperJITLinkMemoryManager::allocate ( const jitlink::JITLinkDylib * JD,
jitlink::LinkGraph & G,
OnAllocatedFunction OnAllocated )
overridevirtual

Start the allocation process.

If the initial allocation is successful then the OnAllocated function will be called with a std::unique_ptr<InFlightAlloc> value. If the assocation is unsuccessful then the OnAllocated function will be called with an Error.

Implements llvm::jitlink::JITLinkMemoryManager.

Definition at line 119 of file MapperJITLinkMemoryManager.cpp.

References llvm::alignTo(), llvm::jitlink::BasicLayout::apply(), llvm::IntervalMap< KeyT, ValT, N, Traits >::begin(), llvm::orc::ExecutorAddrRange::empty(), llvm::End, llvm::IntervalMap< KeyT, ValT, N, Traits >::end(), G, llvm::jitlink::BasicLayout::getContiguousPageBasedLayoutSizes(), llvm::orc::Result, and llvm::jitlink::BasicLayout::segments().

◆ allowSlabGrowth()

void llvm::orc::MapperJITLinkMemoryManager::allowSlabGrowth ( )

Allow each JITDylib to grow into additional reservations on demand (the default).

Objects in different slabs of the same JITDylib are not guaranteed to be within range of each other.

Note: LLJITBuilder::setColocatingSlabAllocator() overrides this default to denySlabGrowth() when no SlabGrowthPolicy is given.

Definition at line 94 of file MapperJITLinkMemoryManager.cpp.

References llvm::Error::success().

◆ CreateWithMapper()

template<class MemoryMapperType, class... Args>
Expected< std::unique_ptr< MapperJITLinkMemoryManager > > llvm::orc::MapperJITLinkMemoryManager::CreateWithMapper ( size_t ReservationGranularity,
Args &&... A )
inlinestatic

Definition at line 39 of file MapperJITLinkMemoryManager.h.

References A().

◆ deallocate()

void llvm::orc::MapperJITLinkMemoryManager::deallocate ( std::vector< FinalizedAlloc > Allocs,
OnDeallocatedFunction OnDeallocated )
overridevirtual

Deallocate a list of allocation objects.

Dealloc actions will be run in reverse order (from the end of the vector to the start).

Implements llvm::jitlink::JITLinkMemoryManager.

Definition at line 233 of file MapperJITLinkMemoryManager.cpp.

References llvm::Size, and llvm::Error::success().

◆ defaultSlabSize()

constexpr size_t llvm::orc::MapperJITLinkMemoryManager::defaultSlabSize ( )
inlinestaticconstexpr

The default per-slab reservation size used by createColocatingInProcessMemoryManager: 1 GiB on 64-bit hosts, 10 MiB on 32-bit hosts.

This is address space that is reserved, not committed.

Definition at line 51 of file MapperJITLinkMemoryManager.h.

Referenced by llvm::orc::createColocatingInProcessMemoryManager().

◆ denySlabGrowth()

void llvm::orc::MapperJITLinkMemoryManager::denySlabGrowth ( )

Restrict each JITDylib to a single reservation ("slab").

Once a JITDylib's slab is full, further allocations for it fail rather than silently spilling into another, possibly out-of-range, slab.

Definition at line 84 of file MapperJITLinkMemoryManager.cpp.

References llvm::createStringError(), and llvm::jitlink::JITLinkDylib::getName().

◆ notifyDestroying()

void llvm::orc::MapperJITLinkMemoryManager::notifyDestroying ( jitlink::JITLinkDylib & JD)
overridevirtual

Called when a registered JITDylib is destroyed (see jitlink::JITLinkDylib::notifyOnDestruction).

Frees its pool so a new JITDylib at the same (reused) address doesn't inherit stale state.

Reimplemented from llvm::jitlink::JITLinkMemoryManager.

Definition at line 79 of file MapperJITLinkMemoryManager.cpp.

◆ reservationUnits()

size_t llvm::orc::MapperJITLinkMemoryManager::reservationUnits ( ) const
inline

The reservation granularity passed to the constructor: each slab reserved from the executor address space is a multiple of this.

Definition at line 60 of file MapperJITLinkMemoryManager.h.

◆ setSlabPolicy()

void llvm::orc::MapperJITLinkMemoryManager::setSlabPolicy ( SlabGrowthPolicy Policy)

Set a custom slab-growth policy. See SlabGrowthPolicy above.

Definition at line 101 of file MapperJITLinkMemoryManager.cpp.


The documentation for this class was generated from the following files: