LLVM 22.0.0git
SimpleExecutorMemoryManager.h
Go to the documentation of this file.
1//===---------------- SimpleExecutorMemoryManager.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// A simple allocator class suitable for basic remote-JIT use.
10//
11// FIXME: The functionality in this file should be moved to the ORC runtime.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEEXECUTORMEMORYMANAGER_H
16#define LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEEXECUTORMEMORYMANAGER_H
17
18#include "llvm/ADT/DenseMap.h"
24#include "llvm/Support/Error.h"
25
26#include <mutex>
27
28namespace llvm {
29namespace orc {
30namespace rt_bootstrap {
31
32/// Simple page-based allocator.
34public:
36
39 Error deinitialize(const std::vector<ExecutorAddr> &InitKeys);
40 Error release(const std::vector<ExecutorAddr> &Bases);
41
42 Error shutdown() override;
44
45private:
46 struct RegionInfo {
47 size_t Size = 0;
48 std::vector<shared::WrapperFunctionCall> DeallocActions;
49 };
50
51 struct SlabInfo {
52 using RegionMap = std::map<ExecutorAddr, RegionInfo>;
53 size_t Size = 0;
54 RegionMap Regions;
55 };
56
57 using SlabMap = std::map<void *, SlabInfo>;
58
59 /// Get a reference to the slab information for the slab containing the given
60 /// address.
61 Expected<SlabInfo &> getSlabInfo(ExecutorAddr A, StringRef Context);
62
63 /// Get a reference to the slab information for the slab *covering* the given
64 /// range. The given range must be a subrange of e(possibly equal to) the
65 /// range of the slab itself.
66 Expected<SlabInfo &> getSlabInfo(ExecutorAddrRange R, StringRef Context);
67
68 /// Create a RegionInfo for the given range, which must not overlap any
69 /// existing region.
71 StringRef Context);
72
73 /// Get a reference to the region information for the given address. This
74 /// address must represent the start of an existing initialized region.
75 Expected<RegionInfo &> getRegionInfo(SlabInfo &Slab, ExecutorAddr A,
76 StringRef Context);
77
78 /// Get a reference to the region information for the given address. This
79 /// address must represent the start of an existing initialized region.
80 Expected<RegionInfo &> getRegionInfo(ExecutorAddr A, StringRef Context);
81
83 reserveWrapper(const char *ArgData, size_t ArgSize);
84
86 initializeWrapper(const char *ArgData, size_t ArgSize);
87
89 deinitializeWrapper(const char *ArgData, size_t ArgSize);
90
92 releaseWrapper(const char *ArgData, size_t ArgSize);
93
94 std::mutex M;
95 SlabMap Slabs;
96};
97
98} // end namespace rt_bootstrap
99} // end namespace orc
100} // end namespace llvm
101
102#endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEEXECUTORMEMORYMANAGER_H
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#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
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Represents an address in the executor process.
Error deinitialize(const std::vector< ExecutorAddr > &InitKeys)
Error release(const std::vector< ExecutorAddr > &Bases)
void addBootstrapSymbols(StringMap< ExecutorAddr > &M) override
This is an optimization pass for GlobalISel generic memory operations.
Represents an address range in the exceutor process.