LLVM 20.0.0git
MapperJITLinkMemoryManager.h
Go to the documentation of this file.
1//===--------------- MapperJITLinkMemoryManager.h -*- C++ -*---------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Implements JITLinkMemoryManager using MemoryMapper
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_MAPPERJITLINKMEMORYMANAGER_H
14#define LLVM_EXECUTIONENGINE_ORC_MAPPERJITLINKMEMORYMANAGER_H
15
19
20namespace llvm {
21namespace orc {
22
24public:
25 MapperJITLinkMemoryManager(size_t ReservationGranularity,
26 std::unique_ptr<MemoryMapper> Mapper);
27
28 template <class MemoryMapperType, class... Args>
30 CreateWithMapper(size_t ReservationGranularity, Args &&...A) {
31 auto Mapper = MemoryMapperType::Create(std::forward<Args>(A)...);
32 if (!Mapper)
33 return Mapper.takeError();
34
35 return std::make_unique<MapperJITLinkMemoryManager>(ReservationGranularity,
36 std::move(*Mapper));
37 }
38
40 OnAllocatedFunction OnAllocated) override;
41 // synchronous overload
42 using JITLinkMemoryManager::allocate;
43
44 void deallocate(std::vector<FinalizedAlloc> Allocs,
45 OnDeallocatedFunction OnDeallocated) override;
46 // synchronous overload
47 using JITLinkMemoryManager::deallocate;
48
49private:
50 class InFlightAlloc;
51
52 std::mutex Mutex;
53
54 // We reserve multiples of this from the executor address space
55 size_t ReservationUnits;
56
57 // Ranges that have been reserved in executor but not yet allocated
58 using AvailableMemoryMap = IntervalMap<ExecutorAddr, bool>;
60 IntervalMap<ExecutorAddr, bool> AvailableMemory;
61
62 // Ranges that have been reserved in executor and already allocated
64
65 std::unique_ptr<MemoryMapper> Mapper;
66};
67
68} // end namespace orc
69} // end namespace llvm
70
71#endif // LLVM_EXECUTIONENGINE_ORC_MAPPERJITLINKMEMORYMANAGER_H
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file implements a coalescing interval map for small objects.
#define G(x, y, z)
Definition: MD5.cpp:56
Tagged union holding either a T or a Error.
Definition: Error.h:481
typename Sizer::Allocator Allocator
Definition: IntervalMap.h:962
void deallocate(std::vector< FinalizedAlloc > Allocs, OnDeallocatedFunction OnDeallocated) override
Deallocate a list of allocation objects.
static Expected< std::unique_ptr< MapperJITLinkMemoryManager > > CreateWithMapper(size_t ReservationGranularity, Args &&...A)
void allocate(const jitlink::JITLinkDylib *JD, jitlink::LinkGraph &G, OnAllocatedFunction OnAllocated) override
Start the allocation process.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18