13#ifndef LLVM_EXECUTIONENGINE_ORC_COFFPLATFORM_H
14#define LLVM_EXECUTIONENGINE_ORC_COFFPLATFORM_H
45 std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer,
47 const char *VCRuntimePath =
nullptr,
48 std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
53 bool StaticVCRuntime =
false,
const char *VCRuntimePath =
nullptr,
54 std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
80 using COFFJITDylibDepInfo = std::vector<ExecutorAddr>;
81 using COFFJITDylibDepInfoMap =
82 std::vector<std::pair<ExecutorAddr, COFFJITDylibDepInfo>>;
83 using COFFObjectSectionsMap =
85 using PushInitializersSendResultFn =
97 void modifyPassConfig(MaterializationResponsibility &MR,
103 Error notifyFailed(MaterializationResponsibility &MR)
override {
107 Error notifyRemovingResources(JITDylib &JD,
ResourceKey K)
override {
111 void notifyTransferringResources(JITDylib &JD,
ResourceKey DstKey,
115 Error associateJITDylibHeaderSymbol(jitlink::LinkGraph &
G,
116 MaterializationResponsibility &MR,
119 Error preserveInitializerSections(jitlink::LinkGraph &
G,
120 MaterializationResponsibility &MR);
121 Error registerObjectPlatformSections(jitlink::LinkGraph &
G, JITDylib &JD);
122 Error registerObjectPlatformSectionsInBootstrap(jitlink::LinkGraph &
G,
125 std::mutex PluginMutex;
129 struct JDBootstrapState {
130 JITDylib *JD =
nullptr;
132 ExecutorAddr HeaderAddr;
133 std::list<COFFObjectSectionsMap> ObjectSectionsMaps;
134 SmallVector<std::pair<std::string, ExecutorAddr>> Initializers;
137 static bool supportedTarget(
const Triple &TT);
140 ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
141 std::unique_ptr<StaticLibraryDefinitionGenerator> OrcRuntimeGenerator,
142 std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer,
143 std::unique_ptr<object::Archive> OrcRuntimeArchive,
145 const char *VCRuntimePath, Error &Err);
148 Error associateRuntimeSupportFunctions(JITDylib &PlatformJD);
151 Error bootstrapCOFFRuntime(JITDylib &PlatformJD);
154 Error runSymbolIfExists(JITDylib &PlatformJD, StringRef SymbolName);
157 Error runBootstrapInitializers(JDBootstrapState &BState);
158 Error runBootstrapSubsectionInitializers(JDBootstrapState &BState,
159 StringRef Start, StringRef
End);
162 Expected<JITDylibDepMap> buildJDDepMap(JITDylib &JD);
164 Expected<MemoryBufferRef> getPerJDObjectFile();
169 void pushInitializersLoop(PushInitializersSendResultFn SendResult,
172 void rt_pushInitializers(PushInitializersSendResultFn SendResult,
173 ExecutorAddr JDHeaderAddr);
175 void rt_lookupSymbol(SendSymbolAddressFn SendResult, ExecutorAddr Handle,
176 StringRef SymbolName);
178 ExecutionSession &ES;
179 ObjectLinkingLayer &ObjLinkingLayer;
182 std::unique_ptr<COFFVCRuntimeBootstrapper> VCRuntimeBootstrap;
183 std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer;
184 std::unique_ptr<object::Archive> OrcRuntimeArchive;
185 bool StaticVCRuntime;
187 SymbolStringPtr COFFHeaderStartSymbol;
190 std::map<JITDylib *, JDBootstrapState> JDBootstrapStates;
191 std::atomic<bool> Bootstrapping;
193 ExecutorAddr orc_rt_coff_platform_bootstrap;
194 ExecutorAddr orc_rt_coff_platform_shutdown;
195 ExecutorAddr orc_rt_coff_register_object_sections;
196 ExecutorAddr orc_rt_coff_deregister_object_sections;
197 ExecutorAddr orc_rt_coff_register_jitdylib;
198 ExecutorAddr orc_rt_coff_deregister_jitdylib;
200 DenseMap<JITDylib *, ExecutorAddr> JITDylibToHeaderAddr;
201 DenseMap<ExecutorAddr, JITDylib *> HeaderAddrToJITDylib;
203 DenseMap<JITDylib *, SymbolLookupSet> RegisteredInitSymbols;
205 std::set<std::string> DylibsToPreload;
207 std::mutex PlatformMutex;
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
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.
An ExecutionSession represents a running JIT program.
Represents a JIT'd dynamic library.
Plugin instances can be added to the ObjectLinkingLayer to receive callbacks when code is loaded or e...
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
An ObjectLayer implementation built on JITLink.
API to remove / transfer ownership of JIT resources.
IntrusiveRefCntPtr< JITDylib > JITDylibSP
This is an optimization pass for GlobalISel generic memory operations.
An LinkGraph pass configuration, consisting of a list of pre-prune, post-prune, and post-fixup passes...