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);
52 JITDylib &PlatformJD,
const char *OrcRuntimePath,
54 const char *VCRuntimePath =
nullptr,
55 std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
81 using COFFJITDylibDepInfo = std::vector<ExecutorAddr>;
82 using COFFJITDylibDepInfoMap =
83 std::vector<std::pair<ExecutorAddr, COFFJITDylibDepInfo>>;
84 using COFFObjectSectionsMap =
86 using PushInitializersSendResultFn =
98 void modifyPassConfig(MaterializationResponsibility &MR,
103 getSyntheticSymbolDependencies(MaterializationResponsibility &MR)
override;
107 Error notifyFailed(MaterializationResponsibility &MR)
override {
111 Error notifyRemovingResources(JITDylib &JD,
ResourceKey K)
override {
115 void notifyTransferringResources(JITDylib &JD,
ResourceKey DstKey,
119 using InitSymbolDepMap =
120 DenseMap<MaterializationResponsibility *, JITLinkSymbolSet>;
122 Error associateJITDylibHeaderSymbol(jitlink::LinkGraph &
G,
123 MaterializationResponsibility &MR,
126 Error preserveInitializerSections(jitlink::LinkGraph &
G,
127 MaterializationResponsibility &MR);
128 Error registerObjectPlatformSections(jitlink::LinkGraph &
G, JITDylib &JD);
129 Error registerObjectPlatformSectionsInBootstrap(jitlink::LinkGraph &
G,
132 std::mutex PluginMutex;
134 InitSymbolDepMap InitSymbolDeps;
137 struct JDBootstrapState {
138 JITDylib *JD =
nullptr;
140 ExecutorAddr HeaderAddr;
141 std::list<COFFObjectSectionsMap> ObjectSectionsMaps;
142 SmallVector<std::pair<std::string, ExecutorAddr>> Initializers;
145 static bool supportedTarget(
const Triple &TT);
148 ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
149 JITDylib &PlatformJD,
150 std::unique_ptr<StaticLibraryDefinitionGenerator> OrcRuntimeGenerator,
151 std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer,
152 std::unique_ptr<object::Archive> OrcRuntimeArchive,
154 const char *VCRuntimePath, Error &Err);
157 Error associateRuntimeSupportFunctions(JITDylib &PlatformJD);
160 Error bootstrapCOFFRuntime(JITDylib &PlatformJD);
163 Error runSymbolIfExists(JITDylib &PlatformJD, StringRef SymbolName);
166 Error runBootstrapInitializers(JDBootstrapState &BState);
167 Error runBootstrapSubsectionInitializers(JDBootstrapState &BState,
168 StringRef Start, StringRef
End);
171 Expected<JITDylibDepMap> buildJDDepMap(JITDylib &JD);
173 Expected<MemoryBufferRef> getPerJDObjectFile();
178 void pushInitializersLoop(PushInitializersSendResultFn SendResult,
181 void rt_pushInitializers(PushInitializersSendResultFn SendResult,
182 ExecutorAddr JDHeaderAddr);
184 void rt_lookupSymbol(SendSymbolAddressFn SendResult, ExecutorAddr Handle,
185 StringRef SymbolName);
187 ExecutionSession &ES;
188 ObjectLinkingLayer &ObjLinkingLayer;
191 std::unique_ptr<COFFVCRuntimeBootstrapper> VCRuntimeBootstrap;
192 std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer;
193 std::unique_ptr<object::Archive> OrcRuntimeArchive;
194 bool StaticVCRuntime;
196 SymbolStringPtr COFFHeaderStartSymbol;
199 std::map<JITDylib *, JDBootstrapState> JDBootstrapStates;
200 std::atomic<bool> Bootstrapping;
202 ExecutorAddr orc_rt_coff_platform_bootstrap;
203 ExecutorAddr orc_rt_coff_platform_shutdown;
204 ExecutorAddr orc_rt_coff_register_object_sections;
205 ExecutorAddr orc_rt_coff_deregister_object_sections;
206 ExecutorAddr orc_rt_coff_register_jitdylib;
207 ExecutorAddr orc_rt_coff_deregister_jitdylib;
209 DenseMap<JITDylib *, ExecutorAddr> JITDylibToHeaderAddr;
210 DenseMap<ExecutorAddr, JITDylib *> HeaderAddrToJITDylib;
212 DenseMap<JITDylib *, SymbolLookupSet> RegisteredInitSymbols;
214 std::set<std::string> DylibsToPreload;
216 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...