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

36public:

37

38

41

42

43

46 std::unique_ptr OrcRuntimeArchiveBuffer,

48 const char *VCRuntimePath = nullptr,

49 std::optional RuntimeAliases = std::nullopt);

50

54 bool StaticVCRuntime = false, const char *VCRuntimePath = nullptr,

55 std::optional RuntimeAliases = std::nullopt);

56

59

65

66

67

68

70

71

73

74

76 standardRuntimeUtilityAliases();

77

79

80private:

81 using COFFJITDylibDepInfo = std::vector;

82 using COFFJITDylibDepInfoMap =

83 std::vector<std::pair<ExecutorAddr, COFFJITDylibDepInfo>>;

84 using COFFObjectSectionsMap =

86 using PushInitializersSendResultFn =

90

91

92

93

95 public:

96 COFFPlatformPlugin(COFFPlatform &CP) : CP(CP) {}

97

98 void modifyPassConfig(MaterializationResponsibility &MR,

101

102

103

104 Error notifyFailed(MaterializationResponsibility &MR) override {

106 }

107

108 Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override {

109 return Error::success();

110 }

111

112 void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey,

113 ResourceKey SrcKey) override {}

114

115 private:

116 Error associateJITDylibHeaderSymbol(jitlink::LinkGraph &G,

117 MaterializationResponsibility &MR,

118 bool Bootstrap);

119

120 Error preserveInitializerSections(jitlink::LinkGraph &G,

121 MaterializationResponsibility &MR);

122 Error registerObjectPlatformSections(jitlink::LinkGraph &G, JITDylib &JD);

123 Error registerObjectPlatformSectionsInBootstrap(jitlink::LinkGraph &G,

124 JITDylib &JD);

125

126 std::mutex PluginMutex;

127 COFFPlatform &CP;

128 };

129

130 struct JDBootstrapState {

131 JITDylib *JD = nullptr;

132 std::string JDName;

133 ExecutorAddr HeaderAddr;

134 std::list ObjectSectionsMaps;

135 SmallVector<std::pair<std::string, ExecutorAddr>> Initializers;

136 };

137

138 static bool supportedTarget(const Triple &TT);

139

140 COFFPlatform(

141 ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,

142 std::unique_ptr OrcRuntimeGenerator,

143 std::setstd::string DylibsToPreload,

144 std::unique_ptr OrcRuntimeArchiveBuffer,

145 std::unique_ptrobject::Archive OrcRuntimeArchive,

146 LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime,

147 const char *VCRuntimePath, Error &Err);

148

149

150 Error associateRuntimeSupportFunctions(JITDylib &PlatformJD);

151

152

153 Error bootstrapCOFFRuntime(JITDylib &PlatformJD);

154

155

156 Error runSymbolIfExists(JITDylib &PlatformJD, StringRef SymbolName);

157

158

159 Error runBootstrapInitializers(JDBootstrapState &BState);

160 Error runBootstrapSubsectionInitializers(JDBootstrapState &BState,

161 StringRef Start, StringRef End);

162

163

164 Expected buildJDDepMap(JITDylib &JD);

165

166 Expected getPerJDObjectFile();

167

168

169

170

171 void pushInitializersLoop(PushInitializersSendResultFn SendResult,

172 JITDylibSP JD, JITDylibDepMap &JDDepMap);

173

174 void rt_pushInitializers(PushInitializersSendResultFn SendResult,

175 ExecutorAddr JDHeaderAddr);

176

177 void rt_lookupSymbol(SendSymbolAddressFn SendResult, ExecutorAddr Handle,

178 StringRef SymbolName);

179

180 ExecutionSession &ES;

181 ObjectLinkingLayer &ObjLinkingLayer;

182

183 LoadDynamicLibrary LoadDynLibrary;

184 std::unique_ptr VCRuntimeBootstrap;

185 std::unique_ptr OrcRuntimeArchiveBuffer;

186 std::unique_ptrobject::Archive OrcRuntimeArchive;

187 bool StaticVCRuntime;

188

189 SymbolStringPtr COFFHeaderStartSymbol;

190

191

192 std::map<JITDylib *, JDBootstrapState> JDBootstrapStates;

193 std::atomic Bootstrapping;

194

195 ExecutorAddr orc_rt_coff_platform_bootstrap;

196 ExecutorAddr orc_rt_coff_platform_shutdown;

197 ExecutorAddr orc_rt_coff_register_object_sections;

198 ExecutorAddr orc_rt_coff_deregister_object_sections;

199 ExecutorAddr orc_rt_coff_register_jitdylib;

200 ExecutorAddr orc_rt_coff_deregister_jitdylib;

201

202 DenseMap<JITDylib *, ExecutorAddr> JITDylibToHeaderAddr;

203 DenseMap<ExecutorAddr, JITDylib *> HeaderAddrToJITDylib;

204

205 DenseMap<JITDylib *, SymbolLookupSet> RegisteredInitSymbols;

206

207 std::mutex PlatformMutex;

208};