LLVM 22.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
20
21namespace llvm {
22namespace orc {
23
26public:
27 MapperJITLinkMemoryManager(size_t ReservationGranularity,
28 std::unique_ptr<MemoryMapper> Mapper);
29
30 template <class MemoryMapperType, class... Args>
32 CreateWithMapper(size_t ReservationGranularity, Args &&...A) {
33 auto Mapper = MemoryMapperType::Create(std::forward<Args>(A)...);
34 if (!Mapper)
35 return Mapper.takeError();
36
37 return std::make_unique<MapperJITLinkMemoryManager>(ReservationGranularity,
38 std::move(*Mapper));
39 }
40
41 void allocate(const jitlink::JITLinkDylib *JD, jitlink::LinkGraph &G,
42 OnAllocatedFunction OnAllocated) override;
43 // synchronous overload
44 using JITLinkMemoryManager::allocate;
45
46 void deallocate(std::vector<FinalizedAlloc> Allocs,
47 OnDeallocatedFunction OnDeallocated) override;
48 // synchronous overload
49 using JITLinkMemoryManager::deallocate;
50
51private:
52 class InFlightAlloc;
53
54 std::mutex Mutex;
55
56 // We reserve multiples of this from the executor address space
57 size_t ReservationUnits;
58
59 // Ranges that have been reserved in executor but not yet allocated
60 using AvailableMemoryMap = IntervalMap<ExecutorAddr, bool>;
61 AvailableMemoryMap::Allocator AMAllocator;
62 IntervalMap<ExecutorAddr, bool> AvailableMemory;
63
64 // Ranges that have been reserved in executor and already allocated
66
67 std::unique_ptr<MemoryMapper> Mapper;
68};
69
70} // end namespace orc
71} // end namespace llvm
72
73#endif // LLVM_EXECUTIONENGINE_ORC_MAPPERJITLINKMEMORYMANAGER_H
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_ABI
Definition Compiler.h:213
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:485
static Expected< std::unique_ptr< MapperJITLinkMemoryManager > > CreateWithMapper(size_t ReservationGranularity, Args &&...A)
MapperJITLinkMemoryManager(size_t ReservationGranularity, std::unique_ptr< MemoryMapper > Mapper)
SmartMutex< false > Mutex
Mutex - A standard, always enforced mutex.
Definition Mutex.h:66
This is an optimization pass for GlobalISel generic memory operations.