mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-11-28 19:54:29 +01:00
61634dd415
* 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>
37 lines
1001 B
C#
37 lines
1001 B
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Threading;
|
|
|
|
namespace ARMeilleure.Translation
|
|
{
|
|
class TranslatedFunction
|
|
{
|
|
private const int MinCallsForRejit = 100;
|
|
|
|
private readonly GuestFunction _func; // Ensure that this delegate will not be garbage collected.
|
|
|
|
private int _callCount;
|
|
|
|
public ulong GuestSize { get; }
|
|
public bool HighCq { get; }
|
|
public IntPtr FuncPtr { get; }
|
|
|
|
public TranslatedFunction(GuestFunction func, ulong guestSize, bool highCq)
|
|
{
|
|
_func = func;
|
|
GuestSize = guestSize;
|
|
HighCq = highCq;
|
|
FuncPtr = Marshal.GetFunctionPointerForDelegate(func);
|
|
}
|
|
|
|
public ulong Execute(State.ExecutionContext context)
|
|
{
|
|
return _func(context.NativeContextPtr);
|
|
}
|
|
|
|
public bool ShouldRejit()
|
|
{
|
|
return !HighCq && Interlocked.Increment(ref _callCount) == MinCallsForRejit;
|
|
}
|
|
}
|
|
} |