mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-30 06:40:53 +00:00
[ORC] Make ObjectLinkingLayer own its jitlink::MemoryManager.
This relieves ObjectLinkingLayer clients of the responsibility of holding the memory manager. This makes it easier to select between RTDyldObjectLinkingLayer (which already owned its memory manager factory) and ObjectLinkingLayer at runtime as clients aren't required to hold a jitlink::MemoryManager field just in case ObjectLinkingLayer is selected.
This commit is contained in:
parent
7e87c82433
commit
9b94fee202
@ -79,7 +79,7 @@ public:
|
||||
/// Construct an ObjectLinkingLayer with the given NotifyLoaded,
|
||||
/// and NotifyEmitted functors.
|
||||
ObjectLinkingLayer(ExecutionSession &ES,
|
||||
jitlink::JITLinkMemoryManager &MemMgr);
|
||||
std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr);
|
||||
|
||||
/// Destruct an ObjectLinkingLayer.
|
||||
~ObjectLinkingLayer();
|
||||
@ -145,7 +145,7 @@ private:
|
||||
Error removeAllModules();
|
||||
|
||||
mutable std::mutex LayerMutex;
|
||||
jitlink::JITLinkMemoryManager &MemMgr;
|
||||
std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr;
|
||||
bool OverrideObjectFlags = false;
|
||||
bool AutoClaimObjectSymbols = false;
|
||||
ReturnObjectBufferFunction ReturnObjectBuffer;
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
Layer.ReturnObjectBuffer(std::move(ObjBuffer));
|
||||
}
|
||||
|
||||
JITLinkMemoryManager &getMemoryManager() override { return Layer.MemMgr; }
|
||||
JITLinkMemoryManager &getMemoryManager() override { return *Layer.MemMgr; }
|
||||
|
||||
MemoryBufferRef getObjectBuffer() const override {
|
||||
return ObjBuffer->getMemBufferRef();
|
||||
@ -328,9 +328,9 @@ private:
|
||||
|
||||
ObjectLinkingLayer::Plugin::~Plugin() {}
|
||||
|
||||
ObjectLinkingLayer::ObjectLinkingLayer(ExecutionSession &ES,
|
||||
JITLinkMemoryManager &MemMgr)
|
||||
: ObjectLayer(ES), MemMgr(MemMgr) {}
|
||||
ObjectLinkingLayer::ObjectLinkingLayer(
|
||||
ExecutionSession &ES, std::unique_ptr<JITLinkMemoryManager> MemMgr)
|
||||
: ObjectLayer(ES), MemMgr(std::move(MemMgr)) {}
|
||||
|
||||
ObjectLinkingLayer::~ObjectLinkingLayer() {
|
||||
if (auto Err = removeAllModules())
|
||||
|
@ -397,8 +397,8 @@ static std::unique_ptr<jitlink::JITLinkMemoryManager> createMemoryManager() {
|
||||
}
|
||||
|
||||
Session::Session(Triple TT)
|
||||
: MainJD(ES.createJITDylib("<main>")), MemMgr(createMemoryManager()),
|
||||
ObjLayer(ES, *MemMgr), TT(std::move(TT)) {
|
||||
: MainJD(ES.createJITDylib("<main>")), ObjLayer(ES, createMemoryManager()),
|
||||
TT(std::move(TT)) {
|
||||
|
||||
/// Local ObjectLinkingLayer::Plugin class to forward modifyPassConfig to the
|
||||
/// Session.
|
||||
|
@ -27,7 +27,6 @@ namespace llvm {
|
||||
struct Session {
|
||||
orc::ExecutionSession ES;
|
||||
orc::JITDylib &MainJD;
|
||||
std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr;
|
||||
orc::ObjectLinkingLayer ObjLayer;
|
||||
std::vector<orc::JITDylib *> JDSearchOrder;
|
||||
Triple TT;
|
||||
|
Loading…
Reference in New Issue
Block a user