diff options
| author | TSR Berry <20988865+TSRBerry@users.noreply.github.com> | 2023-04-08 01:22:00 +0200 |
|---|---|---|
| committer | Mary <thog@protonmail.com> | 2023-04-27 23:51:14 +0200 |
| commit | cee712105850ac3385cd0091a923438167433f9f (patch) | |
| tree | 4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /ARMeilleure/Signal/TestMethods.cs | |
| parent | cd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff) | |
Move solution and projects to src
Diffstat (limited to 'ARMeilleure/Signal/TestMethods.cs')
| -rw-r--r-- | ARMeilleure/Signal/TestMethods.cs | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/ARMeilleure/Signal/TestMethods.cs b/ARMeilleure/Signal/TestMethods.cs deleted file mode 100644 index e2ecad24..00000000 --- a/ARMeilleure/Signal/TestMethods.cs +++ /dev/null @@ -1,84 +0,0 @@ -using ARMeilleure.IntermediateRepresentation; -using ARMeilleure.Translation; -using System; -using System.Runtime.InteropServices; -using static ARMeilleure.IntermediateRepresentation.Operand.Factory; - -namespace ARMeilleure.Signal -{ - public struct NativeWriteLoopState - { - public int Running; - public int Error; - } - - public static class TestMethods - { - public delegate bool DebugPartialUnmap(); - public delegate int DebugThreadLocalMapGetOrReserve(int threadId, int initialState); - public delegate void DebugNativeWriteLoop(IntPtr nativeWriteLoopPtr, IntPtr writePtr); - - public static DebugPartialUnmap GenerateDebugPartialUnmap() - { - EmitterContext context = new EmitterContext(); - - var result = WindowsPartialUnmapHandler.EmitRetryFromAccessViolation(context); - - context.Return(result); - - // Compile and return the function. - - ControlFlowGraph cfg = context.GetControlFlowGraph(); - - OperandType[] argTypes = new OperandType[] { OperandType.I64 }; - - return Compiler.Compile(cfg, argTypes, OperandType.I32, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map<DebugPartialUnmap>(); - } - - public static DebugThreadLocalMapGetOrReserve GenerateDebugThreadLocalMapGetOrReserve(IntPtr structPtr) - { - EmitterContext context = new EmitterContext(); - - var result = WindowsPartialUnmapHandler.EmitThreadLocalMapIntGetOrReserve(context, structPtr, context.LoadArgument(OperandType.I32, 0), context.LoadArgument(OperandType.I32, 1)); - - context.Return(result); - - // Compile and return the function. - - ControlFlowGraph cfg = context.GetControlFlowGraph(); - - OperandType[] argTypes = new OperandType[] { OperandType.I64 }; - - return Compiler.Compile(cfg, argTypes, OperandType.I32, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map<DebugThreadLocalMapGetOrReserve>(); - } - - public static DebugNativeWriteLoop GenerateDebugNativeWriteLoop() - { - EmitterContext context = new EmitterContext(); - - // Loop a write to the target address until "running" is false. - - Operand structPtr = context.Copy(context.LoadArgument(OperandType.I64, 0)); - Operand writePtr = context.Copy(context.LoadArgument(OperandType.I64, 1)); - - Operand loopLabel = Label(); - context.MarkLabel(loopLabel); - - context.Store(writePtr, Const(12345)); - - Operand running = context.Load(OperandType.I32, structPtr); - - context.BranchIfTrue(loopLabel, running); - - context.Return(); - - // Compile and return the function. - - ControlFlowGraph cfg = context.GetControlFlowGraph(); - - OperandType[] argTypes = new OperandType[] { OperandType.I64 }; - - return Compiler.Compile(cfg, argTypes, OperandType.None, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map<DebugNativeWriteLoop>(); - } - } -} |
