diff options
author | gdkchan <gab.dark.100@gmail.com> | 2020-12-16 17:07:42 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-16 17:07:42 -0300 |
commit | 61634dd415fb71b3ae85871a0873d00195b0900c (patch) | |
tree | 233134f41a93d22d96f78b269047a1a050e87aba /Ryujinx.Cpu | |
parent | 11222516c4b5042cd8da6fdd72f53ee736139b66 (diff) |
Clear JIT cache on exit (#1518)
* Initial cache memory allocator implementation
* Get rid of CallFlag
* Perform cache cleanup on exit
* Basic cache invalidation
* Thats not how conditionals works in C# it seems
* Set PTC version to PR number
* Address PR feedback
* Update InstEmitFlowHelper.cs
* Flag clear on address is no longer needed
* Do not include exit block in function size calculation
* Dispose jump table
* For future use
* InternalVersion = 1519 (force retest).
Co-authored-by: LDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com>
Diffstat (limited to 'Ryujinx.Cpu')
-rw-r--r-- | Ryujinx.Cpu/CpuContext.cs | 16 | ||||
-rw-r--r-- | Ryujinx.Cpu/MemoryManager.cs | 10 |
2 files changed, 24 insertions, 2 deletions
diff --git a/Ryujinx.Cpu/CpuContext.cs b/Ryujinx.Cpu/CpuContext.cs index 275fcc68..45040586 100644 --- a/Ryujinx.Cpu/CpuContext.cs +++ b/Ryujinx.Cpu/CpuContext.cs @@ -10,10 +10,22 @@ namespace Ryujinx.Cpu public CpuContext(MemoryManager memory) { _translator = new Translator(new JitMemoryAllocator(), memory); + memory.UnmapEvent += UnmapHandler; } - public static ExecutionContext CreateExecutionContext() => new ExecutionContext(new JitMemoryAllocator()); + private void UnmapHandler(ulong address, ulong size) + { + _translator.InvalidateJitCacheRegion(address, size); + } - public void Execute(ExecutionContext context, ulong address) => _translator.Execute(context, address); + public static ExecutionContext CreateExecutionContext() + { + return new ExecutionContext(new JitMemoryAllocator()); + } + + public void Execute(ExecutionContext context, ulong address) + { + _translator.Execute(context, address); + } } } diff --git a/Ryujinx.Cpu/MemoryManager.cs b/Ryujinx.Cpu/MemoryManager.cs index 36ae9b32..5a778e64 100644 --- a/Ryujinx.Cpu/MemoryManager.cs +++ b/Ryujinx.Cpu/MemoryManager.cs @@ -40,6 +40,8 @@ namespace Ryujinx.Cpu public MemoryTracking Tracking { get; } + internal event Action<ulong, ulong> UnmapEvent; + /// <summary> /// Creates a new instance of the memory manager. /// </summary> @@ -100,6 +102,14 @@ namespace Ryujinx.Cpu /// <param name="size">Size of the range to be unmapped</param> public void Unmap(ulong va, ulong size) { + // If size is 0, there's nothing to unmap, just exit early. + if (size == 0) + { + return; + } + + UnmapEvent?.Invoke(va, size); + ulong remainingSize = size; ulong oVa = va; while (remainingSize != 0) |