11b1f1c77SAnubhab Ghosh //===---------- ExecutorSharedMemoryMapperService.cpp -----------*- C++ -*-===//
21b1f1c77SAnubhab Ghosh //
31b1f1c77SAnubhab Ghosh // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
41b1f1c77SAnubhab Ghosh // See https://llvm.org/LICENSE.txt for license information.
51b1f1c77SAnubhab Ghosh // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
61b1f1c77SAnubhab Ghosh //
71b1f1c77SAnubhab Ghosh //===----------------------------------------------------------------------===//
81b1f1c77SAnubhab Ghosh
91b1f1c77SAnubhab Ghosh #include "llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h"
101b1f1c77SAnubhab Ghosh
111b1f1c77SAnubhab Ghosh #include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
121b1f1c77SAnubhab Ghosh #include "llvm/Support/Process.h"
131b1f1c77SAnubhab Ghosh #include "llvm/Support/WindowsError.h"
141b1f1c77SAnubhab Ghosh
151b1f1c77SAnubhab Ghosh #include <sstream>
161b1f1c77SAnubhab Ghosh
171b1f1c77SAnubhab Ghosh #if defined(LLVM_ON_UNIX)
181b1f1c77SAnubhab Ghosh #include <errno.h>
191b1f1c77SAnubhab Ghosh #include <fcntl.h>
201b1f1c77SAnubhab Ghosh #include <sys/mman.h>
211b1f1c77SAnubhab Ghosh #include <unistd.h>
221b1f1c77SAnubhab Ghosh #endif
231b1f1c77SAnubhab Ghosh
241b1f1c77SAnubhab Ghosh #if defined(_WIN32)
getWindowsProtectionFlags(unsigned Flags)251b1f1c77SAnubhab Ghosh static DWORD getWindowsProtectionFlags(unsigned Flags) {
261b1f1c77SAnubhab Ghosh switch (Flags & llvm::sys::Memory::MF_RWE_MASK) {
271b1f1c77SAnubhab Ghosh case llvm::sys::Memory::MF_READ:
281b1f1c77SAnubhab Ghosh return PAGE_READONLY;
291b1f1c77SAnubhab Ghosh case llvm::sys::Memory::MF_WRITE:
301b1f1c77SAnubhab Ghosh // Note: PAGE_WRITE is not supported by VirtualProtect
311b1f1c77SAnubhab Ghosh return PAGE_READWRITE;
321b1f1c77SAnubhab Ghosh case llvm::sys::Memory::MF_READ | llvm::sys::Memory::MF_WRITE:
331b1f1c77SAnubhab Ghosh return PAGE_READWRITE;
341b1f1c77SAnubhab Ghosh case llvm::sys::Memory::MF_READ | llvm::sys::Memory::MF_EXEC:
351b1f1c77SAnubhab Ghosh return PAGE_EXECUTE_READ;
361b1f1c77SAnubhab Ghosh case llvm::sys::Memory::MF_READ | llvm::sys::Memory::MF_WRITE |
371b1f1c77SAnubhab Ghosh llvm::sys::Memory::MF_EXEC:
381b1f1c77SAnubhab Ghosh return PAGE_EXECUTE_READWRITE;
391b1f1c77SAnubhab Ghosh case llvm::sys::Memory::MF_EXEC:
401b1f1c77SAnubhab Ghosh return PAGE_EXECUTE;
411b1f1c77SAnubhab Ghosh default:
421b1f1c77SAnubhab Ghosh llvm_unreachable("Illegal memory protection flag specified!");
431b1f1c77SAnubhab Ghosh }
441b1f1c77SAnubhab Ghosh // Provide a default return value as required by some compilers.
451b1f1c77SAnubhab Ghosh return PAGE_NOACCESS;
461b1f1c77SAnubhab Ghosh }
471b1f1c77SAnubhab Ghosh #endif
481b1f1c77SAnubhab Ghosh
491b1f1c77SAnubhab Ghosh namespace llvm {
501b1f1c77SAnubhab Ghosh namespace orc {
511b1f1c77SAnubhab Ghosh namespace rt_bootstrap {
521b1f1c77SAnubhab Ghosh
531b1f1c77SAnubhab Ghosh Expected<std::pair<ExecutorAddr, std::string>>
reserve(uint64_t Size)541b1f1c77SAnubhab Ghosh ExecutorSharedMemoryMapperService::reserve(uint64_t Size) {
55b3293305SAnubhab Ghosh #if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
561b1f1c77SAnubhab Ghosh
571b1f1c77SAnubhab Ghosh #if defined(LLVM_ON_UNIX)
581b1f1c77SAnubhab Ghosh
591b1f1c77SAnubhab Ghosh std::string SharedMemoryName;
601b1f1c77SAnubhab Ghosh {
611b1f1c77SAnubhab Ghosh std::stringstream SharedMemoryNameStream;
621b1f1c77SAnubhab Ghosh SharedMemoryNameStream << "/jitlink_" << sys::Process::getProcessId() << '_'
631b1f1c77SAnubhab Ghosh << (++SharedMemoryCount);
641b1f1c77SAnubhab Ghosh SharedMemoryName = SharedMemoryNameStream.str();
651b1f1c77SAnubhab Ghosh }
661b1f1c77SAnubhab Ghosh
671b1f1c77SAnubhab Ghosh int SharedMemoryFile =
681b1f1c77SAnubhab Ghosh shm_open(SharedMemoryName.c_str(), O_RDWR | O_CREAT | O_EXCL, 0700);
691b1f1c77SAnubhab Ghosh if (SharedMemoryFile < 0)
701b1f1c77SAnubhab Ghosh return errorCodeToError(std::error_code(errno, std::generic_category()));
711b1f1c77SAnubhab Ghosh
721b1f1c77SAnubhab Ghosh // by default size is 0
731b1f1c77SAnubhab Ghosh if (ftruncate(SharedMemoryFile, Size) < 0)
741b1f1c77SAnubhab Ghosh return errorCodeToError(std::error_code(errno, std::generic_category()));
751b1f1c77SAnubhab Ghosh
761b1f1c77SAnubhab Ghosh void *Addr = mmap(nullptr, Size, PROT_NONE, MAP_SHARED, SharedMemoryFile, 0);
771b1f1c77SAnubhab Ghosh if (Addr == MAP_FAILED)
781b1f1c77SAnubhab Ghosh return errorCodeToError(std::error_code(errno, std::generic_category()));
791b1f1c77SAnubhab Ghosh
801b1f1c77SAnubhab Ghosh close(SharedMemoryFile);
811b1f1c77SAnubhab Ghosh
821b1f1c77SAnubhab Ghosh #elif defined(_WIN32)
831b1f1c77SAnubhab Ghosh
841b1f1c77SAnubhab Ghosh std::string SharedMemoryName;
851b1f1c77SAnubhab Ghosh {
861b1f1c77SAnubhab Ghosh std::stringstream SharedMemoryNameStream;
871b1f1c77SAnubhab Ghosh SharedMemoryNameStream << "jitlink_" << sys::Process::getProcessId() << '_'
881b1f1c77SAnubhab Ghosh << (++SharedMemoryCount);
891b1f1c77SAnubhab Ghosh SharedMemoryName = SharedMemoryNameStream.str();
901b1f1c77SAnubhab Ghosh }
911b1f1c77SAnubhab Ghosh
921b1f1c77SAnubhab Ghosh std::wstring WideSharedMemoryName(SharedMemoryName.begin(),
931b1f1c77SAnubhab Ghosh SharedMemoryName.end());
941b1f1c77SAnubhab Ghosh HANDLE SharedMemoryFile = CreateFileMappingW(
951b1f1c77SAnubhab Ghosh INVALID_HANDLE_VALUE, NULL, PAGE_EXECUTE_READWRITE, Size >> 32,
961b1f1c77SAnubhab Ghosh Size & 0xffffffff, WideSharedMemoryName.c_str());
971b1f1c77SAnubhab Ghosh if (!SharedMemoryFile)
981b1f1c77SAnubhab Ghosh return errorCodeToError(mapWindowsError(GetLastError()));
991b1f1c77SAnubhab Ghosh
1001b1f1c77SAnubhab Ghosh void *Addr = MapViewOfFile(SharedMemoryFile,
1011b1f1c77SAnubhab Ghosh FILE_MAP_ALL_ACCESS | FILE_MAP_EXECUTE, 0, 0, 0);
1021b1f1c77SAnubhab Ghosh if (!Addr) {
1031b1f1c77SAnubhab Ghosh CloseHandle(SharedMemoryFile);
1041b1f1c77SAnubhab Ghosh return errorCodeToError(mapWindowsError(GetLastError()));
1051b1f1c77SAnubhab Ghosh }
1061b1f1c77SAnubhab Ghosh
1071b1f1c77SAnubhab Ghosh #endif
1081b1f1c77SAnubhab Ghosh
1091b1f1c77SAnubhab Ghosh {
1101b1f1c77SAnubhab Ghosh std::lock_guard<std::mutex> Lock(Mutex);
1111b1f1c77SAnubhab Ghosh Reservations[Addr].Size = Size;
1121b1f1c77SAnubhab Ghosh #if defined(_WIN32)
1131b1f1c77SAnubhab Ghosh Reservations[Addr].SharedMemoryFile = SharedMemoryFile;
1141b1f1c77SAnubhab Ghosh #endif
1151b1f1c77SAnubhab Ghosh }
1161b1f1c77SAnubhab Ghosh
1171b1f1c77SAnubhab Ghosh return std::make_pair(ExecutorAddr::fromPtr(Addr),
1181b1f1c77SAnubhab Ghosh std::move(SharedMemoryName));
1191b1f1c77SAnubhab Ghosh #else
1201b1f1c77SAnubhab Ghosh return make_error<StringError>(
1211b1f1c77SAnubhab Ghosh "SharedMemoryMapper is not supported on this platform yet",
1221b1f1c77SAnubhab Ghosh inconvertibleErrorCode());
1231b1f1c77SAnubhab Ghosh #endif
1241b1f1c77SAnubhab Ghosh }
1251b1f1c77SAnubhab Ghosh
initialize(ExecutorAddr Reservation,tpctypes::SharedMemoryFinalizeRequest & FR)1261b1f1c77SAnubhab Ghosh Expected<ExecutorAddr> ExecutorSharedMemoryMapperService::initialize(
1271b1f1c77SAnubhab Ghosh ExecutorAddr Reservation, tpctypes::SharedMemoryFinalizeRequest &FR) {
128b3293305SAnubhab Ghosh #if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
1291b1f1c77SAnubhab Ghosh
1301b1f1c77SAnubhab Ghosh ExecutorAddr MinAddr(~0ULL);
1311b1f1c77SAnubhab Ghosh
1321b1f1c77SAnubhab Ghosh // Contents are already in place
1331b1f1c77SAnubhab Ghosh for (auto &Segment : FR.Segments) {
1341b1f1c77SAnubhab Ghosh if (Segment.Addr < MinAddr)
1351b1f1c77SAnubhab Ghosh MinAddr = Segment.Addr;
1361b1f1c77SAnubhab Ghosh
1371b1f1c77SAnubhab Ghosh #if defined(LLVM_ON_UNIX)
1381b1f1c77SAnubhab Ghosh
1391b1f1c77SAnubhab Ghosh int NativeProt = 0;
1401b1f1c77SAnubhab Ghosh if (Segment.Prot & tpctypes::WPF_Read)
1411b1f1c77SAnubhab Ghosh NativeProt |= PROT_READ;
1421b1f1c77SAnubhab Ghosh if (Segment.Prot & tpctypes::WPF_Write)
1431b1f1c77SAnubhab Ghosh NativeProt |= PROT_WRITE;
1441b1f1c77SAnubhab Ghosh if (Segment.Prot & tpctypes::WPF_Exec)
1451b1f1c77SAnubhab Ghosh NativeProt |= PROT_EXEC;
1461b1f1c77SAnubhab Ghosh
1471b1f1c77SAnubhab Ghosh if (mprotect(Segment.Addr.toPtr<void *>(), Segment.Size, NativeProt))
1481b1f1c77SAnubhab Ghosh return errorCodeToError(std::error_code(errno, std::generic_category()));
1491b1f1c77SAnubhab Ghosh
1501b1f1c77SAnubhab Ghosh #elif defined(_WIN32)
1511b1f1c77SAnubhab Ghosh
1521b1f1c77SAnubhab Ghosh DWORD NativeProt =
1531b1f1c77SAnubhab Ghosh getWindowsProtectionFlags(fromWireProtectionFlags(Segment.Prot));
1541b1f1c77SAnubhab Ghosh
1551b1f1c77SAnubhab Ghosh if (!VirtualProtect(Segment.Addr.toPtr<void *>(), Segment.Size, NativeProt,
1561b1f1c77SAnubhab Ghosh &NativeProt))
1571b1f1c77SAnubhab Ghosh return errorCodeToError(mapWindowsError(GetLastError()));
1581b1f1c77SAnubhab Ghosh
1591b1f1c77SAnubhab Ghosh #endif
1601b1f1c77SAnubhab Ghosh
1611b1f1c77SAnubhab Ghosh if (Segment.Prot & tpctypes::WPF_Exec)
1621b1f1c77SAnubhab Ghosh sys::Memory::InvalidateInstructionCache(Segment.Addr.toPtr<void *>(),
1631b1f1c77SAnubhab Ghosh Segment.Size);
1641b1f1c77SAnubhab Ghosh }
1651b1f1c77SAnubhab Ghosh
1661b1f1c77SAnubhab Ghosh // Run finalization actions and get deinitlization action list.
1671b1f1c77SAnubhab Ghosh auto DeinitializeActions = shared::runFinalizeActions(FR.Actions);
1681b1f1c77SAnubhab Ghosh if (!DeinitializeActions) {
1691b1f1c77SAnubhab Ghosh return DeinitializeActions.takeError();
1701b1f1c77SAnubhab Ghosh }
1711b1f1c77SAnubhab Ghosh
1721b1f1c77SAnubhab Ghosh {
1731b1f1c77SAnubhab Ghosh std::lock_guard<std::mutex> Lock(Mutex);
1741b1f1c77SAnubhab Ghosh Allocations[MinAddr].DeinitializationActions =
1751b1f1c77SAnubhab Ghosh std::move(*DeinitializeActions);
1761b1f1c77SAnubhab Ghosh Reservations[Reservation.toPtr<void *>()].Allocations.push_back(MinAddr);
1771b1f1c77SAnubhab Ghosh }
1781b1f1c77SAnubhab Ghosh
1791b1f1c77SAnubhab Ghosh return MinAddr;
1801b1f1c77SAnubhab Ghosh
1811b1f1c77SAnubhab Ghosh #else
1821b1f1c77SAnubhab Ghosh return make_error<StringError>(
1831b1f1c77SAnubhab Ghosh "SharedMemoryMapper is not supported on this platform yet",
1841b1f1c77SAnubhab Ghosh inconvertibleErrorCode());
1851b1f1c77SAnubhab Ghosh #endif
1861b1f1c77SAnubhab Ghosh }
1871b1f1c77SAnubhab Ghosh
deinitialize(const std::vector<ExecutorAddr> & Bases)1881b1f1c77SAnubhab Ghosh Error ExecutorSharedMemoryMapperService::deinitialize(
1891b1f1c77SAnubhab Ghosh const std::vector<ExecutorAddr> &Bases) {
1901b1f1c77SAnubhab Ghosh Error AllErr = Error::success();
1911b1f1c77SAnubhab Ghosh
1921b1f1c77SAnubhab Ghosh {
1931b1f1c77SAnubhab Ghosh std::lock_guard<std::mutex> Lock(Mutex);
1941b1f1c77SAnubhab Ghosh
1951b1f1c77SAnubhab Ghosh for (auto Base : Bases) {
1961b1f1c77SAnubhab Ghosh if (Error Err = shared::runDeallocActions(
1971b1f1c77SAnubhab Ghosh Allocations[Base].DeinitializationActions)) {
1981b1f1c77SAnubhab Ghosh AllErr = joinErrors(std::move(AllErr), std::move(Err));
1991b1f1c77SAnubhab Ghosh }
2001b1f1c77SAnubhab Ghosh
2011b1f1c77SAnubhab Ghosh Allocations.erase(Base);
2021b1f1c77SAnubhab Ghosh }
2031b1f1c77SAnubhab Ghosh }
2041b1f1c77SAnubhab Ghosh
2051b1f1c77SAnubhab Ghosh return AllErr;
2061b1f1c77SAnubhab Ghosh }
2071b1f1c77SAnubhab Ghosh
release(const std::vector<ExecutorAddr> & Bases)2081b1f1c77SAnubhab Ghosh Error ExecutorSharedMemoryMapperService::release(
2091b1f1c77SAnubhab Ghosh const std::vector<ExecutorAddr> &Bases) {
210b3293305SAnubhab Ghosh #if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
2111b1f1c77SAnubhab Ghosh Error Err = Error::success();
2121b1f1c77SAnubhab Ghosh
2131b1f1c77SAnubhab Ghosh for (auto Base : Bases) {
2141b1f1c77SAnubhab Ghosh std::vector<ExecutorAddr> AllocAddrs;
2151b1f1c77SAnubhab Ghosh size_t Size;
2161b1f1c77SAnubhab Ghosh
2171b1f1c77SAnubhab Ghosh #if defined(_WIN32)
2181b1f1c77SAnubhab Ghosh HANDLE SharedMemoryFile;
2191b1f1c77SAnubhab Ghosh #endif
2201b1f1c77SAnubhab Ghosh
2211b1f1c77SAnubhab Ghosh {
2221b1f1c77SAnubhab Ghosh std::lock_guard<std::mutex> Lock(Mutex);
2231b1f1c77SAnubhab Ghosh auto &R = Reservations[Base.toPtr<void *>()];
2241b1f1c77SAnubhab Ghosh Size = R.Size;
2251b1f1c77SAnubhab Ghosh
2261b1f1c77SAnubhab Ghosh #if defined(_WIN32)
2271b1f1c77SAnubhab Ghosh SharedMemoryFile = R.SharedMemoryFile;
2281b1f1c77SAnubhab Ghosh #endif
2291b1f1c77SAnubhab Ghosh
2301b1f1c77SAnubhab Ghosh AllocAddrs.swap(R.Allocations);
2311b1f1c77SAnubhab Ghosh }
2321b1f1c77SAnubhab Ghosh
2331b1f1c77SAnubhab Ghosh // deinitialize sub allocations
2341b1f1c77SAnubhab Ghosh if (Error E = deinitialize(AllocAddrs))
2351b1f1c77SAnubhab Ghosh Err = joinErrors(std::move(Err), std::move(E));
2361b1f1c77SAnubhab Ghosh
2371b1f1c77SAnubhab Ghosh #if defined(LLVM_ON_UNIX)
2381b1f1c77SAnubhab Ghosh
2391b1f1c77SAnubhab Ghosh if (munmap(Base.toPtr<void *>(), Size) != 0)
2401b1f1c77SAnubhab Ghosh Err = joinErrors(std::move(Err), errorCodeToError(std::error_code(
2411b1f1c77SAnubhab Ghosh errno, std::generic_category())));
2421b1f1c77SAnubhab Ghosh
2431b1f1c77SAnubhab Ghosh #elif defined(_WIN32)
244*853c8f92SMartin Storsjö (void)Size;
2451b1f1c77SAnubhab Ghosh
2461b1f1c77SAnubhab Ghosh if (!UnmapViewOfFile(Base.toPtr<void *>()))
2471b1f1c77SAnubhab Ghosh Err = joinErrors(std::move(Err),
2481b1f1c77SAnubhab Ghosh errorCodeToError(mapWindowsError(GetLastError())));
2491b1f1c77SAnubhab Ghosh
2501b1f1c77SAnubhab Ghosh CloseHandle(SharedMemoryFile);
2511b1f1c77SAnubhab Ghosh
2521b1f1c77SAnubhab Ghosh #endif
2531b1f1c77SAnubhab Ghosh
2541b1f1c77SAnubhab Ghosh std::lock_guard<std::mutex> Lock(Mutex);
2551b1f1c77SAnubhab Ghosh Reservations.erase(Base.toPtr<void *>());
2561b1f1c77SAnubhab Ghosh }
2571b1f1c77SAnubhab Ghosh
2581b1f1c77SAnubhab Ghosh return Err;
2591b1f1c77SAnubhab Ghosh #else
2601b1f1c77SAnubhab Ghosh return make_error<StringError>(
2611b1f1c77SAnubhab Ghosh "SharedMemoryMapper is not supported on this platform yet",
2621b1f1c77SAnubhab Ghosh inconvertibleErrorCode());
2631b1f1c77SAnubhab Ghosh #endif
2641b1f1c77SAnubhab Ghosh }
2651b1f1c77SAnubhab Ghosh
shutdown()2661b1f1c77SAnubhab Ghosh Error ExecutorSharedMemoryMapperService::shutdown() {
2671b1f1c77SAnubhab Ghosh std::vector<ExecutorAddr> ReservationAddrs;
2681b1f1c77SAnubhab Ghosh if (!Reservations.empty()) {
2691b1f1c77SAnubhab Ghosh std::lock_guard<std::mutex> Lock(Mutex);
2701b1f1c77SAnubhab Ghosh {
2711b1f1c77SAnubhab Ghosh ReservationAddrs.reserve(Reservations.size());
2721b1f1c77SAnubhab Ghosh for (const auto &R : Reservations) {
2731b1f1c77SAnubhab Ghosh ReservationAddrs.push_back(ExecutorAddr::fromPtr(R.getFirst()));
2741b1f1c77SAnubhab Ghosh }
2751b1f1c77SAnubhab Ghosh }
2761b1f1c77SAnubhab Ghosh }
2771b1f1c77SAnubhab Ghosh return release(ReservationAddrs);
2781b1f1c77SAnubhab Ghosh
2791b1f1c77SAnubhab Ghosh return Error::success();
2801b1f1c77SAnubhab Ghosh }
2811b1f1c77SAnubhab Ghosh
addBootstrapSymbols(StringMap<ExecutorAddr> & M)2821b1f1c77SAnubhab Ghosh void ExecutorSharedMemoryMapperService::addBootstrapSymbols(
2831b1f1c77SAnubhab Ghosh StringMap<ExecutorAddr> &M) {
2841b1f1c77SAnubhab Ghosh M[rt::ExecutorSharedMemoryMapperServiceInstanceName] =
2851b1f1c77SAnubhab Ghosh ExecutorAddr::fromPtr(this);
2861b1f1c77SAnubhab Ghosh M[rt::ExecutorSharedMemoryMapperServiceReserveWrapperName] =
2871b1f1c77SAnubhab Ghosh ExecutorAddr::fromPtr(&reserveWrapper);
2881b1f1c77SAnubhab Ghosh M[rt::ExecutorSharedMemoryMapperServiceInitializeWrapperName] =
2891b1f1c77SAnubhab Ghosh ExecutorAddr::fromPtr(&initializeWrapper);
2901b1f1c77SAnubhab Ghosh M[rt::ExecutorSharedMemoryMapperServiceDeinitializeWrapperName] =
2911b1f1c77SAnubhab Ghosh ExecutorAddr::fromPtr(&deinitializeWrapper);
2921b1f1c77SAnubhab Ghosh M[rt::ExecutorSharedMemoryMapperServiceReleaseWrapperName] =
2931b1f1c77SAnubhab Ghosh ExecutorAddr::fromPtr(&releaseWrapper);
2941b1f1c77SAnubhab Ghosh }
2951b1f1c77SAnubhab Ghosh
2961b1f1c77SAnubhab Ghosh llvm::orc::shared::CWrapperFunctionResult
reserveWrapper(const char * ArgData,size_t ArgSize)2971b1f1c77SAnubhab Ghosh ExecutorSharedMemoryMapperService::reserveWrapper(const char *ArgData,
2981b1f1c77SAnubhab Ghosh size_t ArgSize) {
2991b1f1c77SAnubhab Ghosh return shared::WrapperFunction<
3001b1f1c77SAnubhab Ghosh rt::SPSExecutorSharedMemoryMapperServiceReserveSignature>::
3011b1f1c77SAnubhab Ghosh handle(ArgData, ArgSize,
3021b1f1c77SAnubhab Ghosh shared::makeMethodWrapperHandler(
3031b1f1c77SAnubhab Ghosh &ExecutorSharedMemoryMapperService::reserve))
3041b1f1c77SAnubhab Ghosh .release();
3051b1f1c77SAnubhab Ghosh }
3061b1f1c77SAnubhab Ghosh
3071b1f1c77SAnubhab Ghosh llvm::orc::shared::CWrapperFunctionResult
initializeWrapper(const char * ArgData,size_t ArgSize)3081b1f1c77SAnubhab Ghosh ExecutorSharedMemoryMapperService::initializeWrapper(const char *ArgData,
3091b1f1c77SAnubhab Ghosh size_t ArgSize) {
3101b1f1c77SAnubhab Ghosh return shared::WrapperFunction<
3111b1f1c77SAnubhab Ghosh rt::SPSExecutorSharedMemoryMapperServiceInitializeSignature>::
3121b1f1c77SAnubhab Ghosh handle(ArgData, ArgSize,
3131b1f1c77SAnubhab Ghosh shared::makeMethodWrapperHandler(
3141b1f1c77SAnubhab Ghosh &ExecutorSharedMemoryMapperService::initialize))
3151b1f1c77SAnubhab Ghosh .release();
3161b1f1c77SAnubhab Ghosh }
3171b1f1c77SAnubhab Ghosh
3181b1f1c77SAnubhab Ghosh llvm::orc::shared::CWrapperFunctionResult
deinitializeWrapper(const char * ArgData,size_t ArgSize)3191b1f1c77SAnubhab Ghosh ExecutorSharedMemoryMapperService::deinitializeWrapper(const char *ArgData,
3201b1f1c77SAnubhab Ghosh size_t ArgSize) {
3211b1f1c77SAnubhab Ghosh return shared::WrapperFunction<
3221b1f1c77SAnubhab Ghosh rt::SPSExecutorSharedMemoryMapperServiceDeinitializeSignature>::
3231b1f1c77SAnubhab Ghosh handle(ArgData, ArgSize,
3241b1f1c77SAnubhab Ghosh shared::makeMethodWrapperHandler(
3251b1f1c77SAnubhab Ghosh &ExecutorSharedMemoryMapperService::deinitialize))
3261b1f1c77SAnubhab Ghosh .release();
3271b1f1c77SAnubhab Ghosh }
3281b1f1c77SAnubhab Ghosh
3291b1f1c77SAnubhab Ghosh llvm::orc::shared::CWrapperFunctionResult
releaseWrapper(const char * ArgData,size_t ArgSize)3301b1f1c77SAnubhab Ghosh ExecutorSharedMemoryMapperService::releaseWrapper(const char *ArgData,
3311b1f1c77SAnubhab Ghosh size_t ArgSize) {
3321b1f1c77SAnubhab Ghosh return shared::WrapperFunction<
3331b1f1c77SAnubhab Ghosh rt::SPSExecutorSharedMemoryMapperServiceReleaseSignature>::
3341b1f1c77SAnubhab Ghosh handle(ArgData, ArgSize,
3351b1f1c77SAnubhab Ghosh shared::makeMethodWrapperHandler(
3361b1f1c77SAnubhab Ghosh &ExecutorSharedMemoryMapperService::release))
3371b1f1c77SAnubhab Ghosh .release();
3381b1f1c77SAnubhab Ghosh }
3391b1f1c77SAnubhab Ghosh
3401b1f1c77SAnubhab Ghosh } // namespace rt_bootstrap
3411b1f1c77SAnubhab Ghosh } // end namespace orc
3421b1f1c77SAnubhab Ghosh } // end namespace llvm
343