LLVM 24.0.0git
SimpleRemoteMemoryMapper.cpp
Go to the documentation of this file.
1//===---- SimpleRemoteMemoryMapper.cpp - 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
10
12
13namespace llvm::orc {
14
18
20 OnReservedFunction OnReserved) {
21 B.Reserve(
22 [NumBytes, OnReserved = std::move(OnReserved)](
24 if (!Result)
25 return OnReserved(Result.takeError());
26 OnReserved(ExecutorAddrRange(*Result, NumBytes));
27 },
28 ES, B.Instance, static_cast<uint64_t>(NumBytes));
29}
30
32 ExecutorAddr Addr, size_t ContentSize) {
33 return G.allocateBuffer(ContentSize).data();
34}
35
37 OnInitializedFunction OnInitialized) {
38
40
42 FR.Segments.reserve(AI.Segments.size());
43
44 for (auto Seg : AI.Segments)
45 FR.Segments.push_back({Seg.AG, AI.MappingBase + Seg.Offset,
46 Seg.ContentSize + Seg.ZeroFillSize,
47 ArrayRef<char>(Seg.WorkingMem, Seg.ContentSize)});
48
49 B.Initialize(std::move(OnInitialized), ES, B.Instance, std::move(FR));
50}
51
53 ArrayRef<ExecutorAddr> Allocations,
55 B.Deinitialize(std::move(OnDeinitialized), ES, B.Instance, Allocations);
56}
57
59 OnReleasedFunction OnReleased) {
60 B.Release(std::move(OnReleased), ES, B.Instance, Bases);
61}
62
63} // namespace llvm::orc
unsigned uint64_t
#define G(x, y, z)
Definition MD5.cpp:55
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Tagged union holding either a T or a Error.
Definition Error.h:485
An ExecutionSession represents a running JIT program.
Definition Core.h:1111
Represents an address in the executor process.
unique_function< void(Error)> OnReleasedFunction
unique_function< void(Expected< ExecutorAddr >)> OnInitializedFunction
unique_function< void(Expected< ExecutorAddrRange >)> OnReservedFunction
unique_function< void(Error)> OnDeinitializedFunction
void initialize(AllocInfo &AI, OnInitializedFunction OnInitialized) override
Initializes memory within a previously reserved region, applying protections and running any finaliza...
char * prepare(jitlink::LinkGraph &G, ExecutorAddr Addr, size_t ContentSize) override
Provides working memory The LinkGraph parameter is included to allow implementations to allocate work...
SimpleRemoteMemoryMapper(ExecutionSession &ES, SimpleMemoryMapBindings B)
Create a SimpleRemoteMemoryMapper from a given set of memory-manager bindings.
void deinitialize(ArrayRef< ExecutorAddr > Allocations, OnDeinitializedFunction OnDeInitialized) override
Given a series of keys from previous initialize calls, deinitialize previously initialized memory reg...
void release(ArrayRef< ExecutorAddr > Reservations, OnReleasedFunction OnRelease) override
Given a sequence of base addresses from previous reserve calls, release the underlying ranges,...
void reserve(size_t NumBytes, OnReservedFunction OnReserved) override
Reserves memory in the executor, returning the base address of the reserved range on success.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1917
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:880
Represents an address range in the exceutor process.
Represents a single allocation containing multiple segments and initialization and deinitialization a...
std::vector< SegInfo > Segments
The resolved controller-side handle to an executor-side memory manager: the address of the manager in...
std::vector< SegFinalizeRequest > Segments