From a2c1cf09dfaaa6d2161fee00f8317005bf955d64 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Wed, 22 Sep 2021 15:34:46 +1000 Subject: [ORC] Introduce EPCGenericDylibManager / SimpleExecutorDylibManager. EPCGenericDylibManager provides an interface for loading dylibs and looking up symbols in the executor, implemented using EPC-calls to functions in the executor. SimpleExecutorDylibManager is an executor-side service that provides the functions used by EPCGenericDylibManager. SimpleRemoteEPC is updated to use an EPCGenericDylibManager instance to implement the ExecutorProcessControl loadDylib and lookup methods. In a future commit these methods will be removed, and clients updated to use EPCGenericDylibManagers directly. --- .../Orc/TargetProcess/SimpleRemoteEPCServer.cpp | 73 ---------------------- 1 file changed, 73 deletions(-) (limited to 'llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp') diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp index aa35263f35cd..30c9e0fd18b7 100644 --- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp +++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp @@ -54,9 +54,6 @@ void SimpleRemoteEPCServer::ThreadDispatcher::shutdown() { StringMap SimpleRemoteEPCServer::defaultBootstrapSymbols() { StringMap DBS; rt_bootstrap::addTo(DBS); - DBS["__llvm_orc_load_dylib"] = ExecutorAddress::fromPtr(&loadDylibWrapper); - DBS["__llvm_orc_lookup_symbols"] = - ExecutorAddress::fromPtr(&lookupSymbolsWrapper); return DBS; } @@ -199,76 +196,6 @@ void SimpleRemoteEPCServer::handleCallWrapper( }); } -shared::detail::CWrapperFunctionResult -SimpleRemoteEPCServer::loadDylibWrapper(const char *ArgData, size_t ArgSize) { - return shared::WrapperFunction::handle( - ArgData, ArgSize, - [](ExecutorAddress ExecutorSessionObj, std::string Path, - uint64_t Flags) -> Expected { - return ExecutorSessionObj.toPtr() - ->loadDylib(Path, Flags); - }) - .release(); -} - -shared::detail::CWrapperFunctionResult -SimpleRemoteEPCServer::lookupSymbolsWrapper(const char *ArgData, - size_t ArgSize) { - return shared::WrapperFunction::handle( - ArgData, ArgSize, - [](ExecutorAddress ExecutorSessionObj, - std::vector Lookup) { - return ExecutorSessionObj.toPtr() - ->lookupSymbols(Lookup); - }) - .release(); -} - -Expected -SimpleRemoteEPCServer::loadDylib(const std::string &Path, uint64_t Mode) { - std::string ErrMsg; - const char *P = Path.empty() ? nullptr : Path.c_str(); - auto DL = sys::DynamicLibrary::getPermanentLibrary(P, &ErrMsg); - if (!DL.isValid()) - return make_error(std::move(ErrMsg), inconvertibleErrorCode()); - std::lock_guard Lock(ServerStateMutex); - uint64_t Id = Dylibs.size(); - Dylibs.push_back(std::move(DL)); - return Id; -} - -Expected>> -SimpleRemoteEPCServer::lookupSymbols(const std::vector &L) { - std::vector> Result; - - for (const auto &E : L) { - if (E.H >= Dylibs.size()) - return make_error("Unrecognized handle", - inconvertibleErrorCode()); - auto &DL = Dylibs[E.H]; - Result.push_back({}); - - for (const auto &Sym : E.Symbols) { - - const char *DemangledSymName = Sym.Name.c_str(); -#ifdef __APPLE__ - if (*DemangledSymName == '_') - ++DemangledSymName; -#endif - - void *Addr = DL.getAddressOfSymbol(DemangledSymName); - if (!Addr && Sym.Required) - return make_error(Twine("Missing definition for ") + - DemangledSymName, - inconvertibleErrorCode()); - - Result.back().push_back(ExecutorAddress::fromPtr(Addr)); - } - } - - return std::move(Result); -} - shared::WrapperFunctionResult SimpleRemoteEPCServer::doJITDispatch(const void *FnTag, const char *ArgData, size_t ArgSize) { -- cgit v1.2.3