Go to the documentation of this file.
27 unsigned PageSize, std::unique_ptr<jitlink::JITLinkMemoryManager>
MemMgr)
32 OwnedMemMgr = std::make_unique<jitlink::InProcessMemoryManager>();
36 this->MemMgr = OwnedMemMgr.get();
39 GlobalManglingPrefix =
'_';
44 std::shared_ptr<SymbolStringPool> SSP,
45 std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr) {
52 return std::make_unique<SelfTargetProcessControl>(
59 auto Dylib = std::make_unique<sys::DynamicLibrary>(
61 if (!Dylib->isValid())
63 DynamicLibraries.push_back(
std::move(Dylib));
69 std::vector<tpctypes::LookupResult> R;
71 for (
auto &Elem : Request) {
72 auto *Dylib = jitTargetAddressToPointer<sys::DynamicLibrary *>(Elem.Handle);
74 [=](
const std::unique_ptr<sys::DynamicLibrary> &
DL) {
75 return DL.get() == Dylib;
79 R.push_back(std::vector<JITTargetAddress>());
80 for (
auto &KV : Elem.Symbols) {
82 std::string Tmp((*Sym).data() + !!GlobalManglingPrefix,
83 (*Sym).size() - !!GlobalManglingPrefix);
84 void *
Addr = Dylib->getAddressOfSymbol(Tmp.c_str());
88 MissingSymbols.push_back(Sym);
89 return make_error<SymbolsNotFound>(
std::move(MissingSymbols));
101 using MainTy =
int (*)(
int,
char *[]);
110 auto *WrapperFn = jitTargetAddressToFunction<WrapperFnTy>(WrapperFnAddr);
111 return WrapperFn(ArgBuffer.
data(), ArgBuffer.
size());
117 WriteResultFn OnWriteComplete) {
119 *jitTargetAddressToPointer<uint8_t *>(
W.Address) =
W.Value;
124 WriteResultFn OnWriteComplete) {
126 *jitTargetAddressToPointer<uint16_t *>(
W.Address) =
W.Value;
130 void SelfTargetProcessControl::writeUInt32s(ArrayRef<tpctypes::UInt32Write> Ws,
131 WriteResultFn OnWriteComplete) {
133 *jitTargetAddressToPointer<uint32_t *>(
W.Address) =
W.Value;
137 void SelfTargetProcessControl::writeUInt64s(ArrayRef<tpctypes::UInt64Write> Ws,
138 WriteResultFn OnWriteComplete) {
140 *jitTargetAddressToPointer<uint64_t *>(
W.Address) =
W.Value;
144 void SelfTargetProcessControl::writeBuffers(ArrayRef<tpctypes::BufferWrite> Ws,
145 WriteResultFn OnWriteComplete) {
147 memcpy(jitTargetAddressToPointer<char *>(
W.Address),
W.Buffer.data(),
This class represents lattice values for constants.
Expected< int32_t > runAsMain(JITTargetAddress MainFnAddr, ArrayRef< std::string > Args) override
Run function with a main-like signature.
std::shared_ptr< SymbolStringPool > SSP
Error disconnect() override
Disconnect from the target process.
static ErrorSuccess success()
Create a success value.
Triple - Helper class for working with autoconf configuration names.
Tagged union holding either a T or a Error.
Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath) override
Load the dynamic library at the given path and return a handle to it.
Expected< tpctypes::WrapperFunctionResult > runWrapper(JITTargetAddress WrapperFnAddr, ArrayRef< uint8_t > ArgBuffer) override
Run a wrapper function with signature:
static DynamicLibrary getPermanentLibrary(const char *filename, std::string *errMsg=nullptr)
This function permanently loads the dynamic library at the given path.
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
int runAsMain(int(*Main)(int, char *[]), ArrayRef< std::string > Args, Optional< StringRef > ProgramName=None)
Run a main function, returning the result.
static Expected< std::unique_ptr< SelfTargetProcessControl > > Create(std::shared_ptr< SymbolStringPool > SSP, std::unique_ptr< jitlink::JITLinkMemoryManager > MemMgr=nullptr)
Create a SelfTargetProcessControl with the given memory manager.
TargetProcessControl supports interaction with a JIT target process.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
SelfTargetProcessControl(std::shared_ptr< SymbolStringPool > SSP, Triple TargetTriple, unsigned PageSize, std::unique_ptr< jitlink::JITLinkMemoryManager > MemMgr)
static Expected< unsigned > getPageSize()
Get the process's page size.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
jitlink::JITLinkMemoryManager * MemMgr
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
JITTargetAddress pointerToJITTargetAddress(T *Ptr)
Convert a pointer to a JITTargetAddress.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
std::string getProcessTriple()
getProcessTriple() - Return an appropriate target triple for generating code to be loaded into the cu...
Lightweight error class with error context and mandatory checking.
C ABI compatible wrapper function result.
uint64_t JITTargetAddress
Represents an address in the target process's address space.
virtual ~TargetProcessControl()
size_t size() const
size - Get the array size.
Expected< std::vector< tpctypes::LookupResult > > lookupSymbols(ArrayRef< LookupRequest > Request) override
Search for symbols in the target process.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
std::vector< SymbolStringPtr > SymbolNameVector
A vector of symbol names.