diff options
Diffstat (limited to 'ARMeilleure/Memory/ReservedRegion.cs')
| -rw-r--r-- | ARMeilleure/Memory/ReservedRegion.cs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/ARMeilleure/Memory/ReservedRegion.cs b/ARMeilleure/Memory/ReservedRegion.cs index 521019ad..dc6eb9da 100644 --- a/ARMeilleure/Memory/ReservedRegion.cs +++ b/ARMeilleure/Memory/ReservedRegion.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace ARMeilleure.Memory { @@ -8,20 +6,22 @@ namespace ARMeilleure.Memory { private const int DefaultGranularity = 65536; // Mapping granularity in Windows. - public IntPtr Pointer { get; } + public IJitMemoryBlock Block { get; } - private ulong _maxSize; - private ulong _sizeGranularity; + public IntPtr Pointer => Block.Pointer; + + private readonly ulong _maxSize; + private readonly ulong _sizeGranularity; private ulong _currentSize; - public ReservedRegion(ulong maxSize, ulong granularity = 0) + public ReservedRegion(IJitMemoryAllocator allocator, ulong maxSize, ulong granularity = 0) { if (granularity == 0) { granularity = DefaultGranularity; } - Pointer = MemoryManagement.Reserve(maxSize); + Block = allocator.Reserve(maxSize); _maxSize = maxSize; _sizeGranularity = granularity; _currentSize = 0; @@ -43,7 +43,7 @@ namespace ARMeilleure.Memory { ulong overflowBytes = desiredSize - _currentSize; ulong moreToCommit = (((_sizeGranularity - 1) + overflowBytes) / _sizeGranularity) * _sizeGranularity; // Round up. - MemoryManagement.Commit(new IntPtr((long)Pointer + (long)_currentSize), moreToCommit); + Block.Commit(_currentSize, moreToCommit); _currentSize += moreToCommit; } } |
