LLVM 20.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"
13#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
16
17#include <atomic>
18#include <mutex>
19
20#if defined(_WIN32)
21#include <windows.h>
22#endif
23
24namespace llvm {
25namespace orc {
26namespace rt_bootstrap {
27
30public:
32
36
37 Error deinitialize(const std::vector<ExecutorAddr> &Bases);
38 Error release(const std::vector<ExecutorAddr> &Bases);
39
40 Error shutdown() override;
42
43private:
44 struct Allocation {
45 std::vector<shared::WrapperFunctionCall> DeinitializationActions;
46 };
47 using AllocationMap = DenseMap<ExecutorAddr, Allocation>;
48
49 struct Reservation {
50 size_t Size;
51 std::vector<ExecutorAddr> Allocations;
52#if defined(_WIN32)
53 HANDLE SharedMemoryFile;
54#endif
55 };
56 using ReservationMap = DenseMap<void *, Reservation>;
57
59 reserveWrapper(const char *ArgData, size_t ArgSize);
60
62 initializeWrapper(const char *ArgData, size_t ArgSize);
63
65 deinitializeWrapper(const char *ArgData, size_t ArgSize);
66
68 releaseWrapper(const char *ArgData, size_t ArgSize);
69
70#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
71 std::atomic<int> SharedMemoryCount{0};
72#endif
73
74 std::mutex Mutex;
75 ReservationMap Reservations;
76 AllocationMap Allocations;
77};
78
79} // namespace rt_bootstrap
80} // namespace orc
81} // namespace llvm
82#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:160
Tagged union holding either a T or a Error.
Definition: Error.h:481
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:128
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