aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/Common/BitMap.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-12-16 17:07:42 -0300
committerGitHub <noreply@github.com>2020-12-16 17:07:42 -0300
commit61634dd415fb71b3ae85871a0873d00195b0900c (patch)
tree233134f41a93d22d96f78b269047a1a050e87aba /ARMeilleure/Common/BitMap.cs
parent11222516c4b5042cd8da6fdd72f53ee736139b66 (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 'ARMeilleure/Common/BitMap.cs')
-rw-r--r--ARMeilleure/Common/BitMap.cs34
1 files changed, 27 insertions, 7 deletions
diff --git a/ARMeilleure/Common/BitMap.cs b/ARMeilleure/Common/BitMap.cs
index 35100536..b1c9a673 100644
--- a/ARMeilleure/Common/BitMap.cs
+++ b/ARMeilleure/Common/BitMap.cs
@@ -4,12 +4,12 @@ using System.Numerics;
namespace ARMeilleure.Common
{
- class BitMap : IEnumerator<int>
+ class BitMap : IEnumerator<int>, IEnumerable<int>
{
private const int IntSize = 64;
private const int IntMask = IntSize - 1;
- private List<long> _masks;
+ private readonly List<long> _masks;
private int _enumIndex;
private long _enumMask;
@@ -57,7 +57,7 @@ namespace ARMeilleure.Common
EnsureCapacity(bit + 1);
int wordIndex = bit / IntSize;
- int wordBit = bit & IntMask;
+ int wordBit = bit & IntMask;
long wordMask = 1L << wordBit;
@@ -76,7 +76,7 @@ namespace ARMeilleure.Common
EnsureCapacity(bit + 1);
int wordIndex = bit / IntSize;
- int wordBit = bit & IntMask;
+ int wordBit = bit & IntMask;
long wordMask = 1L << wordBit;
@@ -88,11 +88,26 @@ namespace ARMeilleure.Common
EnsureCapacity(bit + 1);
int wordIndex = bit / IntSize;
- int wordBit = bit & IntMask;
+ int wordBit = bit & IntMask;
return (_masks[wordIndex] & (1L << wordBit)) != 0;
}
+ public int FindFirstUnset()
+ {
+ for (int index = 0; index < _masks.Count; index++)
+ {
+ long mask = _masks[index];
+
+ if (mask != -1L)
+ {
+ return BitOperations.TrailingZeroCount(~mask) + index * IntSize;
+ }
+ }
+
+ return _masks.Count * IntSize;
+ }
+
public bool Set(BitMap map)
{
EnsureCapacity(map._masks.Count * IntSize);
@@ -135,7 +150,7 @@ namespace ARMeilleure.Common
return modified;
}
- #region IEnumerable<long> Methods
+ #region IEnumerable<long> Methods
// Note: The bit enumerator is embedded in this class to avoid creating garbage when enumerating.
@@ -147,6 +162,11 @@ namespace ARMeilleure.Common
}
}
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
public IEnumerator<int> GetEnumerator()
{
Reset();
@@ -180,6 +200,6 @@ namespace ARMeilleure.Common
public void Dispose() { }
-#endregion
+ #endregion
}
} \ No newline at end of file