LLVM 22.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
17
18#include <atomic>
19#include <mutex>
20
21#if defined(_WIN32)
22#include <windows.h>
23#endif
24
25namespace llvm {
26namespace orc {
27namespace rt_bootstrap {
28
31public:
33
37
38 Error deinitialize(const std::vector<ExecutorAddr> &Bases);
39 Error release(const std::vector<ExecutorAddr> &Bases);
40
41 Error shutdown() override;
42 void addBootstrapSymbols(StringMap<ExecutorAddr> &M) override;
43
44private:
45 struct Allocation {
46 std::vector<shared::WrapperFunctionCall> DeinitializationActions;
47 };
48 using AllocationMap = DenseMap<ExecutorAddr, Allocation>;
49
50 struct Reservation {
51 size_t Size;
52 std::vector<ExecutorAddr> Allocations;
53#if defined(_WIN32)
54 HANDLE SharedMemoryFile;
55#endif
56 };
57 using ReservationMap = DenseMap<void *, Reservation>;
58
60 reserveWrapper(const char *ArgData, size_t ArgSize);
61
63 initializeWrapper(const char *ArgData, size_t ArgSize);
64
66 deinitializeWrapper(const char *ArgData, size_t ArgSize);
67
69 releaseWrapper(const char *ArgData, size_t ArgSize);
70
71#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
72 std::atomic<int> SharedMemoryCount{0};
73#endif
74
75 std::mutex Mutex;
76 ReservationMap Reservations;
77 AllocationMap Allocations;
78};
79
80} // namespace rt_bootstrap
81} // namespace orc
82} // namespace llvm
83#endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_EXECUTORSHAREDMEMORYMAPPERSERVICE_H
#define LLVM_ABI
Definition Compiler.h:213
This file defines the DenseMap class.
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:133
Represents an address in the executor process.
This is an optimization pass for GlobalISel generic memory operations.