LLVM 17.0.0git
ExecutorSharedMemoryMapperService.h
Go to the documentation of this file.
1//===----------- ExecutorSharedMemoryMapperService.h ------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_EXECUTORSHAREDMEMORYMAPPERSERVICE_H
10#define LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_EXECUTORSHAREDMEMORYMAPPERSERVICE_H
11
12#include "llvm/ADT/DenseMap.h"
15
16#include <atomic>
17#include <mutex>
18
19#if defined(_WIN32)
20#include <windows.h>
21#endif
22
23namespace llvm {
24namespace orc {
25namespace rt_bootstrap {
26
29public:
31
35
36 Error deinitialize(const std::vector<ExecutorAddr> &Bases);
37 Error release(const std::vector<ExecutorAddr> &Bases);
38
39 Error shutdown() override;
41
42private:
43 struct Allocation {
44 std::vector<shared::WrapperFunctionCall> DeinitializationActions;
45 };
46 using AllocationMap = DenseMap<ExecutorAddr, Allocation>;
47
48 struct Reservation {
49 size_t Size;
50 std::vector<ExecutorAddr> Allocations;
51#if defined(_WIN32)
52 HANDLE SharedMemoryFile;
53#endif
54 };
55 using ReservationMap = DenseMap<void *, Reservation>;
56
58 reserveWrapper(const char *ArgData, size_t ArgSize);
59
61 initializeWrapper(const char *ArgData, size_t ArgSize);
62
64 deinitializeWrapper(const char *ArgData, size_t ArgSize);
65
67 releaseWrapper(const char *ArgData, size_t ArgSize);
68
69#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
70 std::atomic<int> SharedMemoryCount{0};
71#endif
72
73 std::mutex Mutex;
74 ReservationMap Reservations;
75 AllocationMap Allocations;
76};
77
78} // namespace rt_bootstrap
79} // namespace orc
80} // namespace llvm
81#endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_EXECUTORSHAREDMEMORYMAPPERSERVICE_H
This file defines the DenseMap class.
uint64_t Size
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
Tagged union holding either a T or a Error.
Definition: Error.h:470
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:111
Represents an address in the executor process.
Expected< std::pair< ExecutorAddr, std::string > > reserve(uint64_t Size)
Expected< ExecutorAddr > initialize(ExecutorAddr Reservation, tpctypes::SharedMemoryFinalizeRequest &FR)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18