LLVM 22.0.0git
SimpleRemoteMemoryMapper.h
Go to the documentation of this file.
1//===- SimpleRemoteMemoryMapper.h - Remote memory mapper --------*- 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 memory mapper that uses EPC calls to implement reserve, initialize,
10// deinitialize, and release.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_EXECUTIONENGINE_ORC_SIMPLEREMOTEMEMORYMAPPER_H
15#define LLVM_EXECUTIONENGINE_ORC_SIMPLEREMOTEMEMORYMAPPER_H
16
18
19namespace llvm::orc {
20
21/// Manages remote memory by making SPS-based EPC calls.
23public:
31
33
36 return std::make_unique<SimpleRemoteMemoryMapper>(EPC, SAs);
37 }
38
39 unsigned int getPageSize() override { return EPC.getPageSize(); }
40
41 /// Reserves memory in the remote process by calling a remote
42 /// SPS-wrapper-function with signature
43 ///
44 /// SPSExpected<SPSExecutorAddr>(uint64_t Size).
45 ///
46 /// On success, returns the base address of the reserved range.
47 void reserve(size_t NumBytes, OnReservedFunction OnReserved) override;
48
50 size_t ContentSize) override;
51
52 /// Initializes memory within a previously reserved region (applying
53 /// protections and running any finalization actions) by calling a remote
54 /// SPS-wrapper-function with signature
55 ///
56 /// SPSExpected<SPSExecutorAddr>(SPSFinalizeRequest)
57 ///
58 /// On success, returns a key that can be used to deinitialize the region.
59 void initialize(AllocInfo &AI, OnInitializedFunction OnInitialized) override;
60
61 /// Given a series of keys from previous initialize calls, deinitialize
62 /// previously initialized memory regions (running dealloc actions, resetting
63 /// permissions and decommitting if possible) by calling a remote
64 /// SPS-wrapper-function with signature
65 ///
66 /// SPSError(SPSSequence<SPSExecutorAddr> Keys)
67 ///
68 void deinitialize(ArrayRef<ExecutorAddr> Allocations,
69 OnDeinitializedFunction OnDeInitialized) override;
70
71 /// Given a sequence of base addresses from previous reserve calls, release
72 /// the underlying ranges (deinitializing any remaining regions within them)
73 /// by calling a remote SPS-wrapper-function with signature
74 ///
75 /// SPSError(SPSSequence<SPSExecutorAddr> Bases)
76 ///
77 void release(ArrayRef<ExecutorAddr> Reservations,
78 OnReleasedFunction OnRelease) override;
79
80private:
82 SymbolAddrs SAs;
83};
84
85} // namespace llvm::orc
86
87#endif // LLVM_EXECUTIONENGINE_ORC_SIMPLEREMOTEMEMORYMAPPER_H
bbsections prepare
#define LLVM_ABI
Definition Compiler.h:213
#define G(x, y, z)
Definition MD5.cpp:56
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
Tagged union holding either a T or a Error.
Definition Error.h:485
Represents an address in the executor process.
ExecutorProcessControl supports interaction with a JIT target process.
Manages mapping, content transfer and protections for JIT memory.
static Expected< std::unique_ptr< SimpleRemoteMemoryMapper > > Create(ExecutorProcessControl &EPC, SymbolAddrs SAs)
SimpleRemoteMemoryMapper(ExecutorProcessControl &EPC, SymbolAddrs SAs)
Summary of memprof metadata on allocations.