forked from OSchip/llvm-project
[ORC][JITLink] Switch to unique ownership for EHFrameRegistrars.
This will make stateful registrars (e.g. a future TargetProcessControl based registrar) easier to deal with.
This commit is contained in:
parent
7a5a74ea96
commit
605df8112c
|
@ -42,32 +42,11 @@ public:
|
|||
/// Registers / Deregisters EH-frames in the current process.
|
||||
class InProcessEHFrameRegistrar final : public EHFrameRegistrar {
|
||||
public:
|
||||
/// Get a reference to the InProcessEHFrameRegistrar singleton.
|
||||
static InProcessEHFrameRegistrar &getInstance();
|
||||
|
||||
InProcessEHFrameRegistrar(const InProcessEHFrameRegistrar &) = delete;
|
||||
InProcessEHFrameRegistrar &
|
||||
operator=(const InProcessEHFrameRegistrar &) = delete;
|
||||
|
||||
InProcessEHFrameRegistrar(InProcessEHFrameRegistrar &&) = delete;
|
||||
InProcessEHFrameRegistrar &operator=(InProcessEHFrameRegistrar &&) = delete;
|
||||
|
||||
Error registerEHFrames(JITTargetAddress EHFrameSectionAddr,
|
||||
size_t EHFrameSectionSize) override {
|
||||
return registerEHFrameSection(
|
||||
jitTargetAddressToPointer<void *>(EHFrameSectionAddr),
|
||||
EHFrameSectionSize);
|
||||
}
|
||||
size_t EHFrameSectionSize) override;
|
||||
|
||||
Error deregisterEHFrames(JITTargetAddress EHFrameSectionAddr,
|
||||
size_t EHFrameSectionSize) override {
|
||||
return deregisterEHFrameSection(
|
||||
jitTargetAddressToPointer<void *>(EHFrameSectionAddr),
|
||||
EHFrameSectionSize);
|
||||
}
|
||||
|
||||
private:
|
||||
InProcessEHFrameRegistrar();
|
||||
size_t EHFrameSectionSize) override;
|
||||
};
|
||||
|
||||
using StoreFrameRangeFunction =
|
||||
|
|
|
@ -177,7 +177,8 @@ private:
|
|||
|
||||
class EHFrameRegistrationPlugin : public ObjectLinkingLayer::Plugin {
|
||||
public:
|
||||
EHFrameRegistrationPlugin(jitlink::EHFrameRegistrar &Registrar);
|
||||
EHFrameRegistrationPlugin(
|
||||
std::unique_ptr<jitlink::EHFrameRegistrar> Registrar);
|
||||
Error notifyEmitted(MaterializationResponsibility &MR) override;
|
||||
void modifyPassConfig(MaterializationResponsibility &MR, const Triple &TT,
|
||||
jitlink::PassConfiguration &PassConfig) override;
|
||||
|
@ -192,7 +193,7 @@ private:
|
|||
};
|
||||
|
||||
std::mutex EHFramePluginMutex;
|
||||
jitlink::EHFrameRegistrar &Registrar;
|
||||
std::unique_ptr<jitlink::EHFrameRegistrar> Registrar;
|
||||
DenseMap<MaterializationResponsibility *, EHFrameRange> InProcessLinks;
|
||||
DenseMap<VModuleKey, EHFrameRange> TrackedEHFrameRanges;
|
||||
std::vector<EHFrameRange> UntrackedEHFrameRanges;
|
||||
|
|
|
@ -763,12 +763,19 @@ Error deregisterEHFrameSection(const void *EHFrameSectionAddr,
|
|||
|
||||
EHFrameRegistrar::~EHFrameRegistrar() {}
|
||||
|
||||
InProcessEHFrameRegistrar &InProcessEHFrameRegistrar::getInstance() {
|
||||
static InProcessEHFrameRegistrar Instance;
|
||||
return Instance;
|
||||
Error InProcessEHFrameRegistrar::registerEHFrames(
|
||||
JITTargetAddress EHFrameSectionAddr, size_t EHFrameSectionSize) {
|
||||
return registerEHFrameSection(
|
||||
jitTargetAddressToPointer<void *>(EHFrameSectionAddr),
|
||||
EHFrameSectionSize);
|
||||
}
|
||||
|
||||
InProcessEHFrameRegistrar::InProcessEHFrameRegistrar() {}
|
||||
Error InProcessEHFrameRegistrar::deregisterEHFrames(
|
||||
JITTargetAddress EHFrameSectionAddr, size_t EHFrameSectionSize) {
|
||||
return deregisterEHFrameSection(
|
||||
jitTargetAddressToPointer<void *>(EHFrameSectionAddr),
|
||||
EHFrameSectionSize);
|
||||
}
|
||||
|
||||
LinkGraphPassFunction
|
||||
createEHFrameRecorderPass(const Triple &TT,
|
||||
|
|
|
@ -984,7 +984,7 @@ Error LLJITBuilderState::prepareForConstruction() {
|
|||
ObjLinkingLayer = std::make_unique<ObjectLinkingLayer>(
|
||||
ES, std::make_unique<jitlink::InProcessMemoryManager>());
|
||||
ObjLinkingLayer->addPlugin(std::make_unique<EHFrameRegistrationPlugin>(
|
||||
jitlink::InProcessEHFrameRegistrar::getInstance()));
|
||||
std::make_unique<jitlink::InProcessEHFrameRegistrar>()));
|
||||
return std::move(ObjLinkingLayer);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -536,8 +536,8 @@ Error ObjectLinkingLayer::removeAllModules() {
|
|||
}
|
||||
|
||||
EHFrameRegistrationPlugin::EHFrameRegistrationPlugin(
|
||||
EHFrameRegistrar &Registrar)
|
||||
: Registrar(Registrar) {}
|
||||
std::unique_ptr<EHFrameRegistrar> Registrar)
|
||||
: Registrar(std::move(Registrar)) {}
|
||||
|
||||
void EHFrameRegistrationPlugin::modifyPassConfig(
|
||||
MaterializationResponsibility &MR, const Triple &TT,
|
||||
|
@ -572,7 +572,7 @@ Error EHFrameRegistrationPlugin::notifyEmitted(
|
|||
else
|
||||
UntrackedEHFrameRanges.push_back(EHFrameRange);
|
||||
|
||||
return Registrar.registerEHFrames(EHFrameRange.Addr, EHFrameRange.Size);
|
||||
return Registrar->registerEHFrames(EHFrameRange.Addr, EHFrameRange.Size);
|
||||
}
|
||||
|
||||
Error EHFrameRegistrationPlugin::notifyRemovingModule(VModuleKey K) {
|
||||
|
@ -587,7 +587,7 @@ Error EHFrameRegistrationPlugin::notifyRemovingModule(VModuleKey K) {
|
|||
|
||||
TrackedEHFrameRanges.erase(EHFrameRangeItr);
|
||||
|
||||
return Registrar.deregisterEHFrames(EHFrameRange.Addr, EHFrameRange.Size);
|
||||
return Registrar->deregisterEHFrames(EHFrameRange.Addr, EHFrameRange.Size);
|
||||
}
|
||||
|
||||
Error EHFrameRegistrationPlugin::notifyRemovingAllModules() {
|
||||
|
@ -608,9 +608,8 @@ Error EHFrameRegistrationPlugin::notifyRemovingAllModules() {
|
|||
auto EHFrameRange = EHFrameRanges.back();
|
||||
assert(EHFrameRange.Addr && "Untracked eh-frame range must not be null");
|
||||
EHFrameRanges.pop_back();
|
||||
Err = joinErrors(std::move(Err),
|
||||
Registrar.deregisterEHFrames(EHFrameRange.Addr,
|
||||
EHFrameRange.Size));
|
||||
Err = joinErrors(std::move(Err), Registrar->deregisterEHFrames(
|
||||
EHFrameRange.Addr, EHFrameRange.Size));
|
||||
}
|
||||
|
||||
return Err;
|
||||
|
|
|
@ -618,7 +618,7 @@ Session::Session(Triple TT, uint64_t PageSize, Error &Err)
|
|||
|
||||
if (!NoExec && !TT.isOSWindows())
|
||||
ObjLayer.addPlugin(std::make_unique<EHFrameRegistrationPlugin>(
|
||||
InProcessEHFrameRegistrar::getInstance()));
|
||||
std::make_unique<InProcessEHFrameRegistrar>()));
|
||||
|
||||
ObjLayer.addPlugin(std::make_unique<JITLinkSessionPlugin>(*this));
|
||||
|
||||
|
|
Loading…
Reference in New Issue