3#include <asmjit/asmjit.h>
4#include <plugify/mem_addr.hpp>
5#include <plugify/method.hpp>
27 explicit JitCall(std::weak_ptr<asmjit::JitRuntime> rt);
51 typedef const uint64_t* Data;
58 arguments.reserve(count);
69 uint64_t& arg = arguments.emplace_back(0);
78 return arguments.data();
82 std::vector<uint64_t> arguments;
90 template<
typename T,
typename...Args>
92 std::construct_at((T*)
GetReturnPtr(), std::forward<Args>(args)...);
121 return (int8_t*) &ret[0];
125 volatile uint64_t ret[2]{};
128 enum class WaitType {
134 using CallingFunc = void(*)(Parameters::Data params,
const Return*);
135 using HiddenParam = bool(*)(ValueType);
176 std::string_view
GetError() noexcept {
return !_function && _errorCode ? _errorCode :
""; }
196 std::weak_ptr<asmjit::JitRuntime> _rt;
200 const char* _errorCode{};
Class encapsulates architecture-, OS- and compiler-specific function call semantics in a virtual "bin...
MemAddr GetJitFunc(MethodHandle method, MemAddr target, WaitType waitType=WaitType::None, HiddenParam hidden=&ValueUtils::IsHiddenParam)
Get a dynamically created function based on the method reference.
JitCall(const JitCall &other)=delete
Copy constructor.
JitCall(JitCall &&other) noexcept
Move constructor.
JitCall & operator=(JitCall &&other) noexcept
Move assignment operator for JitCall.
MemAddr GetTargetFunc() const noexcept
Get the target associated with the object.
MemAddr GetFunction() const noexcept
Get a dynamically created function.
MemAddr GetJitFunc(const asmjit::FuncSignature &sig, MemAddr target, WaitType waitType, bool hidden)
Get a dynamically created function based on the raw signature.
JitCall(std::weak_ptr< asmjit::JitRuntime > rt)
Constructor.
JitCall & operator=(const JitCall &other)=delete
Copy assignment operator for JitCall.
std::string_view GetError() noexcept
Get the error message, if any.
A wrapper class for memory addresses, providing utility functions for pointer manipulation.
A handle class for the Method structure.
constexpr bool IsHiddenParam(ValueType type) noexcept
Checks if a given ValueType is considered a hidden object parameter.
Structure to represent function parameters.
Data GetDataPtr() const noexcept
Get a pointer to the argument storage.
Parameters(size_t count)
Constructor.
void AddArgument(T val)
Set the value of the argument at next available position.
void SetReturn(T val) const noexcept
Set the return value.
int8_t * GetReturnPtr() const noexcept
Get a pointer to the return value.
T GetReturn() const noexcept
Get the value of the return.
void ConstructAt(Args &&... args) const noexcept
Constructs an object of type T at the memory location.