Browse Source

use dmem for swap buffers, restore full jit sizes

eden-orbis-ps4
lizzie 5 days ago
parent
commit
6356c611eb
  1. 12
      src/common/virtual_buffer.cpp
  2. 2
      src/core/arm/dynarmic/arm_dynarmic_32.cpp
  3. 2
      src/core/arm/dynarmic/arm_dynarmic_64.cpp
  4. 9
      src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp

12
src/common/virtual_buffer.cpp

@ -16,6 +16,7 @@
#include <fcntl.h>
#include <boost/container/static_vector.hpp>
#include <orbis/SystemService.h>
#include <orbis/libkernel.h>
typedef void (*SceKernelExceptionHandler)(int32_t, void*);
extern "C" int32_t sceKernelInstallExceptionHandler(int32_t signum, SceKernelExceptionHandler handler);
#endif
@ -143,8 +144,13 @@ void* AllocateMemoryPages(std::size_t size) noexcept {
#elif defined(__OPENORBIS__)
void* addr;
if (size <= 8192 * 4096) {
addr = malloc(size);
LOG_WARNING(HW_Memory, "Using DMem for {} bytes area @ {}", size, addr);
size_t align = 16384;
size_t len = (size + align - 1) / align * align;
off_t offset = 0;
ASSERT(sceKernelAllocateDirectMemory(0, ORBIS_KERNEL_MAIN_DMEM_SIZE, len, align, ORBIS_KERNEL_WB_ONION, &offset) == 0);
ASSERT(sceKernelMapDirectMemory(&addr, len, ORBIS_KERNEL_PROT_CPU_RW, 0, offset, len) == 0);
ASSERT(sceKernelMprotect(addr, len, VM_PROT_ALL) == 0);
LOG_WARNING(HW_Memory, "Using DMem for {} bytes area @ {}", len, addr);
ASSERT(addr != nullptr);
} else {
addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0);
@ -166,7 +172,7 @@ void FreeMemoryPages(void* addr, [[maybe_unused]] std::size_t size) noexcept {
VirtualFree(addr, 0, MEM_RELEASE);
#elif defined(__OPENORBIS__)
if (size <= 8192 * 4096) {
free(addr);
sceKernelCheckedReleaseDirectMemory(off_t(addr), size_t(size));
} else {
int rc = munmap(addr, size);
ASSERT(rc == 0);

2
src/core/arm/dynarmic/arm_dynarmic_32.cpp

@ -204,7 +204,7 @@ void ArmDynarmic32::MakeJit(Common::PageTable* page_table) {
// Code cache size
#if defined(__OPENORBIS__)
config.code_cache_size = std::uint32_t(32_MiB);
config.code_cache_size = std::uint32_t(128_MiB);
#elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
config.code_cache_size = std::uint32_t(128_MiB);
#else

2
src/core/arm/dynarmic/arm_dynarmic_64.cpp

@ -255,7 +255,7 @@ void ArmDynarmic64::MakeJit(Common::PageTable* page_table, std::size_t address_s
// Code cache size
#if defined(__OPENORBIS__)
config.code_cache_size = std::uint32_t(32_MiB);
config.code_cache_size = std::uint32_t(128_MiB);
#elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
config.code_cache_size = std::uint32_t(128_MiB);
#else

9
src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp

@ -58,13 +58,8 @@ const std::array<Xbyak::Reg64, ABI_PARAM_COUNT> BlockOfCode::ABI_PARAMS = {Block
namespace {
#ifdef __OPENORBIS__
constexpr size_t CONSTANT_POOL_SIZE = 8 * 4096;
constexpr size_t PRELUDE_COMMIT_SIZE = 8 * 4096;
#else
constexpr size_t CONSTANT_POOL_SIZE = 2 * 1024 * 1024;
constexpr size_t PRELUDE_COMMIT_SIZE = 16 * 1024 * 1024;
#endif
class CustomXbyakAllocator : public Xbyak::Allocator {
public:
@ -247,9 +242,7 @@ bool IsUnderRosetta() {
} // anonymous namespace
BlockOfCode::BlockOfCode(RunCodeCallbacks cb, JitStateInfo jsi, size_t total_code_size, std::function<void(BlockOfCode&)> rcp) noexcept
#ifdef __OPENORBIS__
: Xbyak::CodeGenerator(total_code_size, Xbyak::AutoGrow, &s_allocator)
#elif defined(DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT)
#if defined(DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT)
: Xbyak::CodeGenerator(total_code_size, Xbyak::DontSetProtectRWE, &s_allocator)
#else
: Xbyak::CodeGenerator(total_code_size, nullptr, &s_allocator)

Loading…
Cancel
Save