From a1a4771ac1de95f2410c7fb8dfaf4a5986e5ebc6 Mon Sep 17 00:00:00 2001 From: gdkchan <gab.dark.100@gmail.com> Date: Mon, 23 Jan 2023 19:37:53 -0300 Subject: Remove use of GetFunctionPointerForDelegate to get JIT cache function pointer (#4337) * Remove use of GetFunctionPointerForDelegate to get JIT cache function pointer * Rename FuncPtr to FuncPointer --- ARMeilleure/CodeGen/CompiledFunction.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'ARMeilleure/CodeGen/CompiledFunction.cs') diff --git a/ARMeilleure/CodeGen/CompiledFunction.cs b/ARMeilleure/CodeGen/CompiledFunction.cs index ab5e88eb..0560bf2e 100644 --- a/ARMeilleure/CodeGen/CompiledFunction.cs +++ b/ARMeilleure/CodeGen/CompiledFunction.cs @@ -48,9 +48,21 @@ namespace ARMeilleure.CodeGen /// <returns>A delegate of type <typeparamref name="T"/> pointing to the mapped function</returns> public T Map<T>() { - IntPtr codePtr = JitCache.Map(this); + return MapWithPointer<T>(out _); + } + + /// <summary> + /// Maps the <see cref="CompiledFunction"/> onto the <see cref="JitCache"/> and returns a delegate of type + /// <typeparamref name="T"/> pointing to the mapped function. + /// </summary> + /// <typeparam name="T">Type of delegate</typeparam> + /// <param name="codePointer">Pointer to the function code in memory</param> + /// <returns>A delegate of type <typeparamref name="T"/> pointing to the mapped function</returns> + public T MapWithPointer<T>(out IntPtr codePointer) + { + codePointer = JitCache.Map(this); - return Marshal.GetDelegateForFunctionPointer<T>(codePtr); + return Marshal.GetDelegateForFunctionPointer<T>(codePointer); } } } \ No newline at end of file -- cgit v1.2.3-70-g09d2