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" 10*89e6a288SDaniil Fukalov #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX 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 #include <sstream> 151b1f1c77SAnubhab Ghosh 161b1f1c77SAnubhab Ghosh #if defined(LLVM_ON_UNIX) 171b1f1c77SAnubhab Ghosh #include <errno.h> 181b1f1c77SAnubhab Ghosh #include <fcntl.h> 191b1f1c77SAnubhab Ghosh #include <sys/mman.h> 20ee736519SFanbo Meng #if defined(__MVS__) 21ee736519SFanbo Meng #include "llvm/Support/BLAKE3.h" 22ee736519SFanbo Meng #include <sys/shm.h> 23ee736519SFanbo Meng #endif 241b1f1c77SAnubhab Ghosh #include <unistd.h> 251b1f1c77SAnubhab Ghosh #endif 261b1f1c77SAnubhab Ghosh 27516397e1SLang Hames namespace llvm { 28516397e1SLang Hames namespace orc { 29516397e1SLang Hames namespace rt_bootstrap { 30516397e1SLang Hames 311b1f1c77SAnubhab Ghosh #if defined(_WIN32) 32543790adSLang Hames static DWORD getWindowsProtectionFlags(MemProt MP) { 33543790adSLang Hames if (MP == MemProt::Read) 341b1f1c77SAnubhab Ghosh return PAGE_READONLY; 35543790adSLang Hames if (MP == MemProt::Write || 36543790adSLang Hames MP == (MemProt::Write | MemProt::Read)) { 371b1f1c77SAnubhab Ghosh // Note: PAGE_WRITE is not supported by VirtualProtect 381b1f1c77SAnubhab Ghosh return PAGE_READWRITE; 391b1f1c77SAnubhab Ghosh } 40543790adSLang Hames if (MP == (MemProt::Read | MemProt::Exec)) 41543790adSLang Hames return PAGE_EXECUTE_READ; 42543790adSLang Hames if (MP == (MemProt::Read | MemProt::Write | MemProt::Exec)) 43543790adSLang Hames return PAGE_EXECUTE_READWRITE; 44ff85a187SLang Hames if (MP == MemProt::Exec) 45543790adSLang Hames return PAGE_EXECUTE; 46543790adSLang Hames 471b1f1c77SAnubhab Ghosh return PAGE_NOACCESS; 481b1f1c77SAnubhab Ghosh } 491b1f1c77SAnubhab Ghosh #endif 501b1f1c77SAnubhab Ghosh 511b1f1c77SAnubhab Ghosh Expected<std::pair<ExecutorAddr, std::string>> 521b1f1c77SAnubhab Ghosh ExecutorSharedMemoryMapperService::reserve(uint64_t Size) { 53ac3cb4ecSAnubhab Ghosh #if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32) 541b1f1c77SAnubhab Ghosh 551b1f1c77SAnubhab Ghosh #if defined(LLVM_ON_UNIX) 561b1f1c77SAnubhab Ghosh 571b1f1c77SAnubhab Ghosh std::string SharedMemoryName; 581b1f1c77SAnubhab Ghosh { 591b1f1c77SAnubhab Ghosh std::stringstream SharedMemoryNameStream; 601b1f1c77SAnubhab Ghosh SharedMemoryNameStream << "/jitlink_" << sys::Process::getProcessId() << '_' 611b1f1c77SAnubhab Ghosh << (++SharedMemoryCount); 621b1f1c77SAnubhab Ghosh SharedMemoryName = SharedMemoryNameStream.str(); 631b1f1c77SAnubhab Ghosh } 641b1f1c77SAnubhab Ghosh 65ee736519SFanbo Meng #if defined(__MVS__) 66ee736519SFanbo Meng ArrayRef<uint8_t> Data( 67ee736519SFanbo Meng reinterpret_cast<const uint8_t *>(SharedMemoryName.c_str()), 68ee736519SFanbo Meng SharedMemoryName.size()); 69ee736519SFanbo Meng auto HashedName = BLAKE3::hash<sizeof(key_t)>(Data); 70ee736519SFanbo Meng key_t Key = *reinterpret_cast<key_t *>(HashedName.data()); 71ee736519SFanbo Meng int SharedMemoryId = 72ee736519SFanbo Meng shmget(Key, Size, IPC_CREAT | IPC_EXCL | __IPC_SHAREAS | 0700); 73ee736519SFanbo Meng if (SharedMemoryId < 0) 74ee736519SFanbo Meng return errorCodeToError(errnoAsErrorCode()); 75ee736519SFanbo Meng 76ee736519SFanbo Meng void *Addr = shmat(SharedMemoryId, nullptr, 0); 77ee736519SFanbo Meng if (Addr == reinterpret_cast<void *>(-1)) 78ee736519SFanbo Meng return errorCodeToError(errnoAsErrorCode()); 79ee736519SFanbo Meng #else 801b1f1c77SAnubhab Ghosh int SharedMemoryFile = 811b1f1c77SAnubhab Ghosh shm_open(SharedMemoryName.c_str(), O_RDWR | O_CREAT | O_EXCL, 0700); 821b1f1c77SAnubhab Ghosh if (SharedMemoryFile < 0) 83ba13fa2aSMichael Spencer return errorCodeToError(errnoAsErrorCode()); 841b1f1c77SAnubhab Ghosh 851b1f1c77SAnubhab Ghosh // by default size is 0 861b1f1c77SAnubhab Ghosh if (ftruncate(SharedMemoryFile, Size) < 0) 87ba13fa2aSMichael Spencer return errorCodeToError(errnoAsErrorCode()); 881b1f1c77SAnubhab Ghosh 891b1f1c77SAnubhab Ghosh void *Addr = mmap(nullptr, Size, PROT_NONE, MAP_SHARED, SharedMemoryFile, 0); 901b1f1c77SAnubhab Ghosh if (Addr == MAP_FAILED) 91ba13fa2aSMichael Spencer return errorCodeToError(errnoAsErrorCode()); 921b1f1c77SAnubhab Ghosh 931b1f1c77SAnubhab Ghosh close(SharedMemoryFile); 94ee736519SFanbo Meng #endif 951b1f1c77SAnubhab Ghosh 961b1f1c77SAnubhab Ghosh #elif defined(_WIN32) 971b1f1c77SAnubhab Ghosh 981b1f1c77SAnubhab Ghosh std::string SharedMemoryName; 991b1f1c77SAnubhab Ghosh { 1001b1f1c77SAnubhab Ghosh std::stringstream SharedMemoryNameStream; 1011b1f1c77SAnubhab Ghosh SharedMemoryNameStream << "jitlink_" << sys::Process::getProcessId() << '_' 1021b1f1c77SAnubhab Ghosh << (++SharedMemoryCount); 1031b1f1c77SAnubhab Ghosh SharedMemoryName = SharedMemoryNameStream.str(); 1041b1f1c77SAnubhab Ghosh } 1051b1f1c77SAnubhab Ghosh 1061b1f1c77SAnubhab Ghosh std::wstring WideSharedMemoryName(SharedMemoryName.begin(), 1071b1f1c77SAnubhab Ghosh SharedMemoryName.end()); 1081b1f1c77SAnubhab Ghosh HANDLE SharedMemoryFile = CreateFileMappingW( 1091b1f1c77SAnubhab Ghosh INVALID_HANDLE_VALUE, NULL, PAGE_EXECUTE_READWRITE, Size >> 32, 1101b1f1c77SAnubhab Ghosh Size & 0xffffffff, WideSharedMemoryName.c_str()); 1111b1f1c77SAnubhab Ghosh if (!SharedMemoryFile) 1121b1f1c77SAnubhab Ghosh return errorCodeToError(mapWindowsError(GetLastError())); 1131b1f1c77SAnubhab Ghosh 1141b1f1c77SAnubhab Ghosh void *Addr = MapViewOfFile(SharedMemoryFile, 1151b1f1c77SAnubhab Ghosh FILE_MAP_ALL_ACCESS | FILE_MAP_EXECUTE, 0, 0, 0); 1161b1f1c77SAnubhab Ghosh if (!Addr) { 1171b1f1c77SAnubhab Ghosh CloseHandle(SharedMemoryFile); 1181b1f1c77SAnubhab Ghosh return errorCodeToError(mapWindowsError(GetLastError())); 1191b1f1c77SAnubhab Ghosh } 1201b1f1c77SAnubhab Ghosh 1211b1f1c77SAnubhab Ghosh #endif 1221b1f1c77SAnubhab Ghosh 1231b1f1c77SAnubhab Ghosh { 1241b1f1c77SAnubhab Ghosh std::lock_guard<std::mutex> Lock(Mutex); 1251b1f1c77SAnubhab Ghosh Reservations[Addr].Size = Size; 1261b1f1c77SAnubhab Ghosh #if defined(_WIN32) 1271b1f1c77SAnubhab Ghosh Reservations[Addr].SharedMemoryFile = SharedMemoryFile; 1281b1f1c77SAnubhab Ghosh #endif 1291b1f1c77SAnubhab Ghosh } 1301b1f1c77SAnubhab Ghosh 1311b1f1c77SAnubhab Ghosh return std::make_pair(ExecutorAddr::fromPtr(Addr), 1321b1f1c77SAnubhab Ghosh std::move(SharedMemoryName)); 1331b1f1c77SAnubhab Ghosh #else 1341b1f1c77SAnubhab Ghosh return make_error<StringError>( 1351b1f1c77SAnubhab Ghosh "SharedMemoryMapper is not supported on this platform yet", 1361b1f1c77SAnubhab Ghosh inconvertibleErrorCode()); 1371b1f1c77SAnubhab Ghosh #endif 1381b1f1c77SAnubhab Ghosh } 1391b1f1c77SAnubhab Ghosh 1401b1f1c77SAnubhab Ghosh Expected<ExecutorAddr> ExecutorSharedMemoryMapperService::initialize( 1411b1f1c77SAnubhab Ghosh ExecutorAddr Reservation, tpctypes::SharedMemoryFinalizeRequest &FR) { 142ac3cb4ecSAnubhab Ghosh #if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32) 1431b1f1c77SAnubhab Ghosh 1441b1f1c77SAnubhab Ghosh ExecutorAddr MinAddr(~0ULL); 1451b1f1c77SAnubhab Ghosh 1461b1f1c77SAnubhab Ghosh // Contents are already in place 1471b1f1c77SAnubhab Ghosh for (auto &Segment : FR.Segments) { 1481b1f1c77SAnubhab Ghosh if (Segment.Addr < MinAddr) 1491b1f1c77SAnubhab Ghosh MinAddr = Segment.Addr; 1501b1f1c77SAnubhab Ghosh 1511b1f1c77SAnubhab Ghosh #if defined(LLVM_ON_UNIX) 1521b1f1c77SAnubhab Ghosh 153ee736519SFanbo Meng #if defined(__MVS__) 154ee736519SFanbo Meng // TODO Is it possible to change the protection level? 155ee736519SFanbo Meng #else 1561b1f1c77SAnubhab Ghosh int NativeProt = 0; 1570b7e16afSLang Hames if ((Segment.RAG.Prot & MemProt::Read) == MemProt::Read) 1581b1f1c77SAnubhab Ghosh NativeProt |= PROT_READ; 1590b7e16afSLang Hames if ((Segment.RAG.Prot & MemProt::Write) == MemProt::Write) 1601b1f1c77SAnubhab Ghosh NativeProt |= PROT_WRITE; 1610b7e16afSLang Hames if ((Segment.RAG.Prot & MemProt::Exec) == MemProt::Exec) 1621b1f1c77SAnubhab Ghosh NativeProt |= PROT_EXEC; 1631b1f1c77SAnubhab Ghosh 1641b1f1c77SAnubhab Ghosh if (mprotect(Segment.Addr.toPtr<void *>(), Segment.Size, NativeProt)) 165ba13fa2aSMichael Spencer return errorCodeToError(errnoAsErrorCode()); 166ee736519SFanbo Meng #endif 1671b1f1c77SAnubhab Ghosh 1681b1f1c77SAnubhab Ghosh #elif defined(_WIN32) 1691b1f1c77SAnubhab Ghosh 1700b7e16afSLang Hames DWORD NativeProt = getWindowsProtectionFlags(Segment.RAG.Prot); 1711b1f1c77SAnubhab Ghosh 1721b1f1c77SAnubhab Ghosh if (!VirtualProtect(Segment.Addr.toPtr<void *>(), Segment.Size, NativeProt, 1731b1f1c77SAnubhab Ghosh &NativeProt)) 1741b1f1c77SAnubhab Ghosh return errorCodeToError(mapWindowsError(GetLastError())); 1751b1f1c77SAnubhab Ghosh 1761b1f1c77SAnubhab Ghosh #endif 1771b1f1c77SAnubhab Ghosh 1780b7e16afSLang Hames if ((Segment.RAG.Prot & MemProt::Exec) == MemProt::Exec) 1791b1f1c77SAnubhab Ghosh sys::Memory::InvalidateInstructionCache(Segment.Addr.toPtr<void *>(), 1801b1f1c77SAnubhab Ghosh Segment.Size); 1811b1f1c77SAnubhab Ghosh } 1821b1f1c77SAnubhab Ghosh 1831b1f1c77SAnubhab Ghosh // Run finalization actions and get deinitlization action list. 1841b1f1c77SAnubhab Ghosh auto DeinitializeActions = shared::runFinalizeActions(FR.Actions); 1851b1f1c77SAnubhab Ghosh if (!DeinitializeActions) { 1861b1f1c77SAnubhab Ghosh return DeinitializeActions.takeError(); 1871b1f1c77SAnubhab Ghosh } 1881b1f1c77SAnubhab Ghosh 1891b1f1c77SAnubhab Ghosh { 1901b1f1c77SAnubhab Ghosh std::lock_guard<std::mutex> Lock(Mutex); 1911b1f1c77SAnubhab Ghosh Allocations[MinAddr].DeinitializationActions = 1921b1f1c77SAnubhab Ghosh std::move(*DeinitializeActions); 1931b1f1c77SAnubhab Ghosh Reservations[Reservation.toPtr<void *>()].Allocations.push_back(MinAddr); 1941b1f1c77SAnubhab Ghosh } 1951b1f1c77SAnubhab Ghosh 1961b1f1c77SAnubhab Ghosh return MinAddr; 1971b1f1c77SAnubhab Ghosh 1981b1f1c77SAnubhab Ghosh #else 1991b1f1c77SAnubhab Ghosh return make_error<StringError>( 2001b1f1c77SAnubhab Ghosh "SharedMemoryMapper is not supported on this platform yet", 2011b1f1c77SAnubhab Ghosh inconvertibleErrorCode()); 2021b1f1c77SAnubhab Ghosh #endif 2031b1f1c77SAnubhab Ghosh } 2041b1f1c77SAnubhab Ghosh 2051b1f1c77SAnubhab Ghosh Error ExecutorSharedMemoryMapperService::deinitialize( 2061b1f1c77SAnubhab Ghosh const std::vector<ExecutorAddr> &Bases) { 2071b1f1c77SAnubhab Ghosh Error AllErr = Error::success(); 2081b1f1c77SAnubhab Ghosh 2091b1f1c77SAnubhab Ghosh { 2101b1f1c77SAnubhab Ghosh std::lock_guard<std::mutex> Lock(Mutex); 2111b1f1c77SAnubhab Ghosh 212349e5bd2SLang Hames for (auto Base : llvm::reverse(Bases)) { 2131b1f1c77SAnubhab Ghosh if (Error Err = shared::runDeallocActions( 2141b1f1c77SAnubhab Ghosh Allocations[Base].DeinitializationActions)) { 2151b1f1c77SAnubhab Ghosh AllErr = joinErrors(std::move(AllErr), std::move(Err)); 2161b1f1c77SAnubhab Ghosh } 2171b1f1c77SAnubhab Ghosh 218e309f5ebSAnubhab Ghosh // Remove the allocation from the allocation list of its reservation 219e309f5ebSAnubhab Ghosh for (auto &Reservation : Reservations) { 2203f0bddb5SKazu Hirata auto AllocationIt = llvm::find(Reservation.second.Allocations, Base); 221e309f5ebSAnubhab Ghosh if (AllocationIt != Reservation.second.Allocations.end()) { 222e309f5ebSAnubhab Ghosh Reservation.second.Allocations.erase(AllocationIt); 223e309f5ebSAnubhab Ghosh break; 224e309f5ebSAnubhab Ghosh } 225e309f5ebSAnubhab Ghosh } 226e309f5ebSAnubhab Ghosh 2271b1f1c77SAnubhab Ghosh Allocations.erase(Base); 2281b1f1c77SAnubhab Ghosh } 2291b1f1c77SAnubhab Ghosh } 2301b1f1c77SAnubhab Ghosh 2311b1f1c77SAnubhab Ghosh return AllErr; 2321b1f1c77SAnubhab Ghosh } 2331b1f1c77SAnubhab Ghosh 2341b1f1c77SAnubhab Ghosh Error ExecutorSharedMemoryMapperService::release( 2351b1f1c77SAnubhab Ghosh const std::vector<ExecutorAddr> &Bases) { 236ac3cb4ecSAnubhab Ghosh #if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32) 2371b1f1c77SAnubhab Ghosh Error Err = Error::success(); 2381b1f1c77SAnubhab Ghosh 2391b1f1c77SAnubhab Ghosh for (auto Base : Bases) { 2401b1f1c77SAnubhab Ghosh std::vector<ExecutorAddr> AllocAddrs; 2411b1f1c77SAnubhab Ghosh size_t Size; 2421b1f1c77SAnubhab Ghosh 2431b1f1c77SAnubhab Ghosh #if defined(_WIN32) 2441b1f1c77SAnubhab Ghosh HANDLE SharedMemoryFile; 2451b1f1c77SAnubhab Ghosh #endif 2461b1f1c77SAnubhab Ghosh 2471b1f1c77SAnubhab Ghosh { 2481b1f1c77SAnubhab Ghosh std::lock_guard<std::mutex> Lock(Mutex); 2491b1f1c77SAnubhab Ghosh auto &R = Reservations[Base.toPtr<void *>()]; 2501b1f1c77SAnubhab Ghosh Size = R.Size; 2511b1f1c77SAnubhab Ghosh 2521b1f1c77SAnubhab Ghosh #if defined(_WIN32) 2531b1f1c77SAnubhab Ghosh SharedMemoryFile = R.SharedMemoryFile; 2541b1f1c77SAnubhab Ghosh #endif 2551b1f1c77SAnubhab Ghosh 2561b1f1c77SAnubhab Ghosh AllocAddrs.swap(R.Allocations); 2571b1f1c77SAnubhab Ghosh } 2581b1f1c77SAnubhab Ghosh 2591b1f1c77SAnubhab Ghosh // deinitialize sub allocations 2601b1f1c77SAnubhab Ghosh if (Error E = deinitialize(AllocAddrs)) 2611b1f1c77SAnubhab Ghosh Err = joinErrors(std::move(Err), std::move(E)); 2621b1f1c77SAnubhab Ghosh 2631b1f1c77SAnubhab Ghosh #if defined(LLVM_ON_UNIX) 2641b1f1c77SAnubhab Ghosh 265ee736519SFanbo Meng #if defined(__MVS__) 266ee736519SFanbo Meng (void)Size; 267ee736519SFanbo Meng 268ee736519SFanbo Meng if (shmdt(Base.toPtr<void *>()) < 0) 269ee736519SFanbo Meng Err = joinErrors(std::move(Err), errorCodeToError(errnoAsErrorCode())); 270ee736519SFanbo Meng #else 2711b1f1c77SAnubhab Ghosh if (munmap(Base.toPtr<void *>(), Size) != 0) 272ba13fa2aSMichael Spencer Err = joinErrors(std::move(Err), errorCodeToError(errnoAsErrorCode())); 273ee736519SFanbo Meng #endif 2741b1f1c77SAnubhab Ghosh 2751b1f1c77SAnubhab Ghosh #elif defined(_WIN32) 27646196db4SMartin Storsjö (void)Size; 2771b1f1c77SAnubhab Ghosh 2781b1f1c77SAnubhab Ghosh if (!UnmapViewOfFile(Base.toPtr<void *>())) 2791b1f1c77SAnubhab Ghosh Err = joinErrors(std::move(Err), 2801b1f1c77SAnubhab Ghosh errorCodeToError(mapWindowsError(GetLastError()))); 2811b1f1c77SAnubhab Ghosh 2821b1f1c77SAnubhab Ghosh CloseHandle(SharedMemoryFile); 2831b1f1c77SAnubhab Ghosh 2841b1f1c77SAnubhab Ghosh #endif 2851b1f1c77SAnubhab Ghosh 2861b1f1c77SAnubhab Ghosh std::lock_guard<std::mutex> Lock(Mutex); 2871b1f1c77SAnubhab Ghosh Reservations.erase(Base.toPtr<void *>()); 2881b1f1c77SAnubhab Ghosh } 2891b1f1c77SAnubhab Ghosh 2901b1f1c77SAnubhab Ghosh return Err; 2911b1f1c77SAnubhab Ghosh #else 2921b1f1c77SAnubhab Ghosh return make_error<StringError>( 2931b1f1c77SAnubhab Ghosh "SharedMemoryMapper is not supported on this platform yet", 2941b1f1c77SAnubhab Ghosh inconvertibleErrorCode()); 2951b1f1c77SAnubhab Ghosh #endif 2961b1f1c77SAnubhab Ghosh } 2971b1f1c77SAnubhab Ghosh 2981b1f1c77SAnubhab Ghosh Error ExecutorSharedMemoryMapperService::shutdown() { 2990aaa74f7SAnubhab Ghosh if (Reservations.empty()) 3000aaa74f7SAnubhab Ghosh return Error::success(); 3010aaa74f7SAnubhab Ghosh 302e309f5ebSAnubhab Ghosh std::vector<ExecutorAddr> ReservationAddrs; 3031b1f1c77SAnubhab Ghosh ReservationAddrs.reserve(Reservations.size()); 304e309f5ebSAnubhab Ghosh for (const auto &R : Reservations) 3051b1f1c77SAnubhab Ghosh ReservationAddrs.push_back(ExecutorAddr::fromPtr(R.getFirst())); 3061b1f1c77SAnubhab Ghosh 307e309f5ebSAnubhab Ghosh return release(std::move(ReservationAddrs)); 3081b1f1c77SAnubhab Ghosh } 3091b1f1c77SAnubhab Ghosh 3101b1f1c77SAnubhab Ghosh void ExecutorSharedMemoryMapperService::addBootstrapSymbols( 3111b1f1c77SAnubhab Ghosh StringMap<ExecutorAddr> &M) { 3121b1f1c77SAnubhab Ghosh M[rt::ExecutorSharedMemoryMapperServiceInstanceName] = 3131b1f1c77SAnubhab Ghosh ExecutorAddr::fromPtr(this); 3141b1f1c77SAnubhab Ghosh M[rt::ExecutorSharedMemoryMapperServiceReserveWrapperName] = 3151b1f1c77SAnubhab Ghosh ExecutorAddr::fromPtr(&reserveWrapper); 3161b1f1c77SAnubhab Ghosh M[rt::ExecutorSharedMemoryMapperServiceInitializeWrapperName] = 3171b1f1c77SAnubhab Ghosh ExecutorAddr::fromPtr(&initializeWrapper); 3181b1f1c77SAnubhab Ghosh M[rt::ExecutorSharedMemoryMapperServiceDeinitializeWrapperName] = 3191b1f1c77SAnubhab Ghosh ExecutorAddr::fromPtr(&deinitializeWrapper); 3201b1f1c77SAnubhab Ghosh M[rt::ExecutorSharedMemoryMapperServiceReleaseWrapperName] = 3211b1f1c77SAnubhab Ghosh ExecutorAddr::fromPtr(&releaseWrapper); 3221b1f1c77SAnubhab Ghosh } 3231b1f1c77SAnubhab Ghosh 3241b1f1c77SAnubhab Ghosh llvm::orc::shared::CWrapperFunctionResult 3251b1f1c77SAnubhab Ghosh ExecutorSharedMemoryMapperService::reserveWrapper(const char *ArgData, 3261b1f1c77SAnubhab Ghosh size_t ArgSize) { 3271b1f1c77SAnubhab Ghosh return shared::WrapperFunction< 3281b1f1c77SAnubhab Ghosh rt::SPSExecutorSharedMemoryMapperServiceReserveSignature>:: 3291b1f1c77SAnubhab Ghosh handle(ArgData, ArgSize, 3301b1f1c77SAnubhab Ghosh shared::makeMethodWrapperHandler( 3311b1f1c77SAnubhab Ghosh &ExecutorSharedMemoryMapperService::reserve)) 3321b1f1c77SAnubhab Ghosh .release(); 3331b1f1c77SAnubhab Ghosh } 3341b1f1c77SAnubhab Ghosh 3351b1f1c77SAnubhab Ghosh llvm::orc::shared::CWrapperFunctionResult 3361b1f1c77SAnubhab Ghosh ExecutorSharedMemoryMapperService::initializeWrapper(const char *ArgData, 3371b1f1c77SAnubhab Ghosh size_t ArgSize) { 3381b1f1c77SAnubhab Ghosh return shared::WrapperFunction< 3391b1f1c77SAnubhab Ghosh rt::SPSExecutorSharedMemoryMapperServiceInitializeSignature>:: 3401b1f1c77SAnubhab Ghosh handle(ArgData, ArgSize, 3411b1f1c77SAnubhab Ghosh shared::makeMethodWrapperHandler( 3421b1f1c77SAnubhab Ghosh &ExecutorSharedMemoryMapperService::initialize)) 3431b1f1c77SAnubhab Ghosh .release(); 3441b1f1c77SAnubhab Ghosh } 3451b1f1c77SAnubhab Ghosh 3461b1f1c77SAnubhab Ghosh llvm::orc::shared::CWrapperFunctionResult 3471b1f1c77SAnubhab Ghosh ExecutorSharedMemoryMapperService::deinitializeWrapper(const char *ArgData, 3481b1f1c77SAnubhab Ghosh size_t ArgSize) { 3491b1f1c77SAnubhab Ghosh return shared::WrapperFunction< 3501b1f1c77SAnubhab Ghosh rt::SPSExecutorSharedMemoryMapperServiceDeinitializeSignature>:: 3511b1f1c77SAnubhab Ghosh handle(ArgData, ArgSize, 3521b1f1c77SAnubhab Ghosh shared::makeMethodWrapperHandler( 3531b1f1c77SAnubhab Ghosh &ExecutorSharedMemoryMapperService::deinitialize)) 3541b1f1c77SAnubhab Ghosh .release(); 3551b1f1c77SAnubhab Ghosh } 3561b1f1c77SAnubhab Ghosh 3571b1f1c77SAnubhab Ghosh llvm::orc::shared::CWrapperFunctionResult 3581b1f1c77SAnubhab Ghosh ExecutorSharedMemoryMapperService::releaseWrapper(const char *ArgData, 3591b1f1c77SAnubhab Ghosh size_t ArgSize) { 3601b1f1c77SAnubhab Ghosh return shared::WrapperFunction< 3611b1f1c77SAnubhab Ghosh rt::SPSExecutorSharedMemoryMapperServiceReleaseSignature>:: 3621b1f1c77SAnubhab Ghosh handle(ArgData, ArgSize, 3631b1f1c77SAnubhab Ghosh shared::makeMethodWrapperHandler( 3641b1f1c77SAnubhab Ghosh &ExecutorSharedMemoryMapperService::release)) 3651b1f1c77SAnubhab Ghosh .release(); 3661b1f1c77SAnubhab Ghosh } 3671b1f1c77SAnubhab Ghosh 3681b1f1c77SAnubhab Ghosh } // namespace rt_bootstrap 3691b1f1c77SAnubhab Ghosh } // end namespace orc 3701b1f1c77SAnubhab Ghosh } // end namespace llvm 371