13#ifndef LLVM_EXECUTIONENGINE_ORC_COFFPLATFORM_H
14#define LLVM_EXECUTIONENGINE_ORC_COFFPLATFORM_H
44 JITDylib &PlatformJD,
const char *OrcRuntimePath,
46 const char *VCRuntimePath =
nullptr,
47 std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
73 using COFFJITDylibDepInfo = std::vector<ExecutorAddr>;
74 using COFFJITDylibDepInfoMap =
75 std::vector<std::pair<ExecutorAddr, COFFJITDylibDepInfo>>;
76 using COFFObjectSectionsMap =
78 using PushInitializersSendResultFn =
90 void modifyPassConfig(MaterializationResponsibility &MR,
95 getSyntheticSymbolDependencies(MaterializationResponsibility &MR)
override;
99 Error notifyFailed(MaterializationResponsibility &MR)
override {
103 Error notifyRemovingResources(JITDylib &JD,
ResourceKey K)
override {
107 void notifyTransferringResources(JITDylib &JD,
ResourceKey DstKey,
111 using InitSymbolDepMap =
112 DenseMap<MaterializationResponsibility *, JITLinkSymbolSet>;
114 Error associateJITDylibHeaderSymbol(jitlink::LinkGraph &
G,
115 MaterializationResponsibility &MR,
118 Error preserveInitializerSections(jitlink::LinkGraph &
G,
119 MaterializationResponsibility &MR);
120 Error registerObjectPlatformSections(jitlink::LinkGraph &
G, JITDylib &JD);
121 Error registerObjectPlatformSectionsInBootstrap(jitlink::LinkGraph &
G,
124 std::mutex PluginMutex;
126 InitSymbolDepMap InitSymbolDeps;
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);
139 COFFPlatform(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
140 JITDylib &PlatformJD,
const char *OrcRuntimePath,
142 const char *VCRuntimePath, Error &Err);
145 Error associateRuntimeSupportFunctions(JITDylib &PlatformJD);
148 Error bootstrapCOFFRuntime(JITDylib &PlatformJD);
151 Error runSymbolIfExists(JITDylib &PlatformJD, StringRef SymbolName);
154 Error runBootstrapInitializers(JDBootstrapState &BState);
155 Error runBootstrapSubsectionInitializers(JDBootstrapState &BState,
156 StringRef Start, StringRef End);
159 Expected<JITDylibDepMap> buildJDDepMap(JITDylib &JD);
161 Expected<MemoryBufferRef> getPerJDObjectFile();
166 void pushInitializersLoop(PushInitializersSendResultFn SendResult,
169 void rt_pushInitializers(PushInitializersSendResultFn SendResult,
170 ExecutorAddr JDHeaderAddr);
172 void rt_lookupSymbol(SendSymbolAddressFn SendResult, ExecutorAddr Handle,
173 StringRef SymbolName);
175 ExecutionSession &ES;
176 ObjectLinkingLayer &ObjLinkingLayer;
179 std::unique_ptr<COFFVCRuntimeBootstrapper> VCRuntimeBootstrap;
180 std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer;
181 std::unique_ptr<object::Archive> OrcRuntimeArchive;
182 bool StaticVCRuntime;
184 SymbolStringPtr COFFHeaderStartSymbol;
187 std::map<JITDylib *, JDBootstrapState> JDBootstrapStates;
188 std::atomic<bool> Bootstrapping;
190 ExecutorAddr orc_rt_coff_platform_bootstrap;
191 ExecutorAddr orc_rt_coff_platform_shutdown;
192 ExecutorAddr orc_rt_coff_register_object_sections;
193 ExecutorAddr orc_rt_coff_deregister_object_sections;
194 ExecutorAddr orc_rt_coff_register_jitdylib;
195 ExecutorAddr orc_rt_coff_deregister_jitdylib;
197 DenseMap<JITDylib *, ExecutorAddr> JITDylibToHeaderAddr;
198 DenseMap<ExecutorAddr, JITDylib *> HeaderAddrToJITDylib;
200 DenseMap<JITDylib *, SymbolLookupSet> RegisteredInitSymbols;
202 std::set<std::string> DylibsToPreload;
204 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.
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
Plugin instances can be added to the ObjectLinkingLayer to receive callbacks when code is loaded or e...
DenseMap< SymbolStringPtr, JITLinkSymbolSet > SyntheticSymbolDependenciesMap
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...