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);
45 typedef const uint64_t* Data;
52 arguments.reserve(count);
63 uint64_t& arg = arguments.emplace_back(0);
72 return arguments.data();
76 std::vector<uint64_t> arguments;
84 template<
typename T,
typename...Args>
86 std::construct_at((T*)
GetReturnPtr(), std::forward<Args>(args)...);
115 return (int8_t*) &ret[0];
119 volatile uint64_t ret[2]{};
122 enum class WaitType {
128 using CallingFunc = void(*)(Parameters::Data params,
const Return*);
129 using HiddenParam = bool(*)(ValueType);
170 std::string_view
GetError() noexcept {
return !_function && _errorCode ? _errorCode :
""; }
173 std::weak_ptr<asmjit::JitRuntime> _rt;
177 const char* _errorCode{};
Class encapsulates architecture-, OS- and compiler-specific function call semantics in a virtual "bin...
MemAddr GetJitFunc(MethodRef method, MemAddr target, WaitType waitType=WaitType::None, HiddenParam hidden=&ValueUtils::IsHiddenParam)
Get a dynamically created function based on the method reference.
JitCall(JitCall &&other) noexcept
Move constructor.
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.
std::string_view GetError() noexcept
Get the error message, if any.
A wrapper class for memory addresses, providing utility functions for pointer manipulation.
A reference 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.
void AddArgument(T val)
Set the value of the argument at next available position.
Parameters(uint8_t count)
Constructor.
void SetReturn(T val) const noexcept
Set 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.
int8_t * GetReturnPtr() const noexcept
Get a pointer to the return value.