aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Common/Collections/IntervalTree.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2022-05-02 20:30:02 -0300
committerGitHub <noreply@github.com>2022-05-02 20:30:02 -0300
commit95017b8c66f70406e926b278ecdd6d4ec0a93110 (patch)
tree3fc8e9a515f9adda96cf0c9d6983a375045ba68c /Ryujinx.Common/Collections/IntervalTree.cs
parent4a892fbdc9059504358ddf41c27576032e1ce414 (diff)
Support memory aliasing (#2954)1.1.110
* Back to the origins: Make memory manager take guest PA rather than host address once again * Direct mapping with alias support on Windows * Fixes and remove more of the emulated shared memory * Linux support * Make shared and transfer memory not depend on SharedMemoryStorage * More efficient view mapping on Windows (no more restricted to 4KB pages at a time) * Handle potential access violations caused by partial unmap * Implement host mapping using shared memory on Linux * Add new GetPhysicalAddressChecked method, used to ensure the virtual address is mapped before address translation Also align GetRef behaviour with software memory manager * We don't need a mirrorable memory block for software memory manager mode * Disable memory aliasing tests while we don't have shared memory support on Mac * Shared memory & SIGBUS handler for macOS * Fix typo + nits + re-enable memory tests * Set MAP_JIT_DARWIN on x86 Mac too * Add back the address space mirror * Only set MAP_JIT_DARWIN if we are mapping as executable * Disable aliasing tests again (still fails on Mac) * Fix UnmapView4KB (by not casting size to int) * Use ref counting on memory blocks to delay closing the shared memory handle until all blocks using it are disposed * Address PR feedback * Make RO hold a reference to the guest process memory manager to avoid early disposal Co-authored-by: nastys <nastys@users.noreply.github.com>
Diffstat (limited to 'Ryujinx.Common/Collections/IntervalTree.cs')
-rw-r--r--Ryujinx.Common/Collections/IntervalTree.cs36
1 files changed, 17 insertions, 19 deletions
diff --git a/Ryujinx.Common/Collections/IntervalTree.cs b/Ryujinx.Common/Collections/IntervalTree.cs
index e1b81f4e..514fd534 100644
--- a/Ryujinx.Common/Collections/IntervalTree.cs
+++ b/Ryujinx.Common/Collections/IntervalTree.cs
@@ -1,7 +1,5 @@
using System;
-using System.Collections;
using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace Ryujinx.Common.Collections
@@ -212,7 +210,7 @@ namespace Ryujinx.Common.Collections
/// <param name="overlaps">Overlaps array to place results in</param>
/// <param name="overlapCount">Overlaps count to update</param>
private void GetValues(IntervalTreeNode<K, V> node, K start, K end, ref V[] overlaps, ref int overlapCount)
- {
+ {
if (node == null || start.CompareTo(node.Max) >= 0)
{
return;
@@ -624,7 +622,7 @@ namespace Ryujinx.Common.Collections
node.Right = LeftOf(right);
if (node.Right != null)
{
- node.Right.Parent = node;
+ node.Right.Parent = node;
}
IntervalTreeNode<K, V> nodeParent = ParentOf(node);
right.Parent = nodeParent;
@@ -638,7 +636,7 @@ namespace Ryujinx.Common.Collections
}
else
{
- nodeParent.Right = right;
+ nodeParent.Right = right;
}
right.Left = node;
node.Parent = right;
@@ -779,37 +777,37 @@ namespace Ryujinx.Common.Collections
/// </summary>
/// <typeparam name="K">Key type of the node</typeparam>
/// <typeparam name="V">Value type of the node</typeparam>
- internal class IntervalTreeNode<K, V>
+ class IntervalTreeNode<K, V>
{
- internal bool Color = true;
- internal IntervalTreeNode<K, V> Left = null;
- internal IntervalTreeNode<K, V> Right = null;
- internal IntervalTreeNode<K, V> Parent = null;
+ public bool Color = true;
+ public IntervalTreeNode<K, V> Left = null;
+ public IntervalTreeNode<K, V> Right = null;
+ public IntervalTreeNode<K, V> Parent = null;
/// <summary>
/// The start of the range.
/// </summary>
- internal K Start;
+ public K Start;
/// <summary>
/// The end of the range - maximum of all in the Values list.
/// </summary>
- internal K End;
+ public K End;
/// <summary>
/// The maximum end value of this node and all its children.
/// </summary>
- internal K Max;
+ public K Max;
- internal List<RangeNode<K, V>> Values;
+ public List<RangeNode<K, V>> Values;
public IntervalTreeNode(K start, K end, V value, IntervalTreeNode<K, V> parent)
{
- this.Start = start;
- this.End = end;
- this.Max = end;
- this.Values = new List<RangeNode<K, V>> { new RangeNode<K, V>(start, end, value) };
- this.Parent = parent;
+ Start = start;
+ End = end;
+ Max = end;
+ Values = new List<RangeNode<K, V>> { new RangeNode<K, V>(start, end, value) };
+ Parent = parent;
}
}
}