LLVM: include/llvm/ExecutionEngine/Orc/MemoryMapper.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_EXECUTIONENGINE_ORC_MEMORYMAPPER_H

14#define LLVM_EXECUTIONENGINE_ORC_MEMORYMAPPER_H

15

20

21#include

22

23namespace llvm {

24namespace orc {

25

26

28public:

29

30

44

46

47

49

50

52

53

54

55

56

58 size_t ContentSize) = 0;

59

61

62

63

64

65

66

67

70

72

73

74

77

79

80

83

85};

86

88public:

90

92

93 unsigned int getPageSize() override { return PageSize; }

94

95 void reserve(size_t NumBytes, OnReservedFunction OnReserved) override;

96

97 void initialize(AllocInfo &AI, OnInitializedFunction OnInitialized) override;

98

100 size_t ContentSize) override;

101

103 OnDeinitializedFunction OnDeInitialized) override;

104

106 OnReleasedFunction OnRelease) override;

107

109

110private:

111 struct Allocation {

113 std::vectorshared::WrapperFunctionCall DeinitializationActions;

114 };

116

117 struct Reservation {

119 std::vector Allocations;

120 };

121 using ReservationMap = DenseMap<void *, Reservation>;

122

123 std::mutex Mutex;

124 ReservationMap Reservations;

125 AllocationMap Allocations;

126

128};

129

131public:

139

141 size_t PageSize);

142

145

146 unsigned int getPageSize() override { return PageSize; }

147

148 void reserve(size_t NumBytes, OnReservedFunction OnReserved) override;

149

151 size_t ContentSize) override;

152

153 void initialize(AllocInfo &AI, OnInitializedFunction OnInitialized) override;

154

156 OnDeinitializedFunction OnDeInitialized) override;

157

159 OnReleasedFunction OnRelease) override;

160

162

163private:

164 struct Reservation {

165 void *LocalAddr;

167 int SharedMemoryId;

168 };

169

170 ExecutorProcessControl &EPC;

171 SymbolAddrs SAs;

172

173 std::mutex Mutex;

174

175 std::map<ExecutorAddr, Reservation> Reservations;

176

178};

179

180}

181}

182

183#endif

static cl::opt< int > PageSize("imp-null-check-page-size", cl::desc("The page size of the target in bytes"), cl::init(4096), cl::Hidden)

Provides a library for accessing information about this process and other processes on the operating ...

static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, const llvm::StringTable &StandardNames, VectorLibrary VecLib)

Initialize the set of available library functions based on the specified target triple.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

Lightweight error class with error context and mandatory checking.

Tagged union holding either a T or a Error.

A pair of memory protections and allocation policies.

Represents an address in the executor process.

ExecutorProcessControl supports interaction with a JIT target process.

Definition MemoryMapper.h:87

InProcessMemoryMapper(size_t PageSize)

static Expected< std::unique_ptr< InProcessMemoryMapper > > Create()

unsigned int getPageSize() override

Definition MemoryMapper.h:93

Manages mapping, content transfer and protections for JIT memory.

Definition MemoryMapper.h:27

unique_function< void(Error)> OnReleasedFunction

Definition MemoryMapper.h:78

virtual char * prepare(jitlink::LinkGraph &G, ExecutorAddr Addr, size_t ContentSize)=0

Provides working memory The LinkGraph parameter is included to allow implementations to allocate work...

virtual unsigned int getPageSize()=0

virtual void release(ArrayRef< ExecutorAddr > Reservations, OnReleasedFunction OnRelease)=0

Release address space acquired through reserve()

virtual void initialize(AllocInfo &AI, OnInitializedFunction OnInitialized)=0

Ensures executor memory is synchronized with working copy memory, sends functions to be called after ...

virtual void deinitialize(ArrayRef< ExecutorAddr > Allocations, OnDeinitializedFunction OnDeInitialized)=0

Runs previously specified deinitialization actions Executor addresses returned by initialize should b...

virtual void reserve(size_t NumBytes, OnReservedFunction OnReserved)=0

Reserves address space in executor process.

unique_function< void(Expected< ExecutorAddr >)> OnInitializedFunction

Definition MemoryMapper.h:60

unique_function< void(Expected< ExecutorAddrRange >)> OnReservedFunction

Definition MemoryMapper.h:45

unique_function< void(Error)> OnDeinitializedFunction

Definition MemoryMapper.h:71

unique_function is a type-erasing functor similar to std::function.

uint64_t ExecutorAddrDiff

SmartMutex< false > Mutex

Mutex - A standard, always enforced mutex.

This is an optimization pass for GlobalISel generic memory operations.

Summary of memprof metadata on allocations.

Definition MemoryMapper.h:32

size_t ZeroFillSize

Definition MemoryMapper.h:36

ExecutorAddrDiff Offset

Definition MemoryMapper.h:33

AllocGroup AG

Definition MemoryMapper.h:37

size_t ContentSize

Definition MemoryMapper.h:35

const char * WorkingMem

Definition MemoryMapper.h:34

Represents a single allocation containing multiple segments and initialization and deinitialization a...

Definition MemoryMapper.h:31

std::vector< SegInfo > Segments

Definition MemoryMapper.h:41

ExecutorAddr MappingBase

Definition MemoryMapper.h:40

shared::AllocActions Actions

Definition MemoryMapper.h:42