Compare commits
7 commits
abcf24a79b
...
ddb09e5486
Author | SHA1 | Date | |
---|---|---|---|
ddb09e5486 | |||
01c01e30ee | |||
ba20e5c2f5 | |||
020ad29a8c | |||
4982dcfaa5 | |||
677148bdca | |||
f088f028f3 |
16 changed files with 68 additions and 264 deletions
|
@ -310,6 +310,7 @@ endif()
|
||||||
if (ARCHITECTURE_arm64 AND (ANDROID OR PLATFORM_LINUX))
|
if (ARCHITECTURE_arm64 AND (ANDROID OR PLATFORM_LINUX))
|
||||||
set(HAS_NCE 1)
|
set(HAS_NCE 1)
|
||||||
add_compile_definitions(HAS_NCE=1)
|
add_compile_definitions(HAS_NCE=1)
|
||||||
|
find_package(oaknut 2.0.1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (YUZU_ROOM)
|
if (YUZU_ROOM)
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
|
|
||||||
find_package(PkgConfig QUIET)
|
|
||||||
pkg_search_module(sirit QUIET IMPORTED_TARGET sirit)
|
|
||||||
find_package_handle_standard_args(sirit
|
|
||||||
REQUIRED_VARS sirit_LINK_LIBRARIES
|
|
||||||
VERSION_VAR sirit_VERSION
|
|
||||||
)
|
|
2
externals/cpmfile.json
vendored
2
externals/cpmfile.json
vendored
|
@ -10,7 +10,7 @@
|
||||||
"repo": "eden-emulator/sirit",
|
"repo": "eden-emulator/sirit",
|
||||||
"sha": "db1f1e8ab5",
|
"sha": "db1f1e8ab5",
|
||||||
"hash": "73eb3a042848c63a10656545797e85f40d142009dfb7827384548a385e1e28e1ac72f42b25924ce530d58275f8638554281e884d72f9c7aaf4ed08690a414b05",
|
"hash": "73eb3a042848c63a10656545797e85f40d142009dfb7827384548a385e1e28e1ac72f42b25924ce530d58275f8638554281e884d72f9c7aaf4ed08690a414b05",
|
||||||
"find_args": "MODULE",
|
"find_args": "CONFIG",
|
||||||
"options": [
|
"options": [
|
||||||
"SIRIT_USE_SYSTEM_SPIRV_HEADERS ON"
|
"SIRIT_USE_SYSTEM_SPIRV_HEADERS ON"
|
||||||
]
|
]
|
||||||
|
|
|
@ -32,7 +32,6 @@ add_library(
|
||||||
atomic_ops.h
|
atomic_ops.h
|
||||||
bit_cast.h
|
bit_cast.h
|
||||||
bit_field.h
|
bit_field.h
|
||||||
bit_set.h
|
|
||||||
bit_util.h
|
bit_util.h
|
||||||
bounded_threadsafe_queue.h
|
bounded_threadsafe_queue.h
|
||||||
cityhash.cpp
|
cityhash.cpp
|
||||||
|
|
|
@ -1,86 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <bit>
|
|
||||||
|
|
||||||
#include "common/alignment.h"
|
|
||||||
#include "common/bit_util.h"
|
|
||||||
#include "common/common_types.h"
|
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
namespace impl {
|
|
||||||
|
|
||||||
template <typename Storage, size_t N>
|
|
||||||
class BitSet {
|
|
||||||
|
|
||||||
public:
|
|
||||||
constexpr BitSet() = default;
|
|
||||||
|
|
||||||
constexpr void SetBit(size_t i) {
|
|
||||||
this->words[i / FlagsPerWord] |= GetBitMask(i % FlagsPerWord);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr void ClearBit(size_t i) {
|
|
||||||
this->words[i / FlagsPerWord] &= ~GetBitMask(i % FlagsPerWord);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr size_t CountLeadingZero() const {
|
|
||||||
for (size_t i = 0; i < NumWords; i++) {
|
|
||||||
if (this->words[i]) {
|
|
||||||
return FlagsPerWord * i + CountLeadingZeroImpl(this->words[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FlagsPerWord * NumWords;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr size_t GetNextSet(size_t n) const {
|
|
||||||
for (size_t i = (n + 1) / FlagsPerWord; i < NumWords; i++) {
|
|
||||||
Storage word = this->words[i];
|
|
||||||
if (!IsAligned(n + 1, FlagsPerWord)) {
|
|
||||||
word &= GetBitMask(n % FlagsPerWord) - 1;
|
|
||||||
}
|
|
||||||
if (word) {
|
|
||||||
return FlagsPerWord * i + CountLeadingZeroImpl(word);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FlagsPerWord * NumWords;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
static_assert(std::is_unsigned_v<Storage>);
|
|
||||||
static_assert(sizeof(Storage) <= sizeof(u64));
|
|
||||||
|
|
||||||
static constexpr size_t FlagsPerWord = BitSize<Storage>();
|
|
||||||
static constexpr size_t NumWords = AlignUp(N, FlagsPerWord) / FlagsPerWord;
|
|
||||||
|
|
||||||
static constexpr auto CountLeadingZeroImpl(Storage word) {
|
|
||||||
return std::countl_zero(static_cast<unsigned long long>(word)) -
|
|
||||||
(BitSize<unsigned long long>() - FlagsPerWord);
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr Storage GetBitMask(size_t bit) {
|
|
||||||
return Storage(1) << (FlagsPerWord - 1 - bit);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::array<Storage, NumWords> words{};
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace impl
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
using BitSet8 = impl::BitSet<u8, N>;
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
using BitSet16 = impl::BitSet<u16, N>;
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
using BitSet32 = impl::BitSet<u32, N>;
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
using BitSet64 = impl::BitSet<u64, N>;
|
|
||||||
|
|
||||||
} // namespace Common
|
|
|
@ -1,13 +1,13 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "common/heap_tracker.h"
|
#include "common/heap_tracker.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/assert.h"
|
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ HeapTracker::~HeapTracker() = default;
|
||||||
|
|
||||||
void HeapTracker::Map(size_t virtual_offset, size_t host_offset, size_t length,
|
void HeapTracker::Map(size_t virtual_offset, size_t host_offset, size_t length,
|
||||||
MemoryPermission perm, bool is_separate_heap) {
|
MemoryPermission perm, bool is_separate_heap) {
|
||||||
|
bool rebuild_required = false;
|
||||||
|
|
||||||
// When mapping other memory, map pages immediately.
|
// When mapping other memory, map pages immediately.
|
||||||
if (!is_separate_heap) {
|
if (!is_separate_heap) {
|
||||||
m_buffer.Map(virtual_offset, host_offset, length, perm, false);
|
m_buffer.Map(virtual_offset, host_offset, length, perm, false);
|
||||||
|
@ -57,11 +59,29 @@ void HeapTracker::Map(size_t virtual_offset, size_t host_offset, size_t length,
|
||||||
|
|
||||||
// Insert into mappings.
|
// Insert into mappings.
|
||||||
m_map_count++;
|
m_map_count++;
|
||||||
m_mappings.insert(*map);
|
const auto it = m_mappings.insert(*map);
|
||||||
|
|
||||||
|
// Update tick before possible rebuild.
|
||||||
|
it->tick = m_tick++;
|
||||||
|
|
||||||
|
// Check if we need to rebuild.
|
||||||
|
if (m_resident_map_count >= m_max_resident_map_count) {
|
||||||
|
rebuild_required = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Map the area.
|
||||||
|
m_buffer.Map(it->vaddr, it->paddr, it->size, it->perm, false);
|
||||||
|
|
||||||
|
// This map is now resident.
|
||||||
|
it->is_resident = true;
|
||||||
|
m_resident_map_count++;
|
||||||
|
m_resident_mappings.insert(*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, map.
|
if (rebuild_required) {
|
||||||
this->DeferredMapSeparateHeap(virtual_offset);
|
// A rebuild was required, so perform it now.
|
||||||
|
this->RebuildSeparateHeapAddressSpace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeapTracker::Unmap(size_t virtual_offset, size_t size, bool is_separate_heap) {
|
void HeapTracker::Unmap(size_t virtual_offset, size_t size, bool is_separate_heap) {
|
||||||
|
@ -147,7 +167,8 @@ void HeapTracker::Protect(size_t virtual_offset, size_t size, MemoryPermission p
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clamp to end.
|
// Clamp to end.
|
||||||
next = (std::min)(next, end);
|
next = std::min(next, end);
|
||||||
|
|
||||||
// Reprotect, if we need to.
|
// Reprotect, if we need to.
|
||||||
if (should_protect) {
|
if (should_protect) {
|
||||||
m_buffer.Protect(cur, next - cur, perm);
|
m_buffer.Protect(cur, next - cur, perm);
|
||||||
|
@ -158,51 +179,6 @@ void HeapTracker::Protect(size_t virtual_offset, size_t size, MemoryPermission p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HeapTracker::DeferredMapSeparateHeap(u8* fault_address) {
|
|
||||||
if (m_buffer.IsInVirtualRange(fault_address)) {
|
|
||||||
return this->DeferredMapSeparateHeap(fault_address - m_buffer.VirtualBasePointer());
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HeapTracker::DeferredMapSeparateHeap(size_t virtual_offset) {
|
|
||||||
bool rebuild_required = false;
|
|
||||||
|
|
||||||
{
|
|
||||||
std::scoped_lock lk{m_lock};
|
|
||||||
|
|
||||||
// Check to ensure this was a non-resident separate heap mapping.
|
|
||||||
const auto it = this->GetNearestHeapMapLocked(virtual_offset);
|
|
||||||
if (it == m_mappings.end() || it->is_resident) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update tick before possible rebuild.
|
|
||||||
it->tick = m_tick++;
|
|
||||||
|
|
||||||
// Check if we need to rebuild.
|
|
||||||
if (m_resident_map_count > m_max_resident_map_count) {
|
|
||||||
rebuild_required = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Map the area.
|
|
||||||
m_buffer.Map(it->vaddr, it->paddr, it->size, it->perm, false);
|
|
||||||
|
|
||||||
// This map is now resident.
|
|
||||||
it->is_resident = true;
|
|
||||||
m_resident_map_count++;
|
|
||||||
m_resident_mappings.insert(*it);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rebuild_required) {
|
|
||||||
// A rebuild was required, so perform it now.
|
|
||||||
this->RebuildSeparateHeapAddressSpace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeapTracker::RebuildSeparateHeapAddressSpace() {
|
void HeapTracker::RebuildSeparateHeapAddressSpace() {
|
||||||
std::scoped_lock lk{m_rebuild_lock, m_lock};
|
std::scoped_lock lk{m_rebuild_lock, m_lock};
|
||||||
|
|
||||||
|
@ -213,8 +189,8 @@ void HeapTracker::RebuildSeparateHeapAddressSpace() {
|
||||||
// Despite being worse in theory, this has proven to be better in practice than more
|
// Despite being worse in theory, this has proven to be better in practice than more
|
||||||
// regularly dumping a smaller amount, because it significantly reduces average case
|
// regularly dumping a smaller amount, because it significantly reduces average case
|
||||||
// lock contention.
|
// lock contention.
|
||||||
std::size_t const desired_count = (std::min)(m_resident_map_count, m_max_resident_map_count) / 2;
|
const size_t desired_count = std::min(m_resident_map_count, m_max_resident_map_count) / 2;
|
||||||
std::size_t const evict_count = m_resident_map_count - desired_count;
|
const size_t evict_count = m_resident_map_count - desired_count;
|
||||||
auto it = m_resident_mappings.begin();
|
auto it = m_resident_mappings.begin();
|
||||||
|
|
||||||
for (size_t i = 0; i < evict_count && it != m_resident_mappings.end(); i++) {
|
for (size_t i = 0; i < evict_count && it != m_resident_mappings.end(); i++) {
|
||||||
|
|
|
@ -1224,12 +1224,11 @@ if (HAS_NCE)
|
||||||
arm/nce/patcher.h
|
arm/nce/patcher.h
|
||||||
arm/nce/visitor_base.h
|
arm/nce/visitor_base.h
|
||||||
)
|
)
|
||||||
target_link_libraries(core PRIVATE merry::mcl merry::oaknut)
|
target_link_libraries(core PRIVATE merry::oaknut)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64)
|
if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64)
|
||||||
target_sources(core PRIVATE
|
target_sources(core PRIVATE
|
||||||
arm/dynarmic/arm_dynarmic.cpp
|
|
||||||
arm/dynarmic/arm_dynarmic.h
|
arm/dynarmic/arm_dynarmic.h
|
||||||
arm/dynarmic/arm_dynarmic_64.cpp
|
arm/dynarmic/arm_dynarmic_64.cpp
|
||||||
arm/dynarmic/arm_dynarmic_64.h
|
arm/dynarmic/arm_dynarmic_64.h
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
|
|
||||||
#include "common/signal_chain.h"
|
|
||||||
|
|
||||||
#include "core/arm/dynarmic/arm_dynarmic.h"
|
|
||||||
#include "core/hle/kernel/k_process.h"
|
|
||||||
#include "core/memory.h"
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
thread_local Core::Memory::Memory* g_current_memory{};
|
|
||||||
std::once_flag g_registered{};
|
|
||||||
struct sigaction g_old_segv {};
|
|
||||||
|
|
||||||
void HandleSigSegv(int sig, siginfo_t* info, void* ctx) {
|
|
||||||
if (g_current_memory && g_current_memory->InvalidateSeparateHeap(info->si_addr)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return g_old_segv.sa_sigaction(sig, info, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
ScopedJitExecution::ScopedJitExecution(Kernel::KProcess* process) {
|
|
||||||
g_current_memory = std::addressof(process->GetMemory());
|
|
||||||
}
|
|
||||||
|
|
||||||
ScopedJitExecution::~ScopedJitExecution() {
|
|
||||||
g_current_memory = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScopedJitExecution::RegisterHandler() {
|
|
||||||
std::call_once(g_registered, [] {
|
|
||||||
struct sigaction sa {};
|
|
||||||
sa.sa_sigaction = &HandleSigSegv;
|
|
||||||
sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
|
|
||||||
Common::SigAction(SIGSEGV, std::addressof(sa), std::addressof(g_old_segv));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Core
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
@ -26,24 +29,4 @@ constexpr HaltReason TranslateHaltReason(Dynarmic::HaltReason hr) {
|
||||||
return static_cast<HaltReason>(hr);
|
return static_cast<HaltReason>(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
|
|
||||||
class ScopedJitExecution {
|
|
||||||
public:
|
|
||||||
explicit ScopedJitExecution(Kernel::KProcess* process);
|
|
||||||
~ScopedJitExecution();
|
|
||||||
static void RegisterHandler();
|
|
||||||
};
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
class ScopedJitExecution {
|
|
||||||
public:
|
|
||||||
explicit ScopedJitExecution(Kernel::KProcess* process) {}
|
|
||||||
~ScopedJitExecution() {}
|
|
||||||
static void RegisterHandler() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
|
@ -343,15 +343,11 @@ bool ArmDynarmic32::IsInThumbMode() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
HaltReason ArmDynarmic32::RunThread(Kernel::KThread* thread) {
|
HaltReason ArmDynarmic32::RunThread(Kernel::KThread* thread) {
|
||||||
ScopedJitExecution sj(thread->GetOwnerProcess());
|
|
||||||
|
|
||||||
m_jit->ClearExclusiveState();
|
m_jit->ClearExclusiveState();
|
||||||
return TranslateHaltReason(m_jit->Run());
|
return TranslateHaltReason(m_jit->Run());
|
||||||
}
|
}
|
||||||
|
|
||||||
HaltReason ArmDynarmic32::StepThread(Kernel::KThread* thread) {
|
HaltReason ArmDynarmic32::StepThread(Kernel::KThread* thread) {
|
||||||
ScopedJitExecution sj(thread->GetOwnerProcess());
|
|
||||||
|
|
||||||
m_jit->ClearExclusiveState();
|
m_jit->ClearExclusiveState();
|
||||||
return TranslateHaltReason(m_jit->Step());
|
return TranslateHaltReason(m_jit->Step());
|
||||||
}
|
}
|
||||||
|
@ -393,7 +389,6 @@ ArmDynarmic32::ArmDynarmic32(System& system, bool uses_wall_clock, Kernel::KProc
|
||||||
m_cp15(std::make_shared<DynarmicCP15>(*this)), m_core_index{core_index} {
|
m_cp15(std::make_shared<DynarmicCP15>(*this)), m_core_index{core_index} {
|
||||||
auto& page_table_impl = process->GetPageTable().GetBasePageTable().GetImpl();
|
auto& page_table_impl = process->GetPageTable().GetBasePageTable().GetImpl();
|
||||||
m_jit = MakeJit(&page_table_impl);
|
m_jit = MakeJit(&page_table_impl);
|
||||||
ScopedJitExecution::RegisterHandler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArmDynarmic32::~ArmDynarmic32() = default;
|
ArmDynarmic32::~ArmDynarmic32() = default;
|
||||||
|
|
|
@ -374,15 +374,11 @@ std::shared_ptr<Dynarmic::A64::Jit> ArmDynarmic64::MakeJit(Common::PageTable* pa
|
||||||
}
|
}
|
||||||
|
|
||||||
HaltReason ArmDynarmic64::RunThread(Kernel::KThread* thread) {
|
HaltReason ArmDynarmic64::RunThread(Kernel::KThread* thread) {
|
||||||
ScopedJitExecution sj(thread->GetOwnerProcess());
|
|
||||||
|
|
||||||
m_jit->ClearExclusiveState();
|
m_jit->ClearExclusiveState();
|
||||||
return TranslateHaltReason(m_jit->Run());
|
return TranslateHaltReason(m_jit->Run());
|
||||||
}
|
}
|
||||||
|
|
||||||
HaltReason ArmDynarmic64::StepThread(Kernel::KThread* thread) {
|
HaltReason ArmDynarmic64::StepThread(Kernel::KThread* thread) {
|
||||||
ScopedJitExecution sj(thread->GetOwnerProcess());
|
|
||||||
|
|
||||||
m_jit->ClearExclusiveState();
|
m_jit->ClearExclusiveState();
|
||||||
return TranslateHaltReason(m_jit->Step());
|
return TranslateHaltReason(m_jit->Step());
|
||||||
}
|
}
|
||||||
|
@ -422,7 +418,6 @@ ArmDynarmic64::ArmDynarmic64(System& system, bool uses_wall_clock, Kernel::KProc
|
||||||
auto& page_table = process->GetPageTable().GetBasePageTable();
|
auto& page_table = process->GetPageTable().GetBasePageTable();
|
||||||
auto& page_table_impl = page_table.GetImpl();
|
auto& page_table_impl = page_table.GetImpl();
|
||||||
m_jit = MakeJit(&page_table_impl, page_table.GetAddressSpaceWidth());
|
m_jit = MakeJit(&page_table_impl, page_table.GetAddressSpaceWidth());
|
||||||
ScopedJitExecution::RegisterHandler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArmDynarmic64::~ArmDynarmic64() = default;
|
ArmDynarmic64::~ArmDynarmic64() = default;
|
||||||
|
|
|
@ -27,11 +27,11 @@ template <>
|
||||||
struct std::hash<PatchCacheKey> {
|
struct std::hash<PatchCacheKey> {
|
||||||
size_t operator()(const PatchCacheKey& key) const {
|
size_t operator()(const PatchCacheKey& key) const {
|
||||||
// Simple XOR hash of first few bytes
|
// Simple XOR hash of first few bytes
|
||||||
size_t hash = 0;
|
size_t hash_ = 0;
|
||||||
for (size_t i = 0; i < key.module_id.size(); ++i) {
|
for (size_t i = 0; i < key.module_id.size(); ++i) {
|
||||||
hash ^= static_cast<size_t>(key.module_id[i]) << ((i % sizeof(size_t)) * 8);
|
hash_ ^= static_cast<size_t>(key.module_id[i]) << ((i % sizeof(size_t)) * 8);
|
||||||
}
|
}
|
||||||
return hash ^ std::hash<uintptr_t>{}(key.offset);
|
return hash_ ^ std::hash<uintptr_t>{}(key.offset);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
@ -5,10 +8,12 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <bit>
|
#include <bit>
|
||||||
|
#include <bitset>
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#include "common/alignment.h"
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/bit_set.h"
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/concepts.h"
|
#include "common/concepts.h"
|
||||||
|
|
||||||
|
@ -159,7 +164,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_queues[priority].PushBack(core, member)) {
|
if (m_queues[priority].PushBack(core, member)) {
|
||||||
m_available_priorities[core].SetBit(priority);
|
m_available_priorities[core].set(std::size_t(priority));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +177,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_queues[priority].PushFront(core, member)) {
|
if (m_queues[priority].PushFront(core, member)) {
|
||||||
m_available_priorities[core].SetBit(priority);
|
m_available_priorities[core].set(std::size_t(priority));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,14 +190,19 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_queues[priority].Remove(core, member)) {
|
if (m_queues[priority].Remove(core, member)) {
|
||||||
m_available_priorities[core].ClearBit(priority);
|
m_available_priorities[core].reset(std::size_t(priority));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Member* GetFront(s32 core) const {
|
constexpr Member* GetFront(s32 core) const {
|
||||||
ASSERT(IsValidCore(core));
|
ASSERT(IsValidCore(core));
|
||||||
|
|
||||||
const s32 priority = static_cast<s32>(m_available_priorities[core].CountLeadingZero());
|
const s32 priority = s32([](auto const& e) {
|
||||||
|
for (size_t i = 0; i < e.size(); ++i)
|
||||||
|
if (e[i])
|
||||||
|
return i;
|
||||||
|
return e.size();
|
||||||
|
}(m_available_priorities[core]));
|
||||||
if (priority <= LowestPriority) {
|
if (priority <= LowestPriority) {
|
||||||
return m_queues[priority].GetFront(core);
|
return m_queues[priority].GetFront(core);
|
||||||
} else {
|
} else {
|
||||||
|
@ -211,16 +221,22 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<size_t N>
|
||||||
|
constexpr size_t GetNextSet(std::bitset<N> const& bit, size_t n) const {
|
||||||
|
for (size_t i = n + 1; i < bit.size(); i++)
|
||||||
|
if (bit[i])
|
||||||
|
return i;
|
||||||
|
return bit.size();
|
||||||
|
}
|
||||||
|
|
||||||
constexpr Member* GetNext(s32 core, const Member* member) const {
|
constexpr Member* GetNext(s32 core, const Member* member) const {
|
||||||
ASSERT(IsValidCore(core));
|
ASSERT(IsValidCore(core));
|
||||||
|
|
||||||
Member* next = member->GetPriorityQueueEntry(core).GetNext();
|
Member* next = member->GetPriorityQueueEntry(core).GetNext();
|
||||||
if (next == nullptr) {
|
if (next == nullptr) {
|
||||||
const s32 priority = static_cast<s32>(
|
s32 priority = s32(GetNextSet(m_available_priorities[core], member->GetPriority()));
|
||||||
m_available_priorities[core].GetNextSet(member->GetPriority()));
|
if (priority <= LowestPriority)
|
||||||
if (priority <= LowestPriority) {
|
|
||||||
next = m_queues[priority].GetFront(core);
|
next = m_queues[priority].GetFront(core);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
@ -250,7 +266,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<KPerCoreQueue, NumPriority> m_queues{};
|
std::array<KPerCoreQueue, NumPriority> m_queues{};
|
||||||
std::array<Common::BitSet64<NumPriority>, NumCores> m_available_priorities{};
|
std::array<std::bitset<NumPriority>, NumCores> m_available_priorities{};
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1230,22 +1230,7 @@ bool Memory::InvalidateNCE(Common::ProcessAddress vaddr, size_t size) {
|
||||||
if (rasterizer) {
|
if (rasterizer) {
|
||||||
impl->InvalidateGPUMemory(ptr, size);
|
impl->InvalidateGPUMemory(ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
if (!rasterizer && mapped) {
|
|
||||||
impl->buffer->DeferredMapSeparateHeap(GetInteger(vaddr));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return mapped && ptr != nullptr;
|
return mapped && ptr != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Memory::InvalidateSeparateHeap(void* fault_address) {
|
|
||||||
#ifdef __linux__
|
|
||||||
return impl->buffer->DeferredMapSeparateHeap(static_cast<u8*>(fault_address));
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Core::Memory
|
} // namespace Core::Memory
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
|
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
@ -492,8 +495,6 @@ public:
|
||||||
|
|
||||||
bool InvalidateNCE(Common::ProcessAddress vaddr, size_t size);
|
bool InvalidateNCE(Common::ProcessAddress vaddr, size_t size);
|
||||||
|
|
||||||
bool InvalidateSeparateHeap(void* fault_address);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
|
|
||||||
|
|
|
@ -374,7 +374,7 @@ endif()
|
||||||
|
|
||||||
target_compile_options(dynarmic PRIVATE ${DYNARMIC_CXX_FLAGS})
|
target_compile_options(dynarmic PRIVATE ${DYNARMIC_CXX_FLAGS})
|
||||||
target_link_libraries(dynarmic
|
target_link_libraries(dynarmic
|
||||||
PRIVATE
|
PUBLIC
|
||||||
fmt::fmt
|
fmt::fmt
|
||||||
merry::mcl
|
merry::mcl
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue