From 4f2d3990f32886924df436c371436cc9a856bc7b Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Thu, 16 Feb 2023 23:03:09 -0500 Subject: [PATCH 1/2] [mono][wasm] Fix ldftn in AOT mode, it should return a ftndesc. Fixes https://github.com/dotnet/runtime/issues/82272. --- src/mono/mono/mini/jit-icalls.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/mono/mono/mini/jit-icalls.c b/src/mono/mono/mini/jit-icalls.c index 93802f47b34e9b..a22a36ea98f5bb 100644 --- a/src/mono/mono/mini/jit-icalls.c +++ b/src/mono/mono/mini/jit-icalls.c @@ -21,6 +21,7 @@ #include "jit-icalls.h" #include "aot-runtime.h" #include "mini-runtime.h" +#include "llvmonly-runtime.h" #include #include #include @@ -42,17 +43,19 @@ mono_ldftn (MonoMethod *method) if (mono_llvm_only) { // FIXME: No error handling + if (mono_method_signature_internal (method)->pinvoke) { + addr = mono_compile_method_checked (method, error); + mono_error_assert_ok (error); + g_assert (addr); - addr = mono_compile_method_checked (method, error); - mono_error_assert_ok (error); - g_assert (addr); - - if (mono_method_needs_static_rgctx_invoke (method, FALSE)) - /* The caller doesn't pass it */ - g_assert_not_reached (); + return addr; + } else { + /* Managed function pointers are ftndesc's */ + addr = mini_llvmonly_load_method_ftndesc (method, FALSE, FALSE, error); + mono_error_assert_ok (error); - addr = mini_add_method_trampoline (method, addr, mono_method_needs_static_rgctx_invoke (method, FALSE), FALSE); - return addr; + return addr; + } } /* if we need the address of a native-to-managed wrapper, just compile it now, trampoline needs thread local From aadde4f078ccdf520f72741fc926a32096dda563 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Mon, 20 Feb 2023 05:25:28 -0500 Subject: [PATCH 2/2] Reenable tests. --- src/libraries/System.Reflection/tests/MethodInfoTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.Reflection/tests/MethodInfoTests.cs b/src/libraries/System.Reflection/tests/MethodInfoTests.cs index 16ba988a5258be..886194492c50ea 100644 --- a/src/libraries/System.Reflection/tests/MethodInfoTests.cs +++ b/src/libraries/System.Reflection/tests/MethodInfoTests.cs @@ -896,7 +896,6 @@ private static void SecondCall(MethodInfo mi) [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/71883", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/82272", typeof(PlatformDetection), nameof(PlatformDetection.IsBrowser))] private static unsafe void TestFunctionPointers() { void* fn = FunctionPointerMethods.GetFunctionPointer();