Skip to content

Commit

Permalink
Initial work
Browse files Browse the repository at this point in the history
  • Loading branch information
gdkchan authored and marysaka committed Jan 9, 2020
1 parent f617fb5 commit 1876b34
Show file tree
Hide file tree
Showing 518 changed files with 15,141 additions and 12,457 deletions.
7 changes: 2 additions & 5 deletions ARMeilleure/Instructions/InstEmitMemoryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,9 @@ private static Operand EmitPtPointerLoad(ArmEmitterContext context, Operand addr
}
while (bit < context.Memory.AddressSpaceBits);

if (!context.Memory.HasWriteWatchSupport)
{
Operand hasFlagSet = context.BitwiseAnd(pte, Const((long)MemoryManager.PteFlagsMask));
Operand hasFlagSet = context.BitwiseAnd(pte, Const((long)MemoryManager.PteFlagsMask));

context.BranchIfTrue(lblFallbackPath, hasFlagSet);
}
context.BranchIfTrue(lblFallbackPath, hasFlagSet);

Operand pageOffset = context.BitwiseAnd(address, Const(address.Type, MemoryManager.PageMask));

Expand Down
37 changes: 0 additions & 37 deletions ARMeilleure/Memory/IMemory.cs

This file was deleted.

24 changes: 0 additions & 24 deletions ARMeilleure/Memory/MemoryManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ namespace ARMeilleure.Memory
{
public static class MemoryManagement
{
public static bool HasWriteWatchSupport => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

public static IntPtr Allocate(ulong size)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
Expand Down Expand Up @@ -88,27 +86,5 @@ public static bool Free(IntPtr address)
throw new PlatformNotSupportedException();
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool GetModifiedPages(
IntPtr address,
IntPtr size,
IntPtr[] addresses,
out ulong count)
{
// This is only supported on windows, but returning
// false (failed) is also valid for platforms without
// write tracking support on the OS.
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return MemoryManagementWindows.GetModifiedPages(address, size, addresses, out count);
}
else
{
count = 0;

return false;
}
}
}
}
37 changes: 0 additions & 37 deletions ARMeilleure/Memory/MemoryManagementWindows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ private enum MemoryProtection : uint
WriteCombineModifierflag = 0x400
}

private enum WriteWatchFlags : uint
{
None = 0,
Reset = 1
}

[DllImport("kernel32.dll")]
private static extern IntPtr VirtualAlloc(
IntPtr lpAddress,
Expand All @@ -62,15 +56,6 @@ private static extern bool VirtualFree(
IntPtr dwSize,
AllocationType dwFreeType);

[DllImport("kernel32.dll")]
private static extern int GetWriteWatch(
WriteWatchFlags dwFlags,
IntPtr lpBaseAddress,
IntPtr dwRegionSize,
IntPtr[] lpAddresses,
ref ulong lpdwCount,
out uint lpdwGranularity);

public static IntPtr Allocate(IntPtr size)
{
const AllocationType flags =
Expand Down Expand Up @@ -130,27 +115,5 @@ public static bool Free(IntPtr address)
{
return VirtualFree(address, IntPtr.Zero, AllocationType.Release);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool GetModifiedPages(
IntPtr address,
IntPtr size,
IntPtr[] addresses,
out ulong count)
{
ulong pagesCount = (ulong)addresses.Length;

int result = GetWriteWatch(
WriteWatchFlags.Reset,
address,
size,
addresses,
ref pagesCount,
out uint granularity);

count = pagesCount;

return result == 0;
}
}
}
Loading

0 comments on commit 1876b34

Please sign in to comment.