LLVM 23.0.0git
SelfExecutorProcessControl.h
Go to the documentation of this file.
1//===-- SelfExecutorProcessControl.h - EPC for in-process JITs --*- 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// Executor process control implementation for JITs that run JIT'd code in the
10// same process.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_EXECUTIONENGINE_ORC_SELFEXECUTORPROCESSCONTROL_H
15#define LLVM_EXECUTIONENGINE_ORC_SELFEXECUTORPROCESSCONTROL_H
16
18
19#include <memory>
20
21namespace llvm::orc {
22
23/// A ExecutorProcessControl implementation targeting the current process.
25public:
27 std::shared_ptr<SymbolStringPool> SSP, std::unique_ptr<TaskDispatcher> D,
29 std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr);
30
31 /// Create a SelfExecutorProcessControl with the given symbol string pool and
32 /// memory manager.
33 /// If no symbol string pool is given then one will be created.
34 /// If no memory manager is given a jitlink::InProcessMemoryManager will
35 /// be created and used by default.
37 Create(std::shared_ptr<SymbolStringPool> SSP = nullptr,
38 std::unique_ptr<TaskDispatcher> D = nullptr,
39 std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr = nullptr);
40
42 ArrayRef<std::string> Args) override;
43
45
46 Expected<int32_t> runAsIntFunction(ExecutorAddr IntFnAddr, int Arg) override;
47
48 void callWrapperAsync(ExecutorAddr WrapperFnAddr,
49 IncomingWFRHandler OnComplete,
50 ArrayRef<char> ArgBuffer) override;
51
53
55
56 Error disconnect() override;
57
58private:
59 class InProcessDylibManager : public DylibManager {
60 public:
61 InProcessDylibManager(char GlobalManglingPrefix);
62 Expected<tpctypes::DylibHandle> loadDylib(const char *DylibPath) override;
63 void
64 lookupSymbolsAsync(ArrayRef<LookupRequest> Request,
65 DylibManager::SymbolLookupCompleteFn Complete) override;
66
67 private:
68 char GlobalManglingPrefix;
69 };
70
72 jitDispatchViaWrapperFunctionManager(void *Ctx, const void *FnTag,
73 const char *Data, size_t Size);
74
75 std::unique_ptr<jitlink::JITLinkMemoryManager> OwnedMemMgr;
76#ifdef __APPLE__
77 std::unique_ptr<UnwindInfoManager> UnwindInfoMgr;
78#endif // __APPLE__
79};
80
81} // namespace llvm::orc
82
83#endif // LLVM_EXECUTIONENGINE_ORC_SELFEXECUTORPROCESSCONTROL_H
#define LLVM_ABI
Definition Compiler.h:213
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
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
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
unique_function< void(Expected< std::vector< tpctypes::LookupResult > >)> SymbolLookupCompleteFn
Represents an address in the executor process.
A handler or incoming WrapperFunctionBuffers – either return values from callWrapper* calls,...
std::unique_ptr< TaskDispatcher > D
std::shared_ptr< SymbolStringPool > SSP
jitlink::JITLinkMemoryManager * MemMgr
ExecutorProcessControl(std::shared_ptr< SymbolStringPool > SSP, std::unique_ptr< TaskDispatcher > D)
Expected< std::unique_ptr< MemoryAccess > > createDefaultMemoryAccess() override
Create a default MemoryAccess for the target process.
SelfExecutorProcessControl(std::shared_ptr< SymbolStringPool > SSP, std::unique_ptr< TaskDispatcher > D, Triple TargetTriple, unsigned PageSize, std::unique_ptr< jitlink::JITLinkMemoryManager > MemMgr)
Error disconnect() override
Disconnect from the target process.
Expected< int32_t > runAsVoidFunction(ExecutorAddr VoidFnAddr) override
Run function with a int (*)(void) signature.
Expected< int32_t > runAsMain(ExecutorAddr MainFnAddr, ArrayRef< std::string > Args) override
Run function with a main-like signature.
void callWrapperAsync(ExecutorAddr WrapperFnAddr, IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer) override
Run a wrapper function in the executor.
Expected< std::unique_ptr< DylibManager > > createDefaultDylibMgr() override
Create a default DylibManager for the target process.
static Expected< std::unique_ptr< SelfExecutorProcessControl > > Create(std::shared_ptr< SymbolStringPool > SSP=nullptr, std::unique_ptr< TaskDispatcher > D=nullptr, std::unique_ptr< jitlink::JITLinkMemoryManager > MemMgr=nullptr)
Create a SelfExecutorProcessControl with the given symbol string pool and memory manager.
Expected< int32_t > runAsIntFunction(ExecutorAddr IntFnAddr, int Arg) override
Run function with a int (*)(int) signature.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:221