From aa3b1e8996ba43552ba859771f1a577755af255a Mon Sep 17 00:00:00 2001 From: riperiperi Date: Mon, 24 Jun 2024 20:37:58 +0100 Subject: [PATCH] Use sparse memory when memory isn't software. --- src/ARMeilleure/Common/IAddressTable.cs | 6 ------ src/Ryujinx.Cpu/AddressTable.cs | 15 ++++++--------- src/Ryujinx.Cpu/Jit/JitCpuContext.cs | 2 +- .../LightningJit/LightningJitCpuContext.cs | 2 +- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/ARMeilleure/Common/IAddressTable.cs b/src/ARMeilleure/Common/IAddressTable.cs index 4924b448b..5be934163 100644 --- a/src/ARMeilleure/Common/IAddressTable.cs +++ b/src/ARMeilleure/Common/IAddressTable.cs @@ -4,12 +4,6 @@ namespace ARMeilleure.Common { public interface IAddressTable : IDisposable where TEntry : unmanaged { - /// - /// If true, the sparse 2-level table should be used to improve performance. - /// If false, the platform doesn't properly support it, or will be negatively impacted. - /// - static bool UseSparseTable { get; } - /// /// Gets the bits used by the of the instance. /// diff --git a/src/Ryujinx.Cpu/AddressTable.cs b/src/Ryujinx.Cpu/AddressTable.cs index 306a6f4d7..d2f03c801 100644 --- a/src/Ryujinx.Cpu/AddressTable.cs +++ b/src/Ryujinx.Cpu/AddressTable.cs @@ -1,3 +1,4 @@ +using ARMeilleure.Memory; using Ryujinx.Common; using Ryujinx.Common.Logging; using Ryujinx.Cpu.Signal; @@ -17,12 +18,6 @@ namespace ARMeilleure.Common /// Type of the value public unsafe class AddressTable : IAddressTable where TEntry : unmanaged { - /// - /// If true, the sparse 2-level table should be used to improve performance. - /// If false, the platform doesn't properly support it, or will be negatively impacted. - /// - public static bool UseSparseTable => true; - private readonly struct AddressTablePage { public readonly bool IsSparse; @@ -177,13 +172,15 @@ namespace ARMeilleure.Common /// /// Create an instance for an ARM function table. - /// Selects the best table structure for A32/A64, taking into account whether sparse mapping is supported. + /// Selects the best table structure for A32/A64, taking into account the selected memory manager type. /// /// True if the guest is A64, false otherwise + /// Memory manager type /// An for ARM function lookup - public static AddressTable CreateForArm(bool for64Bits) + public static AddressTable CreateForArm(bool for64Bits, MemoryManagerType type) { - bool sparse = UseSparseTable; + // Assume software memory means that we don't want to use any signal handlers. + bool sparse = type != MemoryManagerType.SoftwareMmu && type != MemoryManagerType.SoftwarePageTable; return new AddressTable(AddressTablePresets.GetArmPreset(for64Bits, sparse), sparse); } diff --git a/src/Ryujinx.Cpu/Jit/JitCpuContext.cs b/src/Ryujinx.Cpu/Jit/JitCpuContext.cs index 5a9c9dcfe..bd512a758 100644 --- a/src/Ryujinx.Cpu/Jit/JitCpuContext.cs +++ b/src/Ryujinx.Cpu/Jit/JitCpuContext.cs @@ -15,7 +15,7 @@ namespace Ryujinx.Cpu.Jit public JitCpuContext(ITickSource tickSource, IMemoryManager memory, bool for64Bit) { _tickSource = tickSource; - _functionTable = AddressTable.CreateForArm(for64Bit); + _functionTable = AddressTable.CreateForArm(for64Bit, memory.Type); _translator = new Translator(new JitMemoryAllocator(forJit: true), memory, _functionTable); diff --git a/src/Ryujinx.Cpu/LightningJit/LightningJitCpuContext.cs b/src/Ryujinx.Cpu/LightningJit/LightningJitCpuContext.cs index b0b5ad72f..c39e0e67e 100644 --- a/src/Ryujinx.Cpu/LightningJit/LightningJitCpuContext.cs +++ b/src/Ryujinx.Cpu/LightningJit/LightningJitCpuContext.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Cpu.LightningJit public LightningJitCpuContext(ITickSource tickSource, IMemoryManager memory, bool for64Bit) { _tickSource = tickSource; - _functionTable = AddressTable.CreateForArm(for64Bit); + _functionTable = AddressTable.CreateForArm(for64Bit, memory.Type); _translator = new Translator(memory, _functionTable);