diff options
author | Fernando S <fsahmkow27@gmail.com> | 2022-04-13 23:20:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-13 23:20:34 +0200 |
commit | 276764cfe9856fb8dfd60d8135cb9b613ef18831 (patch) | |
tree | 9f0420dabd5345577226a16ed017485bbbe8e8d2 /src/core/hle/service/jit/jit_context.h | |
parent | Merge pull request #8165 from bunnei/ensure-session-port-cleanup (diff) | |
parent | service: jit: Implement the JIT service (diff) | |
download | yuzu-276764cfe9856fb8dfd60d8135cb9b613ef18831.tar yuzu-276764cfe9856fb8dfd60d8135cb9b613ef18831.tar.gz yuzu-276764cfe9856fb8dfd60d8135cb9b613ef18831.tar.bz2 yuzu-276764cfe9856fb8dfd60d8135cb9b613ef18831.tar.lz yuzu-276764cfe9856fb8dfd60d8135cb9b613ef18831.tar.xz yuzu-276764cfe9856fb8dfd60d8135cb9b613ef18831.tar.zst yuzu-276764cfe9856fb8dfd60d8135cb9b613ef18831.zip |
Diffstat (limited to 'src/core/hle/service/jit/jit_context.h')
-rw-r--r-- | src/core/hle/service/jit/jit_context.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/core/hle/service/jit/jit_context.h b/src/core/hle/service/jit/jit_context.h new file mode 100644 index 000000000..d8bf76cff --- /dev/null +++ b/src/core/hle/service/jit/jit_context.h @@ -0,0 +1,65 @@ +// Copyright 2022 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <memory> +#include <span> +#include <string> + +#include "common/common_types.h" + +namespace Core::Memory { +class Memory; +} + +namespace Service::JIT { + +class JITContextImpl; + +class JITContext { +public: + explicit JITContext(Core::Memory::Memory& memory); + ~JITContext(); + + [[nodiscard]] bool LoadNRO(std::span<const u8> data); + void MapProcessMemory(VAddr dest_address, std::size_t size); + + template <typename T, typename... Ts> + u64 CallFunction(VAddr func, T argument, Ts... rest) { + static_assert(std::is_trivially_copyable_v<T>); + PushArgument(&argument, sizeof(argument)); + + if constexpr (sizeof...(rest) > 0) { + return CallFunction(func, rest...); + } else { + return CallFunction(func); + } + } + + u64 CallFunction(VAddr func); + VAddr GetHelper(const std::string& name); + + template <typename T> + VAddr AddHeap(T argument) { + return AddHeap(&argument, sizeof(argument)); + } + VAddr AddHeap(const void* data, size_t size); + + template <typename T> + T GetHeap(VAddr location) { + static_assert(std::is_trivially_copyable_v<T>); + T result; + GetHeap(location, &result, sizeof(result)); + return result; + } + void GetHeap(VAddr location, void* data, size_t size); + +private: + std::unique_ptr<JITContextImpl> impl; + + void PushArgument(const void* data, size_t size); +}; + +} // namespace Service::JIT |