1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[ORC] Rename TargetProcessControl to ExecutorProcessControl. NFC.

This is a first step towards consistently using the term 'executor' for the
process that executes JIT'd code. I've opted for 'executor' as the preferred
term over 'target' as target is already heavily overloaded ("the target
machine for the executor" is much clearer than "the target machine for the
target").
This commit is contained in:
Lang Hames 2021-07-01 11:53:18 +10:00
parent 2866155d9f
commit a397416183
28 changed files with 477 additions and 469 deletions

View File

@ -18,10 +18,10 @@
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/LLVMContext.h"
@ -32,7 +32,7 @@ namespace orc {
class KaleidoscopeJIT {
private:
std::unique_ptr<TargetProcessControl> TPC;
std::unique_ptr<ExecutorProcessControl> EPC;
std::unique_ptr<ExecutionSession> ES;
DataLayout DL;
@ -44,10 +44,10 @@ private:
JITDylib &MainJD;
public:
KaleidoscopeJIT(std::unique_ptr<TargetProcessControl> TPC,
KaleidoscopeJIT(std::unique_ptr<ExecutorProcessControl> EPC,
std::unique_ptr<ExecutionSession> ES,
JITTargetMachineBuilder JTMB, DataLayout DL)
: TPC(std::move(TPC)), ES(std::move(ES)), DL(std::move(DL)),
: EPC(std::move(EPC)), ES(std::move(ES)), DL(std::move(DL)),
Mangle(*this->ES, this->DL),
ObjectLayer(*this->ES,
[]() { return std::make_unique<SectionMemoryManager>(); }),
@ -66,19 +66,19 @@ public:
static Expected<std::unique_ptr<KaleidoscopeJIT>> Create() {
auto SSP = std::make_shared<SymbolStringPool>();
auto TPC = SelfTargetProcessControl::Create(SSP);
if (!TPC)
return TPC.takeError();
auto EPC = SelfExecutorProcessControl::Create(SSP);
if (!EPC)
return EPC.takeError();
auto ES = std::make_unique<ExecutionSession>(std::move(SSP));
JITTargetMachineBuilder JTMB((*TPC)->getTargetTriple());
JITTargetMachineBuilder JTMB((*EPC)->getTargetTriple());
auto DL = JTMB.getDefaultDataLayoutForTarget();
if (!DL)
return DL.takeError();
return std::make_unique<KaleidoscopeJIT>(std::move(*TPC), std::move(ES),
return std::make_unique<KaleidoscopeJIT>(std::move(*EPC), std::move(ES),
std::move(JTMB), std::move(*DL));
}

View File

@ -18,11 +18,11 @@
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/LLVMContext.h"
@ -37,7 +37,7 @@ namespace orc {
class KaleidoscopeJIT {
private:
std::unique_ptr<TargetProcessControl> TPC;
std::unique_ptr<ExecutorProcessControl> EPC;
std::unique_ptr<ExecutionSession> ES;
DataLayout DL;
@ -50,10 +50,10 @@ private:
JITDylib &MainJD;
public:
KaleidoscopeJIT(std::unique_ptr<TargetProcessControl> TPC,
KaleidoscopeJIT(std::unique_ptr<ExecutorProcessControl> EPC,
std::unique_ptr<ExecutionSession> ES,
JITTargetMachineBuilder JTMB, DataLayout DL)
: TPC(std::move(TPC)), ES(std::move(ES)), DL(std::move(DL)),
: EPC(std::move(EPC)), ES(std::move(ES)), DL(std::move(DL)),
Mangle(*this->ES, this->DL),
ObjectLayer(*this->ES,
[]() { return std::make_unique<SectionMemoryManager>(); }),
@ -73,19 +73,19 @@ public:
static Expected<std::unique_ptr<KaleidoscopeJIT>> Create() {
auto SSP = std::make_shared<SymbolStringPool>();
auto TPC = SelfTargetProcessControl::Create(SSP);
if (!TPC)
return TPC.takeError();
auto EPC = SelfExecutorProcessControl::Create(SSP);
if (!EPC)
return EPC.takeError();
auto ES = std::make_unique<ExecutionSession>(std::move(SSP));
JITTargetMachineBuilder JTMB((*TPC)->getTargetTriple());
JITTargetMachineBuilder JTMB((*EPC)->getTargetTriple());
auto DL = JTMB.getDefaultDataLayoutForTarget();
if (!DL)
return DL.takeError();
return std::make_unique<KaleidoscopeJIT>(std::move(*TPC), std::move(ES),
return std::make_unique<KaleidoscopeJIT>(std::move(*EPC), std::move(ES),
std::move(JTMB), std::move(*DL));
}

View File

@ -18,13 +18,13 @@
#include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/TPCIndirectionUtils.h"
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/LLVMContext.h"
@ -39,9 +39,9 @@ namespace orc {
class KaleidoscopeJIT {
private:
std::unique_ptr<TargetProcessControl> TPC;
std::unique_ptr<ExecutorProcessControl> EPC;
std::unique_ptr<ExecutionSession> ES;
std::unique_ptr<TPCIndirectionUtils> TPCIU;
std::unique_ptr<EPCIndirectionUtils> EPCIU;
DataLayout DL;
MangleAndInterner Mangle;
@ -59,11 +59,11 @@ private:
}
public:
KaleidoscopeJIT(std::unique_ptr<TargetProcessControl> TPC,
KaleidoscopeJIT(std::unique_ptr<ExecutorProcessControl> EPC,
std::unique_ptr<ExecutionSession> ES,
std::unique_ptr<TPCIndirectionUtils> TPCIU,
std::unique_ptr<EPCIndirectionUtils> EPCIU,
JITTargetMachineBuilder JTMB, DataLayout DL)
: TPC(std::move(TPC)), ES(std::move(ES)), TPCIU(std::move(TPCIU)),
: EPC(std::move(EPC)), ES(std::move(ES)), EPCIU(std::move(EPCIU)),
DL(std::move(DL)), Mangle(*this->ES, this->DL),
ObjectLayer(*this->ES,
[]() { return std::make_unique<SectionMemoryManager>(); }),
@ -71,8 +71,8 @@ public:
std::make_unique<ConcurrentIRCompiler>(std::move(JTMB))),
OptimizeLayer(*this->ES, CompileLayer, optimizeModule),
CODLayer(*this->ES, OptimizeLayer,
this->TPCIU->getLazyCallThroughManager(),
[this] { return this->TPCIU->createIndirectStubsManager(); }),
this->EPCIU->getLazyCallThroughManager(),
[this] { return this->EPCIU->createIndirectStubsManager(); }),
MainJD(this->ES->createBareJITDylib("<main>")) {
MainJD.addGenerator(
cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess(
@ -82,36 +82,36 @@ public:
~KaleidoscopeJIT() {
if (auto Err = ES->endSession())
ES->reportError(std::move(Err));
if (auto Err = TPCIU->cleanup())
if (auto Err = EPCIU->cleanup())
ES->reportError(std::move(Err));
}
static Expected<std::unique_ptr<KaleidoscopeJIT>> Create() {
auto SSP = std::make_shared<SymbolStringPool>();
auto TPC = SelfTargetProcessControl::Create(SSP);
if (!TPC)
return TPC.takeError();
auto EPC = SelfExecutorProcessControl::Create(SSP);
if (!EPC)
return EPC.takeError();
auto ES = std::make_unique<ExecutionSession>(std::move(SSP));
auto TPCIU = TPCIndirectionUtils::Create(**TPC);
if (!TPCIU)
return TPCIU.takeError();
auto EPCIU = EPCIndirectionUtils::Create(**EPC);
if (!EPCIU)
return EPCIU.takeError();
(*TPCIU)->createLazyCallThroughManager(
(*EPCIU)->createLazyCallThroughManager(
*ES, pointerToJITTargetAddress(&handleLazyCallThroughError));
if (auto Err = setUpInProcessLCTMReentryViaTPCIU(**TPCIU))
if (auto Err = setUpInProcessLCTMReentryViaEPCIU(**EPCIU))
return std::move(Err);
JITTargetMachineBuilder JTMB((*TPC)->getTargetTriple());
JITTargetMachineBuilder JTMB((*EPC)->getTargetTriple());
auto DL = JTMB.getDefaultDataLayoutForTarget();
if (!DL)
return DL.takeError();
return std::make_unique<KaleidoscopeJIT>(std::move(*TPC), std::move(ES),
std::move(*TPCIU), std::move(JTMB),
return std::make_unique<KaleidoscopeJIT>(std::move(*EPC), std::move(ES),
std::move(*EPCIU), std::move(JTMB),
std::move(*DL));
}

View File

@ -18,13 +18,13 @@
#include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/TPCIndirectionUtils.h"
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/LLVMContext.h"
@ -126,9 +126,9 @@ void KaleidoscopeASTMaterializationUnit::materialize(
class KaleidoscopeJIT {
private:
std::unique_ptr<TargetProcessControl> TPC;
std::unique_ptr<ExecutorProcessControl> EPC;
std::unique_ptr<ExecutionSession> ES;
std::unique_ptr<TPCIndirectionUtils> TPCIU;
std::unique_ptr<EPCIndirectionUtils> EPCIU;
DataLayout DL;
MangleAndInterner Mangle;
@ -146,11 +146,11 @@ private:
}
public:
KaleidoscopeJIT(std::unique_ptr<TargetProcessControl> TPC,
KaleidoscopeJIT(std::unique_ptr<ExecutorProcessControl> EPC,
std::unique_ptr<ExecutionSession> ES,
std::unique_ptr<TPCIndirectionUtils> TPCIU,
std::unique_ptr<EPCIndirectionUtils> EPCIU,
JITTargetMachineBuilder JTMB, DataLayout DL)
: TPC(std::move(TPC)), ES(std::move(ES)), TPCIU(std::move(TPCIU)),
: EPC(std::move(EPC)), ES(std::move(ES)), EPCIU(std::move(EPCIU)),
DL(std::move(DL)), Mangle(*this->ES, this->DL),
ObjectLayer(*this->ES,
[]() { return std::make_unique<SectionMemoryManager>(); }),
@ -167,36 +167,36 @@ public:
~KaleidoscopeJIT() {
if (auto Err = ES->endSession())
ES->reportError(std::move(Err));
if (auto Err = TPCIU->cleanup())
if (auto Err = EPCIU->cleanup())
ES->reportError(std::move(Err));
}
static Expected<std::unique_ptr<KaleidoscopeJIT>> Create() {
auto SSP = std::make_shared<SymbolStringPool>();
auto TPC = SelfTargetProcessControl::Create(SSP);
if (!TPC)
return TPC.takeError();
auto EPC = SelfExecutorProcessControl::Create(SSP);
if (!EPC)
return EPC.takeError();
auto ES = std::make_unique<ExecutionSession>(std::move(SSP));
auto TPCIU = TPCIndirectionUtils::Create(**TPC);
if (!TPCIU)
return TPCIU.takeError();
auto EPCIU = EPCIndirectionUtils::Create(**EPC);
if (!EPCIU)
return EPCIU.takeError();
(*TPCIU)->createLazyCallThroughManager(
(*EPCIU)->createLazyCallThroughManager(
*ES, pointerToJITTargetAddress(&handleLazyCallThroughError));
if (auto Err = setUpInProcessLCTMReentryViaTPCIU(**TPCIU))
if (auto Err = setUpInProcessLCTMReentryViaEPCIU(**EPCIU))
return std::move(Err);
JITTargetMachineBuilder JTMB((*TPC)->getTargetTriple());
JITTargetMachineBuilder JTMB((*EPC)->getTargetTriple());
auto DL = JTMB.getDefaultDataLayoutForTarget();
if (!DL)
return DL.takeError();
return std::make_unique<KaleidoscopeJIT>(std::move(*TPC), std::move(ES),
std::move(*TPCIU), std::move(JTMB),
return std::make_unique<KaleidoscopeJIT>(std::move(*EPC), std::move(ES),
std::move(*EPCIU), std::move(JTMB),
std::move(*DL));
}

View File

@ -18,10 +18,10 @@
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/LLVMContext.h"
@ -32,7 +32,7 @@ namespace orc {
class KaleidoscopeJIT {
private:
std::unique_ptr<TargetProcessControl> TPC;
std::unique_ptr<ExecutorProcessControl> EPC;
std::unique_ptr<ExecutionSession> ES;
DataLayout DL;
@ -44,10 +44,10 @@ private:
JITDylib &MainJD;
public:
KaleidoscopeJIT(std::unique_ptr<TargetProcessControl> TPC,
KaleidoscopeJIT(std::unique_ptr<ExecutorProcessControl> EPC,
std::unique_ptr<ExecutionSession> ES,
JITTargetMachineBuilder JTMB, DataLayout DL)
: TPC(std::move(TPC)), ES(std::move(ES)), DL(std::move(DL)),
: EPC(std::move(EPC)), ES(std::move(ES)), DL(std::move(DL)),
Mangle(*this->ES, this->DL),
ObjectLayer(*this->ES,
[]() { return std::make_unique<SectionMemoryManager>(); }),
@ -66,19 +66,19 @@ public:
static Expected<std::unique_ptr<KaleidoscopeJIT>> Create() {
auto SSP = std::make_shared<SymbolStringPool>();
auto TPC = SelfTargetProcessControl::Create(SSP);
if (!TPC)
return TPC.takeError();
auto EPC = SelfExecutorProcessControl::Create(SSP);
if (!EPC)
return EPC.takeError();
auto ES = std::make_unique<ExecutionSession>(std::move(SSP));
JITTargetMachineBuilder JTMB((*TPC)->getTargetTriple());
JITTargetMachineBuilder JTMB((*EPC)->getTargetTriple());
auto DL = JTMB.getDefaultDataLayoutForTarget();
if (!DL)
return DL.takeError();
return std::make_unique<KaleidoscopeJIT>(std::move(*TPC), std::move(ES),
return std::make_unique<KaleidoscopeJIT>(std::move(*EPC), std::move(ES),
std::move(JTMB), std::move(*DL));
}

View File

@ -9,10 +9,10 @@
#include "RemoteJITUtils.h"
#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
#include "llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h"
#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h"
#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"
#include "llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/Shared/RPCUtils.h"
#include "llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h"
#include "llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
@ -31,25 +31,25 @@ using namespace llvm::orc;
namespace llvm {
namespace orc {
class RemoteTargetProcessControl
: public OrcRPCTargetProcessControlBase<
class RemoteExecutorProcessControl
: public OrcRPCExecutorProcessControlBase<
shared::MultiThreadedRPCEndpoint<JITLinkExecutor::RPCChannel>> {
public:
using RPCChannel = JITLinkExecutor::RPCChannel;
using RPCEndpoint = shared::MultiThreadedRPCEndpoint<RPCChannel>;
private:
using ThisT = RemoteTargetProcessControl;
using BaseT = OrcRPCTargetProcessControlBase<RPCEndpoint>;
using MemoryAccess = OrcRPCTPCMemoryAccess<ThisT>;
using MemoryManager = OrcRPCTPCJITLinkMemoryManager<ThisT>;
using ThisT = RemoteExecutorProcessControl;
using BaseT = OrcRPCExecutorProcessControlBase<RPCEndpoint>;
using MemoryAccess = OrcRPCEPCMemoryAccess<ThisT>;
using MemoryManager = OrcRPCEPCJITLinkMemoryManager<ThisT>;
public:
using BaseT::initializeORCRPCTPCBase;
using BaseT::initializeORCRPCEPCBase;
RemoteTargetProcessControl(ExecutionSession &ES,
std::unique_ptr<RPCChannel> Channel,
std::unique_ptr<RPCEndpoint> Endpoint);
RemoteExecutorProcessControl(ExecutionSession &ES,
std::unique_ptr<RPCChannel> Channel,
std::unique_ptr<RPCEndpoint> Endpoint);
void initializeMemoryManagement();
Error disconnect() override;
@ -63,7 +63,7 @@ private:
std::thread ListenerThread;
};
RemoteTargetProcessControl::RemoteTargetProcessControl(
RemoteExecutorProcessControl::RemoteExecutorProcessControl(
ExecutionSession &ES, std::unique_ptr<RPCChannel> Channel,
std::unique_ptr<RPCEndpoint> Endpoint)
: BaseT(ES.getSymbolStringPool(), *Endpoint,
@ -80,7 +80,7 @@ RemoteTargetProcessControl::RemoteTargetProcessControl(
});
}
void RemoteTargetProcessControl::initializeMemoryManagement() {
void RemoteExecutorProcessControl::initializeMemoryManagement() {
OwnedMemAccess = std::make_unique<MemoryAccess>(*this);
OwnedMemMgr = std::make_unique<MemoryManager>(*this);
@ -89,7 +89,7 @@ void RemoteTargetProcessControl::initializeMemoryManagement() {
MemMgr = OwnedMemMgr.get();
}
Error RemoteTargetProcessControl::disconnect() {
Error RemoteExecutorProcessControl::disconnect() {
std::promise<MSVCPError> P;
auto F = P.get_future();
auto Err = closeConnection([&](Error Err) -> Error {
@ -109,11 +109,11 @@ JITLinkExecutor::~JITLinkExecutor() = default;
Expected<std::unique_ptr<ObjectLayer>>
JITLinkExecutor::operator()(ExecutionSession &ES, const Triple &TT) {
return std::make_unique<ObjectLinkingLayer>(ES, TPC->getMemMgr());
return std::make_unique<ObjectLinkingLayer>(ES, EPC->getMemMgr());
}
Error JITLinkExecutor::addDebugSupport(ObjectLayer &ObjLayer) {
auto Registrar = createJITLoaderGDBRegistrar(*TPC);
auto Registrar = createJITLoaderGDBRegistrar(*EPC);
if (!Registrar)
return Registrar.takeError();
@ -126,18 +126,18 @@ Error JITLinkExecutor::addDebugSupport(ObjectLayer &ObjLayer) {
Expected<std::unique_ptr<DefinitionGenerator>>
JITLinkExecutor::loadDylib(StringRef RemotePath) {
if (auto Handle = TPC->loadDylib(RemotePath.data()))
return std::make_unique<TPCDynamicLibrarySearchGenerator>(*TPC, *Handle);
if (auto Handle = EPC->loadDylib(RemotePath.data()))
return std::make_unique<EPCDynamicLibrarySearchGenerator>(*EPC, *Handle);
else
return Handle.takeError();
}
Expected<int> JITLinkExecutor::runAsMain(JITEvaluatedSymbol MainSym,
ArrayRef<std::string> Args) {
return TPC->runAsMain(MainSym.getAddress(), Args);
return EPC->runAsMain(MainSym.getAddress(), Args);
}
Error JITLinkExecutor::disconnect() { return TPC->disconnect(); }
Error JITLinkExecutor::disconnect() { return EPC->disconnect(); }
static std::string defaultPath(const char *HostArgv0, StringRef ExecutorName) {
// This just needs to be some symbol in the binary; C++ doesn't
@ -173,8 +173,8 @@ JITLinkExecutor::CreateLocal(std::string ExecutablePath) {
}
TCPSocketJITLinkExecutor::TCPSocketJITLinkExecutor(
std::unique_ptr<RemoteTargetProcessControl> TPC) {
this->TPC = std::move(TPC);
std::unique_ptr<RemoteExecutorProcessControl> EPC) {
this->EPC = std::move(EPC);
}
#ifndef LLVM_ON_UNIX
@ -249,16 +249,16 @@ Error ChildProcessJITLinkExecutor::launch(ExecutionSession &ES) {
auto Channel =
std::make_unique<RPCChannel>(FromExecutor[ReadEnd], ToExecutor[WriteEnd]);
auto Endpoint =
std::make_unique<RemoteTargetProcessControl::RPCEndpoint>(*Channel, true);
auto Endpoint = std::make_unique<RemoteExecutorProcessControl::RPCEndpoint>(
*Channel, true);
TPC = std::make_unique<RemoteTargetProcessControl>(ES, std::move(Channel),
std::move(Endpoint));
EPC = std::make_unique<RemoteExecutorProcessControl>(ES, std::move(Channel),
std::move(Endpoint));
if (auto Err = TPC->initializeORCRPCTPCBase())
return joinErrors(std::move(Err), TPC->disconnect());
if (auto Err = EPC->initializeORCRPCEPCBase())
return joinErrors(std::move(Err), EPC->disconnect());
TPC->initializeMemoryManagement();
EPC->initializeMemoryManagement();
shared::registerStringError<RPCChannel>();
return Error::success();
@ -328,20 +328,20 @@ JITLinkExecutor::ConnectTCPSocket(StringRef NetworkAddress,
return CreateErr(toString(SockFD.takeError()));
auto Channel = std::make_unique<RPCChannel>(*SockFD, *SockFD);
auto Endpoint =
std::make_unique<RemoteTargetProcessControl::RPCEndpoint>(*Channel, true);
auto Endpoint = std::make_unique<RemoteExecutorProcessControl::RPCEndpoint>(
*Channel, true);
auto TPC = std::make_unique<RemoteTargetProcessControl>(
auto EPC = std::make_unique<RemoteExecutorProcessControl>(
ES, std::move(Channel), std::move(Endpoint));
if (auto Err = TPC->initializeORCRPCTPCBase())
return joinErrors(std::move(Err), TPC->disconnect());
if (auto Err = EPC->initializeORCRPCEPCBase())
return joinErrors(std::move(Err), EPC->disconnect());
TPC->initializeMemoryManagement();
EPC->initializeMemoryManagement();
shared::registerStringError<RPCChannel>();
return std::unique_ptr<TCPSocketJITLinkExecutor>(
new TCPSocketJITLinkExecutor(std::move(TPC)));
new TCPSocketJITLinkExecutor(std::move(EPC)));
}
#endif

View File

@ -6,7 +6,8 @@
//
//===----------------------------------------------------------------------===//
//
// Utilities for TargetProcessControl-based remote JITing with Orc and JITLink.
// Utilities for ExecutorProcessControl-based remote JITing with Orc and
// JITLink.
//
//===----------------------------------------------------------------------===//
@ -36,7 +37,7 @@ namespace llvm {
namespace orc {
class ChildProcessJITLinkExecutor;
class RemoteTargetProcessControl;
class RemoteExecutorProcessControl;
class TCPSocketJITLinkExecutor;
class JITLinkExecutor {
@ -73,7 +74,7 @@ public:
virtual ~JITLinkExecutor();
protected:
std::unique_ptr<RemoteTargetProcessControl> TPC;
std::unique_ptr<RemoteExecutorProcessControl> EPC;
JITLinkExecutor();
};
@ -100,7 +101,7 @@ private:
/// JITLinkExecutor connected through a TCP socket.
class TCPSocketJITLinkExecutor : public JITLinkExecutor {
private:
TCPSocketJITLinkExecutor(std::unique_ptr<RemoteTargetProcessControl> TPC);
TCPSocketJITLinkExecutor(std::unique_ptr<RemoteExecutorProcessControl> EPC);
friend class JITLinkExecutor;
};

View File

@ -1,4 +1,4 @@
//===--- LLJITWithLazyReexports.cpp - LLJIT example with custom laziness --===//
//===- LLJITWithExecutorProcessControl.cpp - LLJIT example with EPC utils -===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -22,12 +22,12 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"
#include "llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/OrcABISupport.h"
#include "llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h"
#include "llvm/ExecutionEngine/Orc/TPCIndirectionUtils.h"
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/raw_ostream.h"
@ -105,8 +105,8 @@ static void *reenter(void *Ctx, void *TrampolineAddr) {
std::promise<void *> LandingAddressP;
auto LandingAddressF = LandingAddressP.get_future();
auto *TPCIU = static_cast<TPCIndirectionUtils *>(Ctx);
TPCIU->getLazyCallThroughManager().resolveTrampolineLandingAddress(
auto *EPCIU = static_cast<EPCIndirectionUtils *>(Ctx);
EPCIU->getLazyCallThroughManager().resolveTrampolineLandingAddress(
pointerToJITTargetAddress(TrampolineAddr),
[&](JITTargetAddress LandingAddress) {
LandingAddressP.set_value(
@ -135,8 +135,8 @@ int main(int argc, char *argv[]) {
// (1) Create LLJIT instance.
auto SSP = std::make_shared<SymbolStringPool>();
auto TPC = ExitOnErr(SelfTargetProcessControl::Create(std::move(SSP)));
auto J = ExitOnErr(LLJITBuilder().setTargetProcessControl(*TPC).create());
auto EPC = ExitOnErr(SelfExecutorProcessControl::Create(std::move(SSP)));
auto J = ExitOnErr(LLJITBuilder().setExecutorProcessControl(*EPC).create());
// (2) Install transform to print modules as they are compiled:
J->getIRTransformLayer().setTransform(
@ -147,14 +147,14 @@ int main(int argc, char *argv[]) {
});
// (3) Create stubs and call-through managers:
auto TPCIU = ExitOnErr(TPCIndirectionUtils::Create(*TPC));
ExitOnErr(TPCIU->writeResolverBlock(pointerToJITTargetAddress(&reenter),
pointerToJITTargetAddress(TPCIU.get())));
TPCIU->createLazyCallThroughManager(
auto EPCIU = ExitOnErr(EPCIndirectionUtils::Create(*EPC));
ExitOnErr(EPCIU->writeResolverBlock(pointerToJITTargetAddress(&reenter),
pointerToJITTargetAddress(EPCIU.get())));
EPCIU->createLazyCallThroughManager(
J->getExecutionSession(), pointerToJITTargetAddress(&reportErrorAndExit));
auto ISM = TPCIU->createIndirectStubsManager();
auto ISM = EPCIU->createIndirectStubsManager();
J->getMainJITDylib().addGenerator(
ExitOnErr(TPCDynamicLibrarySearchGenerator::GetForTargetProcess(*TPC)));
ExitOnErr(EPCDynamicLibrarySearchGenerator::GetForTargetProcess(*EPC)));
// (4) Add modules.
ExitOnErr(J->addIRModule(ExitOnErr(parseExampleModule(FooMod, "foo-mod"))));
@ -171,7 +171,7 @@ int main(int argc, char *argv[]) {
{Mangle("bar_body"),
JITSymbolFlags::Exported | JITSymbolFlags::Callable}}});
ExitOnErr(J->getMainJITDylib().define(
lazyReexports(TPCIU->getLazyCallThroughManager(), *ISM,
lazyReexports(EPCIU->getLazyCallThroughManager(), *ISM,
J->getMainJITDylib(), std::move(ReExports))));
// (6) Dump the ExecutionSession state.

View File

@ -208,7 +208,7 @@ LLVMErrorRef LLVMOrcLLJITAddLLVMIRModuleWithRT(LLVMOrcLLJITRef J,
* This operation does not take ownership of the Name argument.
*/
LLVMErrorRef LLVMOrcLLJITLookup(LLVMOrcLLJITRef J,
LLVMOrcJITTargetAddress *Result,
LLVMOrcExecutorAddress *Result,
const char *Name);
/**

View File

@ -34,10 +34,15 @@
LLVM_C_EXTERN_C_BEGIN
/**
* Represents an address in the target process.
* Represents an address in the executor process.
*/
typedef uint64_t LLVMOrcJITTargetAddress;
/**
* Represents an address in the executor process.
*/
typedef uint64_t LLVMOrcExecutorAddress;
/**
* Represents generic linkage flags for a symbol definition.
*/
@ -65,7 +70,7 @@ typedef struct {
* Represents an evaluated symbol address and flags.
*/
typedef struct {
LLVMOrcJITTargetAddress Address;
LLVMOrcExecutorAddress Address;
LLVMJITSymbolFlags Flags;
} LLVMJITEvaluatedSymbol;

View File

@ -16,8 +16,8 @@
#include "llvm/ADT/Triple.h"
#include "llvm/ExecutionEngine/JITLink/JITLink.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Memory.h"
#include "llvm/Support/MemoryBufferRef.h"

View File

@ -1,4 +1,4 @@
//===- TPCDebugObjectRegistrar.h - TPC-based debug registration -*- C++ -*-===//
//===- EPCDebugObjectRegistrar.h - EPC-based debug registration -*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -6,15 +6,15 @@
//
//===----------------------------------------------------------------------===//
//
// TargetProcessControl based registration of debug objects.
// ExecutorProcessControl based registration of debug objects.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_EXECUTIONENGINE_ORC_TPCDEBUGOBJECTREGISTRAR_H
#define LLVM_EXECUTIONENGINE_ORC_TPCDEBUGOBJECTREGISTRAR_H
#ifndef LLVM_EXECUTIONENGINE_ORC_EPCDEBUGOBJECTREGISTRAR_H
#define LLVM_EXECUTIONENGINE_ORC_EPCDEBUGOBJECTREGISTRAR_H
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Memory.h"
@ -27,38 +27,38 @@ using namespace llvm::orc::shared;
namespace llvm {
namespace orc {
/// Abstract interface for registering debug objects in the target process.
/// Abstract interface for registering debug objects in the executor process.
class DebugObjectRegistrar {
public:
virtual Error registerDebugObject(sys::MemoryBlock) = 0;
virtual ~DebugObjectRegistrar() {}
};
/// Use TargetProcessControl to register debug objects locally or in a remote
/// target process.
class TPCDebugObjectRegistrar : public DebugObjectRegistrar {
/// Use ExecutorProcessControl to register debug objects locally or in a remote
/// executor process.
class EPCDebugObjectRegistrar : public DebugObjectRegistrar {
public:
TPCDebugObjectRegistrar(TargetProcessControl &TPC,
EPCDebugObjectRegistrar(ExecutorProcessControl &EPC,
JITTargetAddress RegisterFn)
: TPC(TPC), RegisterFn(RegisterFn) {}
: EPC(EPC), RegisterFn(RegisterFn) {}
Error registerDebugObject(sys::MemoryBlock TargetMem) override {
return WrapperFunction<void(SPSTargetAddress, uint64_t)>::call(
TPCCaller(TPC, RegisterFn), pointerToJITTargetAddress(TargetMem.base()),
EPCCaller(EPC, RegisterFn), pointerToJITTargetAddress(TargetMem.base()),
static_cast<uint64_t>(TargetMem.allocatedSize()));
}
private:
TargetProcessControl &TPC;
ExecutorProcessControl &EPC;
JITTargetAddress RegisterFn;
};
/// Create a TargetProcessControl-based DebugObjectRegistrar that emits debug
/// Create a ExecutorProcessControl-based DebugObjectRegistrar that emits debug
/// objects to the GDB JIT interface.
Expected<std::unique_ptr<TPCDebugObjectRegistrar>>
createJITLoaderGDBRegistrar(TargetProcessControl &TPC);
Expected<std::unique_ptr<EPCDebugObjectRegistrar>>
createJITLoaderGDBRegistrar(ExecutorProcessControl &EPC);
} // end namespace orc
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_TDEBUGOBJECTREGISTRAR_H
#endif // LLVM_EXECUTIONENGINE_ORC_EPCDEBUGOBJECTREGISTRAR_H

View File

@ -1,4 +1,4 @@
//===------------ TPCDynamicLibrarySearchGenerator.h ------------*- C++ -*-===//
//===------------ EPCDynamicLibrarySearchGenerator.h ------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -6,21 +6,21 @@
//
//===----------------------------------------------------------------------===//
//
// Support loading and searching of dynamic libraries in a target process via
// the TargetProcessControl class.
// Support loading and searching of dynamic libraries in an executor process
// via the ExecutorProcessControl class.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_EXECUTIONENGINE_ORC_TPCDYNAMICLIBRARYSEARCHGENERATOR_H
#define LLVM_EXECUTIONENGINE_ORC_TPCDYNAMICLIBRARYSEARCHGENERATOR_H
#ifndef LLVM_EXECUTIONENGINE_ORC_EPCDYNAMICLIBRARYSEARCHGENERATOR_H
#define LLVM_EXECUTIONENGINE_ORC_EPCDYNAMICLIBRARYSEARCHGENERATOR_H
#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
namespace llvm {
namespace orc {
class TPCDynamicLibrarySearchGenerator : public DefinitionGenerator {
class EPCDynamicLibrarySearchGenerator : public DefinitionGenerator {
public:
using SymbolPredicate = unique_function<bool(const SymbolStringPtr &)>;
@ -30,24 +30,24 @@ public:
/// If the Allow predicate is given then only symbols matching the predicate
/// will be searched for. If the predicate is not given then all symbols will
/// be searched for.
TPCDynamicLibrarySearchGenerator(TargetProcessControl &TPC,
EPCDynamicLibrarySearchGenerator(ExecutorProcessControl &EPC,
tpctypes::DylibHandle H,
SymbolPredicate Allow = SymbolPredicate())
: TPC(TPC), H(H), Allow(std::move(Allow)) {}
: EPC(EPC), H(H), Allow(std::move(Allow)) {}
/// Permanently loads the library at the given path and, on success, returns
/// a DynamicLibrarySearchGenerator that will search it for symbol definitions
/// in the library. On failure returns the reason the library failed to load.
static Expected<std::unique_ptr<TPCDynamicLibrarySearchGenerator>>
Load(TargetProcessControl &TPC, const char *LibraryPath,
static Expected<std::unique_ptr<EPCDynamicLibrarySearchGenerator>>
Load(ExecutorProcessControl &EPC, const char *LibraryPath,
SymbolPredicate Allow = SymbolPredicate());
/// Creates a TPCDynamicLibrarySearchGenerator that searches for symbols in
/// Creates a EPCDynamicLibrarySearchGenerator that searches for symbols in
/// the target process.
static Expected<std::unique_ptr<TPCDynamicLibrarySearchGenerator>>
GetForTargetProcess(TargetProcessControl &TPC,
static Expected<std::unique_ptr<EPCDynamicLibrarySearchGenerator>>
GetForTargetProcess(ExecutorProcessControl &EPC,
SymbolPredicate Allow = SymbolPredicate()) {
return Load(TPC, nullptr, std::move(Allow));
return Load(EPC, nullptr, std::move(Allow));
}
Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD,
@ -55,7 +55,7 @@ public:
const SymbolLookupSet &Symbols) override;
private:
TargetProcessControl &TPC;
ExecutorProcessControl &EPC;
tpctypes::DylibHandle H;
SymbolPredicate Allow;
};
@ -63,4 +63,4 @@ private:
} // end namespace orc
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_TPCDYNAMICLIBRARYSEARCHGENERATOR_H
#endif // LLVM_EXECUTIONENGINE_ORC_EPCDYNAMICLIBRARYSEARCHGENERATOR_H

View File

@ -1,4 +1,4 @@
//===-- TPCEHFrameRegistrar.h - TPC based eh-frame registration -*- C++ -*-===//
//===-- EPCEHFrameRegistrar.h - EPC based eh-frame registration -*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -6,35 +6,35 @@
//
//===----------------------------------------------------------------------===//
//
// TargetProcessControl based eh-frame registration.
// ExecutorProcessControl based eh-frame registration.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_EXECUTIONENGINE_ORC_TPCEHFRAMEREGISTRAR_H
#define LLVM_EXECUTIONENGINE_ORC_TPCEHFRAMEREGISTRAR_H
#ifndef LLVM_EXECUTIONENGINE_ORC_EPCEHFRAMEREGISTRAR_H
#define LLVM_EXECUTIONENGINE_ORC_EPCEHFRAMEREGISTRAR_H
#include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h"
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
namespace llvm {
namespace orc {
/// Register/Deregisters EH frames in a remote process via a
/// TargetProcessControl instance.
class TPCEHFrameRegistrar : public jitlink::EHFrameRegistrar {
/// ExecutorProcessControl instance.
class EPCEHFrameRegistrar : public jitlink::EHFrameRegistrar {
public:
/// Create from a TargetProcessControl instance alone. This will use
/// the TPC's lookupSymbols method to find the registration/deregistration
/// Create from a ExecutorProcessControl instance alone. This will use
/// the EPC's lookupSymbols method to find the registration/deregistration
/// funciton addresses by name.
static Expected<std::unique_ptr<TPCEHFrameRegistrar>>
Create(TargetProcessControl &TPC);
static Expected<std::unique_ptr<EPCEHFrameRegistrar>>
Create(ExecutorProcessControl &EPC);
/// Create a TPCEHFrameRegistrar with the given TargetProcessControl
/// Create a EPCEHFrameRegistrar with the given ExecutorProcessControl
/// object and registration/deregistration function addresses.
TPCEHFrameRegistrar(TargetProcessControl &TPC,
EPCEHFrameRegistrar(ExecutorProcessControl &EPC,
JITTargetAddress RegisterEHFrameWrapperFnAddr,
JITTargetAddress DeregisterEHFRameWrapperFnAddr)
: TPC(TPC), RegisterEHFrameWrapperFnAddr(RegisterEHFrameWrapperFnAddr),
: EPC(EPC), RegisterEHFrameWrapperFnAddr(RegisterEHFrameWrapperFnAddr),
DeregisterEHFrameWrapperFnAddr(DeregisterEHFRameWrapperFnAddr) {}
Error registerEHFrames(JITTargetAddress EHFrameSectionAddr,
@ -43,7 +43,7 @@ public:
size_t EHFrameSectionSize) override;
private:
TargetProcessControl &TPC;
ExecutorProcessControl &EPC;
JITTargetAddress RegisterEHFrameWrapperFnAddr;
JITTargetAddress DeregisterEHFrameWrapperFnAddr;
};
@ -51,4 +51,4 @@ private:
} // end namespace orc
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_TPCEHFRAMEREGISTRAR_H
#endif // LLVM_EXECUTIONENGINE_ORC_EPCEHFRAMEREGISTRAR_H

View File

@ -1,4 +1,4 @@
//===--- TPCIndirectionUtils.h - TPC based indirection utils ----*- C++ -*-===//
//===--- EPCIndirectionUtils.h - EPC based indirection utils ----*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
//
// Indirection utilities (stubs, trampolines, lazy call-throughs) that use the
// TargetProcessControl API to interact with the target process.
// ExecutorProcessControl API to interact with the executor process.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_EXECUTIONENGINE_ORC_TPCINDIRECTIONUTILS_H
#define LLVM_EXECUTIONENGINE_ORC_TPCINDIRECTIONUTILS_H
#ifndef LLVM_EXECUTIONENGINE_ORC_EPCINDIRECTIONUTILS_H
#define LLVM_EXECUTIONENGINE_ORC_EPCINDIRECTIONUTILS_H
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
#include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
@ -23,12 +23,12 @@
namespace llvm {
namespace orc {
class TargetProcessControl;
class ExecutorProcessControl;
/// Provides TargetProcessControl based indirect stubs, trampoline pool and
/// Provides ExecutorProcessControl based indirect stubs, trampoline pool and
/// lazy call through manager.
class TPCIndirectionUtils {
friend class TPCIndirectionUtilsAccess;
class EPCIndirectionUtils {
friend class EPCIndirectionUtilsAccess;
public:
/// ABI support base class. Used to write resolver, stub, and trampoline
@ -79,15 +79,15 @@ public:
/// Create using the given ABI class.
template <typename ORCABI>
static std::unique_ptr<TPCIndirectionUtils>
CreateWithABI(TargetProcessControl &TPC);
static std::unique_ptr<EPCIndirectionUtils>
CreateWithABI(ExecutorProcessControl &EPC);
/// Create based on the TargetProcessControl triple.
static Expected<std::unique_ptr<TPCIndirectionUtils>>
Create(TargetProcessControl &TPC);
/// Create based on the ExecutorProcessControl triple.
static Expected<std::unique_ptr<EPCIndirectionUtils>>
Create(ExecutorProcessControl &EPC);
/// Return a reference to the TargetProcessControl object.
TargetProcessControl &getTargetProcessControl() const { return TPC; }
/// Return a reference to the ExecutorProcessControl object.
ExecutorProcessControl &getExecutorProcessControl() const { return EPC; }
/// Return a reference to the ABISupport object for this instance.
ABISupport &getABISupport() const { return *ABI; }
@ -96,7 +96,7 @@ public:
/// prior to destruction of the class.
Error cleanup();
/// Write resolver code to the target process and return its address.
/// Write resolver code to the executor process and return its address.
/// This must be called before any call to createTrampolinePool or
/// createLazyCallThroughManager.
Expected<JITTargetAddress>
@ -107,10 +107,10 @@ public:
/// writeResolverBlock method has not previously been called.
JITTargetAddress getResolverBlockAddress() const { return ResolverBlockAddr; }
/// Create an IndirectStubsManager for the target process.
/// Create an IndirectStubsManager for the executor process.
std::unique_ptr<IndirectStubsManager> createIndirectStubsManager();
/// Create a TrampolinePool for the target process.
/// Create a TrampolinePool for the executor process.
TrampolinePool &getTrampolinePool();
/// Create a LazyCallThroughManager.
@ -119,7 +119,7 @@ public:
createLazyCallThroughManager(ExecutionSession &ES,
JITTargetAddress ErrorHandlerAddr);
/// Create a LazyCallThroughManager for the target process.
/// Create a LazyCallThroughManager for the executor process.
LazyCallThroughManager &getLazyCallThroughManager() {
assert(LCTM && "createLazyCallThroughManager must be called first");
return *LCTM;
@ -139,14 +139,14 @@ private:
using IndirectStubInfoVector = std::vector<IndirectStubInfo>;
/// Create a TPCIndirectionUtils instance.
TPCIndirectionUtils(TargetProcessControl &TPC,
/// Create an EPCIndirectionUtils instance.
EPCIndirectionUtils(ExecutorProcessControl &EPC,
std::unique_ptr<ABISupport> ABI);
Expected<IndirectStubInfoVector> getIndirectStubs(unsigned NumStubs);
std::mutex TPCUIMutex;
TargetProcessControl &TPC;
std::mutex EPCUIMutex;
ExecutorProcessControl &EPC;
std::unique_ptr<ABISupport> ABI;
JITTargetAddress ResolverBlockAddr;
std::unique_ptr<jitlink::JITLinkMemoryManager::Allocation> ResolverBlock;
@ -157,23 +157,23 @@ private:
std::vector<std::unique_ptr<Allocation>> IndirectStubAllocs;
};
/// This will call writeResolver on the given TPCIndirectionUtils instance
/// This will call writeResolver on the given EPCIndirectionUtils instance
/// to set up re-entry via a function that will directly return the trampoline
/// landing address.
///
/// The TPCIndirectionUtils' LazyCallThroughManager must have been previously
/// created via TPCIndirectionUtils::createLazyCallThroughManager.
/// The EPCIndirectionUtils' LazyCallThroughManager must have been previously
/// created via EPCIndirectionUtils::createLazyCallThroughManager.
///
/// The TPCIndirectionUtils' writeResolver method must not have been previously
/// The EPCIndirectionUtils' writeResolver method must not have been previously
/// called.
///
/// This function is experimental and likely subject to revision.
Error setUpInProcessLCTMReentryViaTPCIU(TPCIndirectionUtils &TPCIU);
Error setUpInProcessLCTMReentryViaEPCIU(EPCIndirectionUtils &EPCIU);
namespace detail {
template <typename ORCABI>
class ABISupportImpl : public TPCIndirectionUtils::ABISupport {
class ABISupportImpl : public EPCIndirectionUtils::ABISupport {
public:
ABISupportImpl()
: ABISupport(ORCABI::PointerSize, ORCABI::TrampolineSize,
@ -210,13 +210,13 @@ public:
} // end namespace detail
template <typename ORCABI>
std::unique_ptr<TPCIndirectionUtils>
TPCIndirectionUtils::CreateWithABI(TargetProcessControl &TPC) {
return std::unique_ptr<TPCIndirectionUtils>(new TPCIndirectionUtils(
TPC, std::make_unique<detail::ABISupportImpl<ORCABI>>()));
std::unique_ptr<EPCIndirectionUtils>
EPCIndirectionUtils::CreateWithABI(ExecutorProcessControl &EPC) {
return std::unique_ptr<EPCIndirectionUtils>(new EPCIndirectionUtils(
EPC, std::make_unique<detail::ABISupportImpl<ORCABI>>()));
}
} // end namespace orc
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_TPCINDIRECTIONUTILS_H
#endif // LLVM_EXECUTIONENGINE_ORC_EPCINDIRECTIONUTILS_H

View File

@ -1,4 +1,4 @@
//===--- TargetProcessControl.h - Target process control APIs ---*- C++ -*-===//
//===- ExecutorProcessControl.h - Executor process control APIs -*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
//
// Utilities for interacting with target processes.
// Utilities for interacting with the executor processes.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_EXECUTIONENGINE_ORC_TARGETPROCESSCONTROL_H
#define LLVM_EXECUTIONENGINE_ORC_TARGETPROCESSCONTROL_H
#ifndef LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H
#define LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
@ -29,8 +29,8 @@
namespace llvm {
namespace orc {
/// TargetProcessControl supports interaction with a JIT target process.
class TargetProcessControl {
/// ExecutorProcessControl supports interaction with a JIT target process.
class ExecutorProcessControl {
public:
/// APIs for manipulating memory in the target process.
class MemoryAccess {
@ -99,7 +99,7 @@ public:
const SymbolLookupSet &Symbols;
};
virtual ~TargetProcessControl();
virtual ~ExecutorProcessControl();
/// Intern a symbol name in the SymbolStringPool.
SymbolStringPtr intern(StringRef SymName) { return SSP->intern(SymName); }
@ -153,7 +153,7 @@ public:
virtual Error disconnect() = 0;
protected:
TargetProcessControl(std::shared_ptr<SymbolStringPool> SSP)
ExecutorProcessControl(std::shared_ptr<SymbolStringPool> SSP)
: SSP(std::move(SSP)) {}
std::shared_ptr<SymbolStringPool> SSP;
@ -163,33 +163,34 @@ protected:
jitlink::JITLinkMemoryManager *MemMgr = nullptr;
};
/// Call a wrapper function via TargetProcessControl::runWrapper.
class TPCCaller {
/// Call a wrapper function via ExecutorProcessControl::runWrapper.
class EPCCaller {
public:
TPCCaller(TargetProcessControl &TPC, JITTargetAddress WrapperFnAddr)
: TPC(TPC), WrapperFnAddr(WrapperFnAddr) {}
EPCCaller(ExecutorProcessControl &EPC, JITTargetAddress WrapperFnAddr)
: EPC(EPC), WrapperFnAddr(WrapperFnAddr) {}
Expected<shared::WrapperFunctionResult> operator()(const char *ArgData,
size_t ArgSize) const {
return TPC.runWrapper(WrapperFnAddr, ArrayRef<char>(ArgData, ArgSize));
return EPC.runWrapper(WrapperFnAddr, ArrayRef<char>(ArgData, ArgSize));
}
private:
TargetProcessControl &TPC;
ExecutorProcessControl &EPC;
JITTargetAddress WrapperFnAddr;
};
/// A TargetProcessControl implementation targeting the current process.
class SelfTargetProcessControl : public TargetProcessControl,
private TargetProcessControl::MemoryAccess {
/// A ExecutorProcessControl implementation targeting the current process.
class SelfExecutorProcessControl
: public ExecutorProcessControl,
private ExecutorProcessControl::MemoryAccess {
public:
SelfTargetProcessControl(
SelfExecutorProcessControl(
std::shared_ptr<SymbolStringPool> SSP, Triple TargetTriple,
unsigned PageSize, std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr);
/// Create a SelfTargetProcessControl with the given memory manager.
/// Create a SelfExecutorProcessControl with the given memory manager.
/// If no memory manager is given a jitlink::InProcessMemoryManager will
/// be used by default.
static Expected<std::unique_ptr<SelfTargetProcessControl>>
static Expected<std::unique_ptr<SelfExecutorProcessControl>>
Create(std::shared_ptr<SymbolStringPool> SSP,
std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr = nullptr);
@ -230,4 +231,4 @@ private:
} // end namespace orc
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESSCONTROL_H
#endif // LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H

View File

@ -29,7 +29,7 @@ namespace orc {
class LLJITBuilderState;
class LLLazyJITBuilderState;
class ObjectTransformLayer;
class TargetProcessControl;
class ExecutorProcessControl;
/// A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
///
@ -267,7 +267,7 @@ public:
CompileFunctionCreator CreateCompileFunction;
PlatformSetupFunction SetUpPlatform;
unsigned NumCompileThreads = 0;
TargetProcessControl *TPC = nullptr;
ExecutorProcessControl *EPC = nullptr;
/// Called prior to JIT class construcion to fix up defaults.
Error prepareForConstruction();
@ -350,14 +350,14 @@ public:
return impl();
}
/// Set a TargetProcessControl object.
/// Set an ExecutorProcessControl object.
///
/// If the platform uses ObjectLinkingLayer by default and no
/// ObjectLinkingLayerCreator has been set then the TargetProcessControl
/// ObjectLinkingLayerCreator has been set then the ExecutorProcessControl
/// object will be used to supply the memory manager for the
/// ObjectLinkingLayer.
SetterImpl &setTargetProcessControl(TargetProcessControl &TPC) {
impl().TPC = &TPC;
SetterImpl &setExecutorProcessControl(ExecutorProcessControl &EPC) {
impl().EPC = &EPC;
return impl();
}

View File

@ -1,4 +1,4 @@
//===--- OrcRPCTargetProcessControl.h - Remote target control ---*- C++ -*-===//
//===-- OrcRPCExecutorProcessControl.h - Remote target control --*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -6,17 +6,17 @@
//
//===----------------------------------------------------------------------===//
//
// Utilities for interacting with target processes.
// Executor control via ORC RPC.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_EXECUTIONENGINE_ORC_ORCRPCTARGETPROCESSCONTROL_H
#define LLVM_EXECUTIONENGINE_ORC_ORCRPCTARGETPROCESSCONTROL_H
#ifndef LLVM_EXECUTIONENGINE_ORC_ORCRPCEXECUTORPROCESSCONTROL_H
#define LLVM_EXECUTIONENGINE_ORC_ORCRPCEXECUTORPROCESSCONTROL_H
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/Shared/RPCUtils.h"
#include "llvm/ExecutionEngine/Orc/Shared/RawByteChannel.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/OrcRPCTPCServer.h"
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
#include "llvm/Support/MSVCErrorWorkarounds.h"
namespace llvm {
@ -24,8 +24,8 @@ namespace orc {
/// JITLinkMemoryManager implementation for a process connected via an ORC RPC
/// endpoint.
template <typename OrcRPCTPCImplT>
class OrcRPCTPCJITLinkMemoryManager : public jitlink::JITLinkMemoryManager {
template <typename OrcRPCEPCImplT>
class OrcRPCEPCJITLinkMemoryManager : public jitlink::JITLinkMemoryManager {
private:
struct HostAlloc {
std::unique_ptr<char[]> Mem;
@ -43,7 +43,7 @@ private:
public:
class OrcRPCAllocation : public Allocation {
public:
OrcRPCAllocation(OrcRPCTPCJITLinkMemoryManager<OrcRPCTPCImplT> &Parent,
OrcRPCAllocation(OrcRPCEPCJITLinkMemoryManager<OrcRPCEPCImplT> &Parent,
HostAllocMap HostAllocs, TargetAllocMap TargetAllocs)
: Parent(Parent), HostAllocs(std::move(HostAllocs)),
TargetAllocs(std::move(TargetAllocs)) {
@ -140,12 +140,12 @@ public:
}
private:
OrcRPCTPCJITLinkMemoryManager<OrcRPCTPCImplT> &Parent;
OrcRPCEPCJITLinkMemoryManager<OrcRPCEPCImplT> &Parent;
HostAllocMap HostAllocs;
TargetAllocMap TargetAllocs;
};
OrcRPCTPCJITLinkMemoryManager(OrcRPCTPCImplT &Parent) : Parent(Parent) {}
OrcRPCEPCJITLinkMemoryManager(OrcRPCEPCImplT &Parent) : Parent(Parent) {}
Expected<std::unique_ptr<Allocation>>
allocate(const jitlink::JITLinkDylib *JD,
@ -216,19 +216,19 @@ public:
private:
void reportError(Error Err) { Parent.reportError(std::move(Err)); }
decltype(std::declval<OrcRPCTPCImplT>().getEndpoint()) getEndpoint() {
decltype(std::declval<OrcRPCEPCImplT>().getEndpoint()) getEndpoint() {
return Parent.getEndpoint();
}
OrcRPCTPCImplT &Parent;
OrcRPCEPCImplT &Parent;
};
/// TargetProcessControl::MemoryAccess implementation for a process connected
/// ExecutorProcessControl::MemoryAccess implementation for a process connected
/// via an ORC RPC endpoint.
template <typename OrcRPCTPCImplT>
class OrcRPCTPCMemoryAccess : public TargetProcessControl::MemoryAccess {
template <typename OrcRPCEPCImplT>
class OrcRPCEPCMemoryAccess : public ExecutorProcessControl::MemoryAccess {
public:
OrcRPCTPCMemoryAccess(OrcRPCTPCImplT &Parent) : Parent(Parent) {}
OrcRPCEPCMemoryAccess(OrcRPCEPCImplT &Parent) : Parent(Parent) {}
void writeUInt8s(ArrayRef<tpctypes::UInt8Write> Ws,
WriteResultFn OnWriteComplete) override {
@ -269,20 +269,20 @@ private:
}
}
OrcRPCTPCImplT &Parent;
OrcRPCEPCImplT &Parent;
};
// TargetProcessControl for a process connected via an ORC RPC Endpoint.
// ExecutorProcessControl for a process connected via an ORC RPC Endpoint.
template <typename RPCEndpointT>
class OrcRPCTargetProcessControlBase : public TargetProcessControl {
class OrcRPCExecutorProcessControlBase : public ExecutorProcessControl {
public:
using ErrorReporter = unique_function<void(Error)>;
using OnCloseConnectionFunction = unique_function<Error(Error)>;
OrcRPCTargetProcessControlBase(std::shared_ptr<SymbolStringPool> SSP,
RPCEndpointT &EP, ErrorReporter ReportError)
: TargetProcessControl(std::move(SSP)),
OrcRPCExecutorProcessControlBase(std::shared_ptr<SymbolStringPool> SSP,
RPCEndpointT &EP, ErrorReporter ReportError)
: ExecutorProcessControl(std::move(SSP)),
ReportError(std::move(ReportError)), EP(EP) {}
void reportError(Error Err) { ReportError(std::move(Err)); }
@ -391,7 +391,7 @@ public:
protected:
/// Subclasses must call this during construction to initialize the
/// TargetTriple and PageSize members.
Error initializeORCRPCTPCBase() {
Error initializeORCRPCEPCBase() {
if (auto TripleOrErr = EP.template callB<orcrpctpc::GetTargetTriple>())
TargetTriple = Triple(*TripleOrErr);
else
@ -413,4 +413,4 @@ private:
} // end namespace orc
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_ORCRPCTARGETPROCESSCONTROL_H
#endif // LLVM_EXECUTIONENGINE_ORC_ORCRPCEXECUTORPROCESSCONTROL_H

View File

@ -4,6 +4,10 @@ add_llvm_component_library(LLVMOrcJIT
Core.cpp
DebugObjectManagerPlugin.cpp
DebugUtils.cpp
EPCDynamicLibrarySearchGenerator.cpp
EPCDebugObjectRegistrar.cpp
EPCEHFrameRegistrar.cpp
EPCIndirectionUtils.cpp
ExecutionUtils.cpp
IndirectionUtils.cpp
IRCompileLayer.cpp
@ -21,12 +25,8 @@ add_llvm_component_library(LLVMOrcJIT
RTDyldObjectLinkingLayer.cpp
Speculation.cpp
SpeculateAnalyses.cpp
TargetProcessControl.cpp
ExecutorProcessControl.cpp
ThreadSafeModule.cpp
TPCDebugObjectRegistrar.cpp
TPCDynamicLibrarySearchGenerator.cpp
TPCEHFrameRegistrar.cpp
TPCIndirectionUtils.cpp
ADDITIONAL_HEADER_DIRS
${LLVM_MAIN_INCLUDE_DIR}/llvm/ExecutionEngine/Orc

View File

@ -1,4 +1,4 @@
//===----- TPCDebugObjectRegistrar.cpp - TPC-based debug registration -----===//
//===----- EPCDebugObjectRegistrar.cpp - EPC-based debug registration -----===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h"
#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
@ -15,21 +15,21 @@
namespace llvm {
namespace orc {
Expected<std::unique_ptr<TPCDebugObjectRegistrar>>
createJITLoaderGDBRegistrar(TargetProcessControl &TPC) {
auto ProcessHandle = TPC.loadDylib(nullptr);
Expected<std::unique_ptr<EPCDebugObjectRegistrar>>
createJITLoaderGDBRegistrar(ExecutorProcessControl &EPC) {
auto ProcessHandle = EPC.loadDylib(nullptr);
if (!ProcessHandle)
return ProcessHandle.takeError();
SymbolStringPtr RegisterFn =
TPC.getTargetTriple().isOSBinFormatMachO()
? TPC.intern("_llvm_orc_registerJITLoaderGDBWrapper")
: TPC.intern("llvm_orc_registerJITLoaderGDBWrapper");
EPC.getTargetTriple().isOSBinFormatMachO()
? EPC.intern("_llvm_orc_registerJITLoaderGDBWrapper")
: EPC.intern("llvm_orc_registerJITLoaderGDBWrapper");
SymbolLookupSet RegistrationSymbols;
RegistrationSymbols.add(RegisterFn);
auto Result = TPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}});
auto Result = EPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}});
if (!Result)
return Result.takeError();
@ -37,7 +37,7 @@ createJITLoaderGDBRegistrar(TargetProcessControl &TPC) {
assert((*Result)[0].size() == 1 &&
"Unexpected number of addresses in result");
return std::make_unique<TPCDebugObjectRegistrar>(TPC, (*Result)[0][0]);
return std::make_unique<EPCDebugObjectRegistrar>(EPC, (*Result)[0][0]);
}
} // namespace orc

View File

@ -1,4 +1,4 @@
//===---------------- TPCDynamicLibrarySearchGenerator.cpp ----------------===//
//===---------------- EPCDynamicLibrarySearchGenerator.cpp ----------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -6,24 +6,24 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h"
#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"
namespace llvm {
namespace orc {
Expected<std::unique_ptr<TPCDynamicLibrarySearchGenerator>>
TPCDynamicLibrarySearchGenerator::Load(TargetProcessControl &TPC,
Expected<std::unique_ptr<EPCDynamicLibrarySearchGenerator>>
EPCDynamicLibrarySearchGenerator::Load(ExecutorProcessControl &EPC,
const char *LibraryPath,
SymbolPredicate Allow) {
auto Handle = TPC.loadDylib(LibraryPath);
auto Handle = EPC.loadDylib(LibraryPath);
if (!Handle)
return Handle.takeError();
return std::make_unique<TPCDynamicLibrarySearchGenerator>(TPC, *Handle,
return std::make_unique<EPCDynamicLibrarySearchGenerator>(EPC, *Handle,
std::move(Allow));
}
Error TPCDynamicLibrarySearchGenerator::tryToGenerate(
Error EPCDynamicLibrarySearchGenerator::tryToGenerate(
LookupState &LS, LookupKind K, JITDylib &JD,
JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) {
@ -41,8 +41,8 @@ Error TPCDynamicLibrarySearchGenerator::tryToGenerate(
SymbolMap NewSymbols;
TargetProcessControl::LookupRequest Request(H, LookupSymbols);
auto Result = TPC.lookupSymbols(Request);
ExecutorProcessControl::LookupRequest Request(H, LookupSymbols);
auto Result = EPC.lookupSymbols(Request);
if (!Result)
return Result.takeError();

View File

@ -1,4 +1,4 @@
//===------ TPCEHFrameRegistrar.cpp - TPC-based eh-frame registration -----===//
//===------ EPCEHFrameRegistrar.cpp - EPC-based eh-frame registration -----===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h"
#include "llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h"
#include "llvm/Support/BinaryStreamWriter.h"
using namespace llvm::orc::shared;
@ -14,19 +14,19 @@ using namespace llvm::orc::shared;
namespace llvm {
namespace orc {
Expected<std::unique_ptr<TPCEHFrameRegistrar>>
TPCEHFrameRegistrar::Create(TargetProcessControl &TPC) {
Expected<std::unique_ptr<EPCEHFrameRegistrar>>
EPCEHFrameRegistrar::Create(ExecutorProcessControl &EPC) {
// FIXME: Proper mangling here -- we really need to decouple linker mangling
// from DataLayout.
// Find the addresses of the registration/deregistration functions in the
// target process.
auto ProcessHandle = TPC.loadDylib(nullptr);
// executor process.
auto ProcessHandle = EPC.loadDylib(nullptr);
if (!ProcessHandle)
return ProcessHandle.takeError();
std::string RegisterWrapperName, DeregisterWrapperName;
if (TPC.getTargetTriple().isOSBinFormatMachO()) {
if (EPC.getTargetTriple().isOSBinFormatMachO()) {
RegisterWrapperName += '_';
DeregisterWrapperName += '_';
}
@ -34,10 +34,10 @@ TPCEHFrameRegistrar::Create(TargetProcessControl &TPC) {
DeregisterWrapperName += "llvm_orc_deregisterEHFrameSectionWrapper";
SymbolLookupSet RegistrationSymbols;
RegistrationSymbols.add(TPC.intern(RegisterWrapperName));
RegistrationSymbols.add(TPC.intern(DeregisterWrapperName));
RegistrationSymbols.add(EPC.intern(RegisterWrapperName));
RegistrationSymbols.add(EPC.intern(DeregisterWrapperName));
auto Result = TPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}});
auto Result = EPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}});
if (!Result)
return Result.takeError();
@ -48,22 +48,22 @@ TPCEHFrameRegistrar::Create(TargetProcessControl &TPC) {
auto RegisterEHFrameWrapperFnAddr = (*Result)[0][0];
auto DeregisterEHFrameWrapperFnAddr = (*Result)[0][1];
return std::make_unique<TPCEHFrameRegistrar>(
TPC, RegisterEHFrameWrapperFnAddr, DeregisterEHFrameWrapperFnAddr);
return std::make_unique<EPCEHFrameRegistrar>(
EPC, RegisterEHFrameWrapperFnAddr, DeregisterEHFrameWrapperFnAddr);
}
Error TPCEHFrameRegistrar::registerEHFrames(JITTargetAddress EHFrameSectionAddr,
Error EPCEHFrameRegistrar::registerEHFrames(JITTargetAddress EHFrameSectionAddr,
size_t EHFrameSectionSize) {
return WrapperFunction<void(SPSTargetAddress, uint64_t)>::call(
TPCCaller(TPC, RegisterEHFrameWrapperFnAddr), EHFrameSectionAddr,
EPCCaller(EPC, RegisterEHFrameWrapperFnAddr), EHFrameSectionAddr,
static_cast<uint64_t>(EHFrameSectionSize));
}
Error TPCEHFrameRegistrar::deregisterEHFrames(
Error EPCEHFrameRegistrar::deregisterEHFrames(
JITTargetAddress EHFrameSectionAddr, size_t EHFrameSectionSize) {
return WrapperFunction<void(SPSTargetAddress, uint64_t)>::call(
TPCCaller(TPC, DeregisterEHFrameWrapperFnAddr), EHFrameSectionAddr,
EPCCaller(EPC, DeregisterEHFrameWrapperFnAddr), EHFrameSectionAddr,
static_cast<uint64_t>(EHFrameSectionSize));
}

View File

@ -1,4 +1,4 @@
//===------ TargetProcessControl.cpp -- Target process control APIs -------===//
//===------- EPCIndirectionUtils.cpp -- EPC based indirection APIs --------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/Orc/TPCIndirectionUtils.h"
#include "llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h"
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/Support/MathExtras.h"
#include <future>
@ -19,14 +19,14 @@ using namespace llvm::orc;
namespace llvm {
namespace orc {
class TPCIndirectionUtilsAccess {
class EPCIndirectionUtilsAccess {
public:
using IndirectStubInfo = TPCIndirectionUtils::IndirectStubInfo;
using IndirectStubInfoVector = TPCIndirectionUtils::IndirectStubInfoVector;
using IndirectStubInfo = EPCIndirectionUtils::IndirectStubInfo;
using IndirectStubInfoVector = EPCIndirectionUtils::IndirectStubInfoVector;
static Expected<IndirectStubInfoVector>
getIndirectStubs(TPCIndirectionUtils &TPCIU, unsigned NumStubs) {
return TPCIU.getIndirectStubs(NumStubs);
getIndirectStubs(EPCIndirectionUtils &EPCIU, unsigned NumStubs) {
return EPCIU.getIndirectStubs(NumStubs);
};
};
@ -35,9 +35,9 @@ public:
namespace {
class TPCTrampolinePool : public TrampolinePool {
class EPCTrampolinePool : public TrampolinePool {
public:
TPCTrampolinePool(TPCIndirectionUtils &TPCIU);
EPCTrampolinePool(EPCIndirectionUtils &EPCIU);
Error deallocatePool();
protected:
@ -45,16 +45,16 @@ protected:
using Allocation = jitlink::JITLinkMemoryManager::Allocation;
TPCIndirectionUtils &TPCIU;
EPCIndirectionUtils &EPCIU;
unsigned TrampolineSize = 0;
unsigned TrampolinesPerPage = 0;
std::vector<std::unique_ptr<Allocation>> TrampolineBlocks;
};
class TPCIndirectStubsManager : public IndirectStubsManager,
private TPCIndirectionUtilsAccess {
class EPCIndirectStubsManager : public IndirectStubsManager,
private EPCIndirectionUtilsAccess {
public:
TPCIndirectStubsManager(TPCIndirectionUtils &TPCIU) : TPCIU(TPCIU) {}
EPCIndirectStubsManager(EPCIndirectionUtils &EPCIU) : EPCIU(EPCIU) {}
Error deallocateStubs();
@ -73,43 +73,43 @@ private:
using StubInfo = std::pair<IndirectStubInfo, JITSymbolFlags>;
std::mutex ISMMutex;
TPCIndirectionUtils &TPCIU;
EPCIndirectionUtils &EPCIU;
StringMap<StubInfo> StubInfos;
};
TPCTrampolinePool::TPCTrampolinePool(TPCIndirectionUtils &TPCIU)
: TPCIU(TPCIU) {
auto &TPC = TPCIU.getTargetProcessControl();
auto &ABI = TPCIU.getABISupport();
EPCTrampolinePool::EPCTrampolinePool(EPCIndirectionUtils &EPCIU)
: EPCIU(EPCIU) {
auto &EPC = EPCIU.getExecutorProcessControl();
auto &ABI = EPCIU.getABISupport();
TrampolineSize = ABI.getTrampolineSize();
TrampolinesPerPage =
(TPC.getPageSize() - ABI.getPointerSize()) / TrampolineSize;
(EPC.getPageSize() - ABI.getPointerSize()) / TrampolineSize;
}
Error TPCTrampolinePool::deallocatePool() {
Error EPCTrampolinePool::deallocatePool() {
Error Err = Error::success();
for (auto &Alloc : TrampolineBlocks)
Err = joinErrors(std::move(Err), Alloc->deallocate());
return Err;
}
Error TPCTrampolinePool::grow() {
Error EPCTrampolinePool::grow() {
assert(AvailableTrampolines.empty() &&
"Grow called with trampolines still available");
auto ResolverAddress = TPCIU.getResolverBlockAddress();
auto ResolverAddress = EPCIU.getResolverBlockAddress();
assert(ResolverAddress && "Resolver address can not be null");
auto &TPC = TPCIU.getTargetProcessControl();
auto &EPC = EPCIU.getExecutorProcessControl();
constexpr auto TrampolinePagePermissions =
static_cast<sys::Memory::ProtectionFlags>(sys::Memory::MF_READ |
sys::Memory::MF_EXEC);
auto PageSize = TPC.getPageSize();
auto PageSize = EPC.getPageSize();
jitlink::JITLinkMemoryManager::SegmentsRequestMap Request;
Request[TrampolinePagePermissions] = {PageSize, static_cast<size_t>(PageSize),
0};
auto Alloc = TPC.getMemMgr().allocate(nullptr, Request);
auto Alloc = EPC.getMemMgr().allocate(nullptr, Request);
if (!Alloc)
return Alloc.takeError();
@ -119,7 +119,7 @@ Error TPCTrampolinePool::grow() {
auto WorkingMemory = (*Alloc)->getWorkingMemory(TrampolinePagePermissions);
auto TargetAddress = (*Alloc)->getTargetMemory(TrampolinePagePermissions);
TPCIU.getABISupport().writeTrampolines(WorkingMemory.data(), TargetAddress,
EPCIU.getABISupport().writeTrampolines(WorkingMemory.data(), TargetAddress,
ResolverAddress, NumTrampolines);
auto TargetAddr = (*Alloc)->getTargetMemory(TrampolinePagePermissions);
@ -134,7 +134,7 @@ Error TPCTrampolinePool::grow() {
return Error::success();
}
Error TPCIndirectStubsManager::createStub(StringRef StubName,
Error EPCIndirectStubsManager::createStub(StringRef StubName,
JITTargetAddress StubAddr,
JITSymbolFlags StubFlags) {
StubInitsMap SIM;
@ -142,8 +142,8 @@ Error TPCIndirectStubsManager::createStub(StringRef StubName,
return createStubs(SIM);
}
Error TPCIndirectStubsManager::createStubs(const StubInitsMap &StubInits) {
auto AvailableStubInfos = getIndirectStubs(TPCIU, StubInits.size());
Error EPCIndirectStubsManager::createStubs(const StubInitsMap &StubInits) {
auto AvailableStubInfos = getIndirectStubs(EPCIU, StubInits.size());
if (!AvailableStubInfos)
return AvailableStubInfos.takeError();
@ -156,8 +156,8 @@ Error TPCIndirectStubsManager::createStubs(const StubInitsMap &StubInits) {
}
}
auto &MemAccess = TPCIU.getTargetProcessControl().getMemoryAccess();
switch (TPCIU.getABISupport().getPointerSize()) {
auto &MemAccess = EPCIU.getExecutorProcessControl().getMemoryAccess();
switch (EPCIU.getABISupport().getPointerSize()) {
case 4: {
unsigned ASIdx = 0;
std::vector<tpctypes::UInt32Write> PtrUpdates;
@ -180,7 +180,7 @@ Error TPCIndirectStubsManager::createStubs(const StubInitsMap &StubInits) {
}
}
JITEvaluatedSymbol TPCIndirectStubsManager::findStub(StringRef Name,
JITEvaluatedSymbol EPCIndirectStubsManager::findStub(StringRef Name,
bool ExportedStubsOnly) {
std::lock_guard<std::mutex> Lock(ISMMutex);
auto I = StubInfos.find(Name);
@ -189,7 +189,7 @@ JITEvaluatedSymbol TPCIndirectStubsManager::findStub(StringRef Name,
return {I->second.first.StubAddress, I->second.second};
}
JITEvaluatedSymbol TPCIndirectStubsManager::findPointer(StringRef Name) {
JITEvaluatedSymbol EPCIndirectStubsManager::findPointer(StringRef Name) {
std::lock_guard<std::mutex> Lock(ISMMutex);
auto I = StubInfos.find(Name);
if (I == StubInfos.end())
@ -197,7 +197,7 @@ JITEvaluatedSymbol TPCIndirectStubsManager::findPointer(StringRef Name) {
return {I->second.first.PointerAddress, I->second.second};
}
Error TPCIndirectStubsManager::updatePointer(StringRef Name,
Error EPCIndirectStubsManager::updatePointer(StringRef Name,
JITTargetAddress NewAddr) {
JITTargetAddress PtrAddr = 0;
@ -210,8 +210,8 @@ Error TPCIndirectStubsManager::updatePointer(StringRef Name,
PtrAddr = I->second.first.PointerAddress;
}
auto &MemAccess = TPCIU.getTargetProcessControl().getMemoryAccess();
switch (TPCIU.getABISupport().getPointerSize()) {
auto &MemAccess = EPCIU.getExecutorProcessControl().getMemoryAccess();
switch (EPCIU.getABISupport().getPointerSize()) {
case 4: {
tpctypes::UInt32Write PUpdate(PtrAddr, NewAddr);
return MemAccess.writeUInt32s(PUpdate);
@ -231,42 +231,42 @@ Error TPCIndirectStubsManager::updatePointer(StringRef Name,
namespace llvm {
namespace orc {
TPCIndirectionUtils::ABISupport::~ABISupport() {}
EPCIndirectionUtils::ABISupport::~ABISupport() {}
Expected<std::unique_ptr<TPCIndirectionUtils>>
TPCIndirectionUtils::Create(TargetProcessControl &TPC) {
const auto &TT = TPC.getTargetTriple();
Expected<std::unique_ptr<EPCIndirectionUtils>>
EPCIndirectionUtils::Create(ExecutorProcessControl &EPC) {
const auto &TT = EPC.getTargetTriple();
switch (TT.getArch()) {
default:
return make_error<StringError>(
std::string("No TPCIndirectionUtils available for ") + TT.str(),
std::string("No EPCIndirectionUtils available for ") + TT.str(),
inconvertibleErrorCode());
case Triple::aarch64:
case Triple::aarch64_32:
return CreateWithABI<OrcAArch64>(TPC);
return CreateWithABI<OrcAArch64>(EPC);
case Triple::x86:
return CreateWithABI<OrcI386>(TPC);
return CreateWithABI<OrcI386>(EPC);
case Triple::mips:
return CreateWithABI<OrcMips32Be>(TPC);
return CreateWithABI<OrcMips32Be>(EPC);
case Triple::mipsel:
return CreateWithABI<OrcMips32Le>(TPC);
return CreateWithABI<OrcMips32Le>(EPC);
case Triple::mips64:
case Triple::mips64el:
return CreateWithABI<OrcMips64>(TPC);
return CreateWithABI<OrcMips64>(EPC);
case Triple::x86_64:
if (TT.getOS() == Triple::OSType::Win32)
return CreateWithABI<OrcX86_64_Win32>(TPC);
return CreateWithABI<OrcX86_64_Win32>(EPC);
else
return CreateWithABI<OrcX86_64_SysV>(TPC);
return CreateWithABI<OrcX86_64_SysV>(EPC);
}
}
Error TPCIndirectionUtils::cleanup() {
Error EPCIndirectionUtils::cleanup() {
Error Err = Error::success();
for (auto &A : IndirectStubAllocs)
@ -274,7 +274,7 @@ Error TPCIndirectionUtils::cleanup() {
if (TP)
Err = joinErrors(std::move(Err),
static_cast<TPCTrampolinePool &>(*TP).deallocatePool());
static_cast<EPCTrampolinePool &>(*TP).deallocatePool());
if (ResolverBlock)
Err = joinErrors(std::move(Err), ResolverBlock->deallocate());
@ -283,7 +283,7 @@ Error TPCIndirectionUtils::cleanup() {
}
Expected<JITTargetAddress>
TPCIndirectionUtils::writeResolverBlock(JITTargetAddress ReentryFnAddr,
EPCIndirectionUtils::writeResolverBlock(JITTargetAddress ReentryFnAddr,
JITTargetAddress ReentryCtxAddr) {
assert(ABI && "ABI can not be null");
constexpr auto ResolverBlockPermissions =
@ -292,9 +292,9 @@ TPCIndirectionUtils::writeResolverBlock(JITTargetAddress ReentryFnAddr,
auto ResolverSize = ABI->getResolverCodeSize();
jitlink::JITLinkMemoryManager::SegmentsRequestMap Request;
Request[ResolverBlockPermissions] = {TPC.getPageSize(),
Request[ResolverBlockPermissions] = {EPC.getPageSize(),
static_cast<size_t>(ResolverSize), 0};
auto Alloc = TPC.getMemMgr().allocate(nullptr, Request);
auto Alloc = EPC.getMemMgr().allocate(nullptr, Request);
if (!Alloc)
return Alloc.takeError();
@ -311,17 +311,17 @@ TPCIndirectionUtils::writeResolverBlock(JITTargetAddress ReentryFnAddr,
}
std::unique_ptr<IndirectStubsManager>
TPCIndirectionUtils::createIndirectStubsManager() {
return std::make_unique<TPCIndirectStubsManager>(*this);
EPCIndirectionUtils::createIndirectStubsManager() {
return std::make_unique<EPCIndirectStubsManager>(*this);
}
TrampolinePool &TPCIndirectionUtils::getTrampolinePool() {
TrampolinePool &EPCIndirectionUtils::getTrampolinePool() {
if (!TP)
TP = std::make_unique<TPCTrampolinePool>(*this);
TP = std::make_unique<EPCTrampolinePool>(*this);
return *TP;
}
LazyCallThroughManager &TPCIndirectionUtils::createLazyCallThroughManager(
LazyCallThroughManager &EPCIndirectionUtils::createLazyCallThroughManager(
ExecutionSession &ES, JITTargetAddress ErrorHandlerAddr) {
assert(!LCTM &&
"createLazyCallThroughManager can not have been called before");
@ -330,24 +330,24 @@ LazyCallThroughManager &TPCIndirectionUtils::createLazyCallThroughManager(
return *LCTM;
}
TPCIndirectionUtils::TPCIndirectionUtils(TargetProcessControl &TPC,
EPCIndirectionUtils::EPCIndirectionUtils(ExecutorProcessControl &EPC,
std::unique_ptr<ABISupport> ABI)
: TPC(TPC), ABI(std::move(ABI)) {
: EPC(EPC), ABI(std::move(ABI)) {
assert(this->ABI && "ABI can not be null");
assert(TPC.getPageSize() > getABISupport().getStubSize() &&
assert(EPC.getPageSize() > getABISupport().getStubSize() &&
"Stubs larger than one page are not supported");
}
Expected<TPCIndirectionUtils::IndirectStubInfoVector>
TPCIndirectionUtils::getIndirectStubs(unsigned NumStubs) {
Expected<EPCIndirectionUtils::IndirectStubInfoVector>
EPCIndirectionUtils::getIndirectStubs(unsigned NumStubs) {
std::lock_guard<std::mutex> Lock(TPCUIMutex);
std::lock_guard<std::mutex> Lock(EPCUIMutex);
// If there aren't enough stubs available then allocate some more.
if (NumStubs > AvailableIndirectStubs.size()) {
auto NumStubsToAllocate = NumStubs;
auto PageSize = TPC.getPageSize();
auto PageSize = EPC.getPageSize();
auto StubBytes = alignTo(NumStubsToAllocate * ABI->getStubSize(), PageSize);
NumStubsToAllocate = StubBytes / ABI->getStubSize();
auto PointerBytes =
@ -364,7 +364,7 @@ TPCIndirectionUtils::getIndirectStubs(unsigned NumStubs) {
Request[StubPagePermissions] = {PageSize, static_cast<size_t>(StubBytes),
0};
Request[PointerPagePermissions] = {PageSize, 0, PointerBytes};
auto Alloc = TPC.getMemMgr().allocate(nullptr, Request);
auto Alloc = EPC.getMemMgr().allocate(nullptr, Request);
if (!Alloc)
return Alloc.takeError();
@ -411,9 +411,9 @@ static JITTargetAddress reentry(JITTargetAddress LCTMAddr,
return LandingAddrF.get();
}
Error setUpInProcessLCTMReentryViaTPCIU(TPCIndirectionUtils &TPCIU) {
auto &LCTM = TPCIU.getLazyCallThroughManager();
return TPCIU
Error setUpInProcessLCTMReentryViaEPCIU(EPCIndirectionUtils &EPCIU) {
auto &LCTM = EPCIU.getLazyCallThroughManager();
return EPCIU
.writeResolverBlock(pointerToJITTargetAddress(&reentry),
pointerToJITTargetAddress(&LCTM))
.takeError();

View File

@ -1,4 +1,4 @@
//===------ TargetProcessControl.cpp -- Target process control APIs -------===//
//===---- ExecutorProcessControl.cpp -- Executor process control APIs -----===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/TargetExecutionUtils.h"
@ -18,14 +18,14 @@
namespace llvm {
namespace orc {
TargetProcessControl::MemoryAccess::~MemoryAccess() {}
ExecutorProcessControl::MemoryAccess::~MemoryAccess() {}
TargetProcessControl::~TargetProcessControl() {}
ExecutorProcessControl::~ExecutorProcessControl() {}
SelfTargetProcessControl::SelfTargetProcessControl(
SelfExecutorProcessControl::SelfExecutorProcessControl(
std::shared_ptr<SymbolStringPool> SSP, Triple TargetTriple,
unsigned PageSize, std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr)
: TargetProcessControl(std::move(SSP)) {
: ExecutorProcessControl(std::move(SSP)) {
OwnedMemMgr = std::move(MemMgr);
if (!OwnedMemMgr)
@ -39,8 +39,8 @@ SelfTargetProcessControl::SelfTargetProcessControl(
GlobalManglingPrefix = '_';
}
Expected<std::unique_ptr<SelfTargetProcessControl>>
SelfTargetProcessControl::Create(
Expected<std::unique_ptr<SelfExecutorProcessControl>>
SelfExecutorProcessControl::Create(
std::shared_ptr<SymbolStringPool> SSP,
std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr) {
auto PageSize = sys::Process::getPageSize();
@ -49,12 +49,12 @@ SelfTargetProcessControl::Create(
Triple TT(sys::getProcessTriple());
return std::make_unique<SelfTargetProcessControl>(
return std::make_unique<SelfExecutorProcessControl>(
std::move(SSP), std::move(TT), *PageSize, std::move(MemMgr));
}
Expected<tpctypes::DylibHandle>
SelfTargetProcessControl::loadDylib(const char *DylibPath) {
SelfExecutorProcessControl::loadDylib(const char *DylibPath) {
std::string ErrMsg;
auto Dylib = std::make_unique<sys::DynamicLibrary>(
sys::DynamicLibrary::getPermanentLibrary(DylibPath, &ErrMsg));
@ -65,7 +65,7 @@ SelfTargetProcessControl::loadDylib(const char *DylibPath) {
}
Expected<std::vector<tpctypes::LookupResult>>
SelfTargetProcessControl::lookupSymbols(ArrayRef<LookupRequest> Request) {
SelfExecutorProcessControl::lookupSymbols(ArrayRef<LookupRequest> Request) {
std::vector<tpctypes::LookupResult> R;
for (auto &Elem : Request) {
@ -96,53 +96,53 @@ SelfTargetProcessControl::lookupSymbols(ArrayRef<LookupRequest> Request) {
}
Expected<int32_t>
SelfTargetProcessControl::runAsMain(JITTargetAddress MainFnAddr,
ArrayRef<std::string> Args) {
SelfExecutorProcessControl::runAsMain(JITTargetAddress MainFnAddr,
ArrayRef<std::string> Args) {
using MainTy = int (*)(int, char *[]);
return orc::runAsMain(jitTargetAddressToFunction<MainTy>(MainFnAddr), Args);
}
Expected<shared::WrapperFunctionResult>
SelfTargetProcessControl::runWrapper(JITTargetAddress WrapperFnAddr,
ArrayRef<char> ArgBuffer) {
SelfExecutorProcessControl::runWrapper(JITTargetAddress WrapperFnAddr,
ArrayRef<char> ArgBuffer) {
using WrapperFnTy = shared::detail::CWrapperFunctionResult (*)(
const char *Data, uint64_t Size);
auto *WrapperFn = jitTargetAddressToFunction<WrapperFnTy>(WrapperFnAddr);
return WrapperFn(ArgBuffer.data(), ArgBuffer.size());
}
Error SelfTargetProcessControl::disconnect() { return Error::success(); }
Error SelfExecutorProcessControl::disconnect() { return Error::success(); }
void SelfTargetProcessControl::writeUInt8s(ArrayRef<tpctypes::UInt8Write> Ws,
WriteResultFn OnWriteComplete) {
void SelfExecutorProcessControl::writeUInt8s(ArrayRef<tpctypes::UInt8Write> Ws,
WriteResultFn OnWriteComplete) {
for (auto &W : Ws)
*jitTargetAddressToPointer<uint8_t *>(W.Address) = W.Value;
OnWriteComplete(Error::success());
}
void SelfTargetProcessControl::writeUInt16s(ArrayRef<tpctypes::UInt16Write> Ws,
WriteResultFn OnWriteComplete) {
void SelfExecutorProcessControl::writeUInt16s(
ArrayRef<tpctypes::UInt16Write> Ws, WriteResultFn OnWriteComplete) {
for (auto &W : Ws)
*jitTargetAddressToPointer<uint16_t *>(W.Address) = W.Value;
OnWriteComplete(Error::success());
}
void SelfTargetProcessControl::writeUInt32s(ArrayRef<tpctypes::UInt32Write> Ws,
WriteResultFn OnWriteComplete) {
void SelfExecutorProcessControl::writeUInt32s(
ArrayRef<tpctypes::UInt32Write> Ws, WriteResultFn OnWriteComplete) {
for (auto &W : Ws)
*jitTargetAddressToPointer<uint32_t *>(W.Address) = W.Value;
OnWriteComplete(Error::success());
}
void SelfTargetProcessControl::writeUInt64s(ArrayRef<tpctypes::UInt64Write> Ws,
WriteResultFn OnWriteComplete) {
void SelfExecutorProcessControl::writeUInt64s(
ArrayRef<tpctypes::UInt64Write> Ws, WriteResultFn OnWriteComplete) {
for (auto &W : Ws)
*jitTargetAddressToPointer<uint64_t *>(W.Address) = W.Value;
OnWriteComplete(Error::success());
}
void SelfTargetProcessControl::writeBuffers(ArrayRef<tpctypes::BufferWrite> Ws,
WriteResultFn OnWriteComplete) {
void SelfExecutorProcessControl::writeBuffers(
ArrayRef<tpctypes::BufferWrite> Ws, WriteResultFn OnWriteComplete) {
for (auto &W : Ws)
memcpy(jitTargetAddressToPointer<char *>(W.Address), W.Buffer.data(),
W.Buffer.size());

View File

@ -9,12 +9,12 @@
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
#include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h"
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/MachOPlatform.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/Shared/OrcError.h"
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
@ -976,13 +976,13 @@ Error LLJITBuilderState::prepareForConstruction() {
JTMB->setRelocationModel(Reloc::PIC_);
JTMB->setCodeModel(CodeModel::Small);
CreateObjectLinkingLayer =
[TPC = this->TPC](
[EPC = this->EPC](
ExecutionSession &ES,
const Triple &) -> Expected<std::unique_ptr<ObjectLayer>> {
std::unique_ptr<ObjectLinkingLayer> ObjLinkingLayer;
if (TPC)
if (EPC)
ObjLinkingLayer =
std::make_unique<ObjectLinkingLayer>(ES, TPC->getMemMgr());
std::make_unique<ObjectLinkingLayer>(ES, EPC->getMemMgr());
else
ObjLinkingLayer = std::make_unique<ObjectLinkingLayer>(
ES, std::make_unique<jitlink::InProcessMemoryManager>());

View File

@ -22,12 +22,14 @@
#include "llvm/Config/llvm-config.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/JITEventListener.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/MCJIT.h"
#include "llvm/ExecutionEngine/ObjectCache.h"
#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
#include "llvm/ExecutionEngine/Orc/DebugUtils.h"
#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h"
#include "llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
@ -35,8 +37,6 @@
#include "llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h"
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
#include "llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h"
#include "llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/TargetExecutionUtils.h"
@ -936,18 +936,18 @@ int runOrcJIT(const char *ProgName) {
}
}
std::unique_ptr<orc::TargetProcessControl> TPC = nullptr;
std::unique_ptr<orc::ExecutorProcessControl> EPC = nullptr;
if (JITLinker == JITLinkerKind::JITLink) {
TPC = ExitOnErr(orc::SelfTargetProcessControl::Create(
EPC = ExitOnErr(orc::SelfExecutorProcessControl::Create(
std::make_shared<orc::SymbolStringPool>()));
Builder.setObjectLinkingLayerCreator([&TPC](orc::ExecutionSession &ES,
Builder.setObjectLinkingLayerCreator([&EPC](orc::ExecutionSession &ES,
const Triple &) {
auto L = std::make_unique<orc::ObjectLinkingLayer>(ES, TPC->getMemMgr());
auto L = std::make_unique<orc::ObjectLinkingLayer>(ES, EPC->getMemMgr());
L->addPlugin(std::make_unique<orc::EHFrameRegistrationPlugin>(
ES, ExitOnErr(orc::TPCEHFrameRegistrar::Create(*TPC))));
ES, ExitOnErr(orc::EPCEHFrameRegistrar::Create(*EPC))));
L->addPlugin(std::make_unique<orc::DebugObjectManagerPlugin>(
ES, ExitOnErr(orc::createJITLoaderGDBRegistrar(*TPC))));
ES, ExitOnErr(orc::createJITLoaderGDBRegistrar(*EPC))));
return L;
});
}
@ -1069,9 +1069,9 @@ int runOrcJIT(const char *ProgName) {
JITEvaluatedSymbol MainSym = ExitOnErr(J->lookup(EntryFunc));
int Result;
if (TPC) {
// TargetProcessControl-based execution with JITLink.
Result = ExitOnErr(TPC->runAsMain(MainSym.getAddress(), InputArgv));
if (EPC) {
// ExecutorProcessControl-based execution with JITLink.
Result = ExitOnErr(EPC->runAsMain(MainSym.getAddress(), InputArgv));
} else {
// Manual in-process execution with RuntimeDyld.
using MainFnTy = int(int, char *[]);

View File

@ -16,10 +16,10 @@
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h"
#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"
#include "llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h"
#include "llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h"
#include "llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h"
#include "llvm/MC/MCAsmInfo.h"
@ -588,8 +588,8 @@ Error LLVMJITLinkObjectLinkingLayer::add(ResourceTrackerSP RT,
return JD.define(std::move(MU), std::move(RT));
}
Expected<std::unique_ptr<TargetProcessControl>>
LLVMJITLinkRemoteTargetProcessControl::LaunchExecutor() {
Expected<std::unique_ptr<ExecutorProcessControl>>
LLVMJITLinkRemoteExecutorProcessControl::LaunchExecutor() {
#ifndef LLVM_ON_UNIX
// FIXME: Add support for Windows.
return make_error<StringError>("-" + OutOfProcessExecutor.ArgStr +
@ -661,13 +661,13 @@ LLVMJITLinkRemoteTargetProcessControl::LaunchExecutor() {
};
Error Err = Error::success();
std::unique_ptr<LLVMJITLinkRemoteTargetProcessControl> RTPC(
new LLVMJITLinkRemoteTargetProcessControl(
std::unique_ptr<LLVMJITLinkRemoteExecutorProcessControl> REPC(
new LLVMJITLinkRemoteExecutorProcessControl(
std::move(SSP), std::move(Channel), std::move(Endpoint),
std::move(ReportError), Err));
if (Err)
return std::move(Err);
return std::move(RTPC);
return std::move(REPC);
#endif
}
@ -717,8 +717,8 @@ static Expected<int> connectTCPSocket(std::string Host, std::string PortStr) {
}
#endif
Expected<std::unique_ptr<TargetProcessControl>>
LLVMJITLinkRemoteTargetProcessControl::ConnectToExecutor() {
Expected<std::unique_ptr<ExecutorProcessControl>>
LLVMJITLinkRemoteExecutorProcessControl::ConnectToExecutor() {
#ifndef LLVM_ON_UNIX
// FIXME: Add TCP support for Windows.
return make_error<StringError>("-" + OutOfProcessExecutorConnect.ArgStr +
@ -756,17 +756,17 @@ LLVMJITLinkRemoteTargetProcessControl::ConnectToExecutor() {
};
Error Err = Error::success();
std::unique_ptr<LLVMJITLinkRemoteTargetProcessControl> RTPC(
new LLVMJITLinkRemoteTargetProcessControl(
std::unique_ptr<LLVMJITLinkRemoteExecutorProcessControl> REPC(
new LLVMJITLinkRemoteExecutorProcessControl(
std::move(SSP), std::move(Channel), std::move(Endpoint),
std::move(ReportError), Err));
if (Err)
return std::move(Err);
return std::move(RTPC);
return std::move(REPC);
#endif
}
Error LLVMJITLinkRemoteTargetProcessControl::disconnect() {
Error LLVMJITLinkRemoteExecutorProcessControl::disconnect() {
std::promise<MSVCPError> P;
auto F = P.get_future();
auto Err = closeConnection([&](Error Err) -> Error {
@ -797,24 +797,25 @@ Expected<std::unique_ptr<Session>> Session::Create(Triple TT) {
return PageSize.takeError();
/// If -oop-executor is passed then launch the executor.
std::unique_ptr<TargetProcessControl> TPC;
std::unique_ptr<ExecutorProcessControl> EPC;
if (OutOfProcessExecutor.getNumOccurrences()) {
if (auto RTPC = LLVMJITLinkRemoteTargetProcessControl::LaunchExecutor())
TPC = std::move(*RTPC);
if (auto REPC = LLVMJITLinkRemoteExecutorProcessControl::LaunchExecutor())
EPC = std::move(*REPC);
else
return RTPC.takeError();
return REPC.takeError();
} else if (OutOfProcessExecutorConnect.getNumOccurrences()) {
if (auto RTPC = LLVMJITLinkRemoteTargetProcessControl::ConnectToExecutor())
TPC = std::move(*RTPC);
if (auto REPC =
LLVMJITLinkRemoteExecutorProcessControl::ConnectToExecutor())
EPC = std::move(*REPC);
else
return RTPC.takeError();
return REPC.takeError();
} else
TPC = std::make_unique<SelfTargetProcessControl>(
EPC = std::make_unique<SelfExecutorProcessControl>(
std::make_shared<SymbolStringPool>(), std::move(TT), *PageSize,
createMemoryManager());
Error Err = Error::success();
std::unique_ptr<Session> S(new Session(std::move(TPC), Err));
std::unique_ptr<Session> S(new Session(std::move(EPC), Err));
if (Err)
return std::move(Err);
return std::move(S);
@ -827,8 +828,8 @@ Session::~Session() {
// FIXME: Move to createJITDylib if/when we start using Platform support in
// llvm-jitlink.
Session::Session(std::unique_ptr<TargetProcessControl> TPC, Error &Err)
: TPC(std::move(TPC)), ObjLayer(*this, this->TPC->getMemMgr()) {
Session::Session(std::unique_ptr<ExecutorProcessControl> EPC, Error &Err)
: EPC(std::move(EPC)), ObjLayer(*this, this->EPC->getMemMgr()) {
/// Local ObjectLinkingLayer::Plugin class to forward modifyPassConfig to the
/// Session.
@ -862,11 +863,11 @@ Session::Session(std::unique_ptr<TargetProcessControl> TPC, Error &Err)
return;
}
if (!NoExec && !this->TPC->getTargetTriple().isOSWindows()) {
if (!NoExec && !this->EPC->getTargetTriple().isOSWindows()) {
ObjLayer.addPlugin(std::make_unique<EHFrameRegistrationPlugin>(
ES, ExitOnErr(TPCEHFrameRegistrar::Create(*this->TPC))));
ES, ExitOnErr(EPCEHFrameRegistrar::Create(*this->EPC))));
ObjLayer.addPlugin(std::make_unique<DebugObjectManagerPlugin>(
ES, ExitOnErr(createJITLoaderGDBRegistrar(*this->TPC))));
ES, ExitOnErr(createJITLoaderGDBRegistrar(*this->EPC))));
}
ObjLayer.addPlugin(std::make_unique<JITLinkSessionPlugin>(*this));
@ -913,10 +914,10 @@ void Session::modifyPassConfig(const Triple &TT,
PassConfiguration &PassConfig) {
if (!CheckFiles.empty())
PassConfig.PostFixupPasses.push_back([this](LinkGraph &G) {
if (TPC->getTargetTriple().getObjectFormat() == Triple::ELF)
if (EPC->getTargetTriple().getObjectFormat() == Triple::ELF)
return registerELFGraphInfo(*this, G);
if (TPC->getTargetTriple().getObjectFormat() == Triple::MachO)
if (EPC->getTargetTriple().getObjectFormat() == Triple::MachO)
return registerMachOGraphInfo(*this, G);
return make_error<StringError>("Unsupported object format for GOT/stub "
@ -1094,15 +1095,15 @@ static Error loadProcessSymbols(Session &S) {
return Name != EPName;
};
S.MainJD->addGenerator(
ExitOnErr(orc::TPCDynamicLibrarySearchGenerator::GetForTargetProcess(
*S.TPC, std::move(FilterMainEntryPoint))));
ExitOnErr(orc::EPCDynamicLibrarySearchGenerator::GetForTargetProcess(
*S.EPC, std::move(FilterMainEntryPoint))));
return Error::success();
}
static Error loadDylibs(Session &S) {
for (const auto &Dylib : Dylibs) {
auto G = orc::TPCDynamicLibrarySearchGenerator::Load(*S.TPC, Dylib.c_str());
auto G = orc::EPCDynamicLibrarySearchGenerator::Load(*S.EPC, Dylib.c_str());
if (!G)
return G.takeError();
S.MainJD->addGenerator(std::move(*G));
@ -1178,7 +1179,7 @@ static Error loadObjects(Session &S) {
if (Magic == file_magic::archive ||
Magic == file_magic::macho_universal_binary)
JD.addGenerator(ExitOnErr(StaticLibraryDefinitionGenerator::Load(
S.ObjLayer, InputFile.c_str(), S.TPC->getTargetTriple())));
S.ObjLayer, InputFile.c_str(), S.EPC->getTargetTriple())));
else
ExitOnErr(S.ObjLayer.add(JD, std::move(ObjBuffer)));
}
@ -1226,7 +1227,7 @@ static Error loadObjects(Session &S) {
static Error runChecks(Session &S) {
auto TripleName = S.TPC->getTargetTriple().str();
auto TripleName = S.EPC->getTargetTriple().str();
std::string ErrorStr;
const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, ErrorStr);
if (!TheTarget)
@ -1292,7 +1293,7 @@ static Error runChecks(Session &S) {
RuntimeDyldChecker Checker(
IsSymbolValid, GetSymbolInfo, GetSectionInfo, GetStubInfo, GetGOTInfo,
S.TPC->getTargetTriple().isLittleEndian() ? support::little
S.EPC->getTargetTriple().isLittleEndian() ? support::little
: support::big,
Disassembler.get(), InstPrinter.get(), dbgs());
@ -1381,11 +1382,11 @@ int main(int argc, char *argv[]) {
int Result = 0;
{
TimeRegion TR(Timers ? &Timers->RunTimer : nullptr);
Result = ExitOnErr(S->TPC->runAsMain(EntryPoint.getAddress(), InputArgv));
Result = ExitOnErr(S->EPC->runAsMain(EntryPoint.getAddress(), InputArgv));
}
ExitOnErr(S->ES.endSession());
ExitOnErr(S->TPC->disconnect());
ExitOnErr(S->EPC->disconnect());
return Result;
}

View File

@ -17,11 +17,11 @@
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Triple.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h"
#include "llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/Shared/FDRawByteChannel.h"
#include "llvm/ExecutionEngine/Orc/Shared/RPCUtils.h"
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
#include "llvm/ExecutionEngine/RuntimeDyldChecker.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Regex.h"
@ -52,26 +52,26 @@ using LLVMJITLinkChannel = orc::shared::FDRawByteChannel;
using LLVMJITLinkRPCEndpoint =
orc::shared::MultiThreadedRPCEndpoint<LLVMJITLinkChannel>;
using LLVMJITLinkRemoteMemoryAccess =
orc::OrcRPCTPCMemoryAccess<LLVMJITLinkRPCEndpoint>;
orc::OrcRPCEPCMemoryAccess<LLVMJITLinkRPCEndpoint>;
class LLVMJITLinkRemoteTargetProcessControl
: public orc::OrcRPCTargetProcessControlBase<LLVMJITLinkRPCEndpoint> {
class LLVMJITLinkRemoteExecutorProcessControl
: public orc::OrcRPCExecutorProcessControlBase<LLVMJITLinkRPCEndpoint> {
public:
using BaseT = orc::OrcRPCTargetProcessControlBase<LLVMJITLinkRPCEndpoint>;
static Expected<std::unique_ptr<TargetProcessControl>> LaunchExecutor();
using BaseT = orc::OrcRPCExecutorProcessControlBase<LLVMJITLinkRPCEndpoint>;
static Expected<std::unique_ptr<ExecutorProcessControl>> LaunchExecutor();
static Expected<std::unique_ptr<TargetProcessControl>> ConnectToExecutor();
static Expected<std::unique_ptr<ExecutorProcessControl>> ConnectToExecutor();
Error disconnect() override;
private:
using LLVMJITLinkRemoteMemoryAccess =
orc::OrcRPCTPCMemoryAccess<LLVMJITLinkRemoteTargetProcessControl>;
orc::OrcRPCEPCMemoryAccess<LLVMJITLinkRemoteExecutorProcessControl>;
using LLVMJITLinkRemoteMemoryManager =
orc::OrcRPCTPCJITLinkMemoryManager<LLVMJITLinkRemoteTargetProcessControl>;
using LLVMJITLinkRemoteMemoryManager = orc::OrcRPCEPCJITLinkMemoryManager<
LLVMJITLinkRemoteExecutorProcessControl>;
LLVMJITLinkRemoteTargetProcessControl(
LLVMJITLinkRemoteExecutorProcessControl(
std::shared_ptr<orc::SymbolStringPool> SSP,
std::unique_ptr<LLVMJITLinkChannel> Channel,
std::unique_ptr<LLVMJITLinkRPCEndpoint> Endpoint,
@ -89,7 +89,7 @@ private:
}
});
if (auto Err2 = initializeORCRPCTPCBase()) {
if (auto Err2 = initializeORCRPCEPCBase()) {
Err = joinErrors(std::move(Err2), disconnect());
return;
}
@ -102,14 +102,14 @@ private:
std::unique_ptr<LLVMJITLinkChannel> Channel;
std::unique_ptr<LLVMJITLinkRPCEndpoint> Endpoint;
std::unique_ptr<TargetProcessControl::MemoryAccess> OwnedMemAccess;
std::unique_ptr<ExecutorProcessControl::MemoryAccess> OwnedMemAccess;
std::unique_ptr<jitlink::JITLinkMemoryManager> OwnedMemMgr;
std::atomic<bool> Finished{false};
std::thread ListenerThread;
};
struct Session {
std::unique_ptr<orc::TargetProcessControl> TPC;
std::unique_ptr<orc::ExecutorProcessControl> EPC;
orc::ExecutionSession ES;
orc::JITDylib *MainJD;
LLVMJITLinkObjectLinkingLayer ObjLayer;
@ -156,7 +156,7 @@ struct Session {
DenseMap<StringRef, StringRef> CanonicalWeakDefs;
private:
Session(std::unique_ptr<orc::TargetProcessControl> TPC, Error &Err);
Session(std::unique_ptr<orc::ExecutorProcessControl> EPC, Error &Err);
};
/// Record symbols, GOT entries, stubs, and sections for ELF file.