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

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_EXECUTIONENGINE_SECTIONMEMORYMANAGER_H

15#define LLVM_EXECUTIONENGINE_SECTIONMEMORYMANAGER_H

16

21#include

22#include

23#include <system_error>

24

25namespace llvm {

26

27

28

29

30

31

32

33

34

35

36

37

38

39

41public:

42

43

49

50

51

53 public:

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

76 unsigned Flags, std::error_code &EC) = 0;

77

78

79

80

81

82

83

84

85

86

87

88

89

91 unsigned Flags) = 0;

92

93

94

95

96

97

98

99

101

103 };

104

105

106

107

112

113

114

115

116

117

119 unsigned SectionID,

121

122

123

124

125

126

129 bool isReadOnly) override;

130

131

132

133

134

135

136

137

138

139

140

141

142 bool finalizeMemory(std::string *ErrMsg = nullptr) override;

143

144

145

146

147

148

149

150

152

153private:

154 struct FreeMemBlock {

155

157

158

159

160

161 unsigned PendingPrefixIndex;

162 };

163

164 struct MemoryGroup {

165

166

167

168

171

172

174

176 };

177

178 uint8_t *allocateSection(AllocationPurpose Purpose, uintptr_t Size,

179 unsigned Alignment);

180

181 std::error_code applyMemoryGroupPermissions(MemoryGroup &MemGroup,

182 unsigned Permissions);

183

184 void anchor() override;

185

186 MemoryGroup CodeMem;

187 MemoryGroup RWDataMem;

188 MemoryGroup RODataMem;

189 MemoryMapper *MMapper;

190 std::unique_ptr OwnedMMapper;

191};

192

193}

194

195#endif

This file defines the SmallVector class.

RTDyldMemoryManager()=default

Implementations of this interface are used by SectionMemoryManager to request pages from the operatin...

Definition SectionMemoryManager.h:52

virtual std::error_code protectMappedMemory(const sys::MemoryBlock &Block, unsigned Flags)=0

This method sets the protection flags for a block of memory to the state specified by Flags.

virtual std::error_code releaseMappedMemory(sys::MemoryBlock &M)=0

This method releases a block of memory that was allocated with the allocateMappedMemory method.

virtual sys::MemoryBlock allocateMappedMemory(AllocationPurpose Purpose, size_t NumBytes, const sys::MemoryBlock *const NearBlock, unsigned Flags, std::error_code &EC)=0

This method attempts to allocate NumBytes bytes of virtual memory for Purpose.

AllocationPurpose

This enum describes the various reasons to allocate pages from allocateMappedMemory.

Definition SectionMemoryManager.h:44

@ ROData

Definition SectionMemoryManager.h:46

@ RWData

Definition SectionMemoryManager.h:47

@ Code

Definition SectionMemoryManager.h:45

SectionMemoryManager(MemoryMapper *MM=nullptr)

Creates a SectionMemoryManager instance with MM as the associated memory mapper.

virtual void invalidateInstructionCache()

Invalidate instruction cache for code sections.

void operator=(const SectionMemoryManager &)=delete

uint8_t * allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName, bool isReadOnly) override

Allocates a memory block of (at least) the given size suitable for executable code.

uint8_t * allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName) override

Allocates a memory block of (at least) the given size suitable for executable code.

SectionMemoryManager(const SectionMemoryManager &)=delete

bool finalizeMemory(std::string *ErrMsg=nullptr) override

Update section-specific memory permissions and other attributes.

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

This class encapsulates the notion of a memory block which has an address and a size.

This is an optimization pass for GlobalISel generic memory operations.