Skip to content

Commit

Permalink
[mono][wasm] Fix ldftn in AOT mode, it should return a ftndesc. (#82282)
Browse files Browse the repository at this point in the history
* [mono][wasm] Fix ldftn in AOT mode, it should return a ftndesc.

Fixes #82272.

* Reenable tests.
  • Loading branch information
vargaz authored Feb 21, 2023
1 parent 99227fc commit 75eac96
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/libraries/System.Reflection/tests/MethodInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
21 changes: 12 additions & 9 deletions src/mono/mono/mini/jit-icalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "jit-icalls.h"
#include "aot-runtime.h"
#include "mini-runtime.h"
#include "llvmonly-runtime.h"
#include <mono/utils/mono-error-internals.h>
#include <mono/metadata/exception-internals.h>
#include <mono/metadata/threads-types.h>
Expand All @@ -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
Expand Down

0 comments on commit 75eac96

Please sign in to comment.