diff options
author | gdkchan <gab.dark.100@gmail.com> | 2020-12-16 17:07:42 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-16 17:07:42 -0300 |
commit | 61634dd415fb71b3ae85871a0873d00195b0900c (patch) | |
tree | 233134f41a93d22d96f78b269047a1a050e87aba /ARMeilleure/Instructions/NativeInterface.cs | |
parent | 11222516c4b5042cd8da6fdd72f53ee736139b66 (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/Instructions/NativeInterface.cs')
-rw-r--r-- | ARMeilleure/Instructions/NativeInterface.cs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/ARMeilleure/Instructions/NativeInterface.cs b/ARMeilleure/Instructions/NativeInterface.cs index bc1be21d..b2b200b9 100644 --- a/ARMeilleure/Instructions/NativeInterface.cs +++ b/ARMeilleure/Instructions/NativeInterface.cs @@ -23,16 +23,16 @@ namespace ARMeilleure.Instructions } [ThreadStatic] - private static ThreadContext _context; + private static ThreadContext Context; public static void RegisterThread(ExecutionContext context, IMemoryManager memory, Translator translator) { - _context = new ThreadContext(context, memory, translator); + Context = new ThreadContext(context, memory, translator); } public static void UnregisterThread() { - _context = null; + Context = null; } public static void Break(ulong address, int imm) @@ -231,14 +231,24 @@ namespace ARMeilleure.Instructions public static ulong GetFunctionAddress(ulong address) { - TranslatedFunction function = _context.Translator.GetOrTranslate(address, GetContext().ExecutionMode); + return GetFunctionAddressWithHint(address, true); + } + + public static ulong GetFunctionAddressWithoutRejit(ulong address) + { + return GetFunctionAddressWithHint(address, false); + } + + private static ulong GetFunctionAddressWithHint(ulong address, bool hintRejit) + { + TranslatedFunction function = Context.Translator.GetOrTranslate(address, GetContext().ExecutionMode, hintRejit); return (ulong)function.FuncPtr.ToInt64(); } public static ulong GetIndirectFunctionAddress(ulong address, ulong entryAddress) { - TranslatedFunction function = _context.Translator.GetOrTranslate(address, GetContext().ExecutionMode); + TranslatedFunction function = Context.Translator.GetOrTranslate(address, GetContext().ExecutionMode, hintRejit: true); ulong ptr = (ulong)function.FuncPtr.ToInt64(); @@ -266,12 +276,12 @@ namespace ARMeilleure.Instructions public static ExecutionContext GetContext() { - return _context.Context; + return Context.Context; } public static IMemoryManager GetMemoryManager() { - return _context.Memory; + return Context.Memory; } } }
\ No newline at end of file |