Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mono][wasm] Use [UnmanagedCallersOnly] in GetDelegateForFunctionPoin… #89334

Closed
wants to merge 1 commit into from

Conversation

vargaz
Copy link
Contributor

@vargaz vargaz commented Jul 21, 2023

…terTests so it works on wasm.

Fixes #39187.

@ghost
Copy link

ghost commented Jul 21, 2023

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

Issue Details

…terTests so it works on wasm.

Fixes #39187.

Author: vargaz
Assignees: -
Labels:

area-System.Runtime.InteropServices

Milestone: -

@vargaz vargaz requested a review from lewing July 22, 2023 00:00
@vargaz
Copy link
Contributor Author

vargaz commented Jul 22, 2023

Looks like the tests only pass in non-aot mode if compiled with /p:WasmBuildNative=true.

@lewing
Copy link
Member

lewing commented Jul 25, 2023

Looks like the tests only pass in non-aot mode if compiled with /p:WasmBuildNative=true.

That makes some sense given how we use the table generator for this attribute. We might be able to add a check to a platform analyzer, but we should definitely document it.

@marek-safar
Copy link
Contributor

@vargaz what's the plan here?

@vargaz
Copy link
Contributor Author

vargaz commented Oct 9, 2023

Not sure, this test will not pass in non-aot mode on wasm even with these changes.

@lewing
Copy link
Member

lewing commented Nov 16, 2023

cc @kg

@lewing
Copy link
Member

lewing commented Nov 28, 2023

We could run the table generator and check if any new entries were added over the default and emit an error if WasmBuildNative is not enabled.


private static void Method(string s) { }
[UnmanagedCallersOnly]
Copy link
Member

@lambdageek lambdageek Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NativeAOT uses UnmanagedFunctionPointerAttribute on the delegate definitions to make delegate stubs available to the AOT compiler when they can't figure it out directly from arguments to GetFunctionPointerForDelegate or GetDelegateForFunctionPointer

@lewing lewing requested a review from kg December 6, 2023 00:06
@kg
Copy link
Member

kg commented Dec 6, 2023

I'm not sure how I feel about this test change. We're narrowing our test coverage to no longer cover "what happens when you pass a managed type across the boundary". I guess we probably have enough comprehensive test coverage for p/invoke that it's fine to do so?

@vargaz
Copy link
Contributor Author

vargaz commented Dec 6, 2023

The string->int change is needed because UnmanagedCallersOnly requires blittable types.

@kg
Copy link
Member

kg commented Dec 6, 2023

I guess my concern is that it feels like we're replacing test A with a new test B, when we could leave A disabled and add the new test alongside it to avoid reducing our test coverage. Then if we fix string support later we can turn the existing test on.

@vargaz
Copy link
Contributor Author

vargaz commented Dec 6, 2023

This test is supposed to test GetDelegateForFunctionPointer, not pinvoke in general.

@vargaz
Copy link
Contributor Author

vargaz commented Jan 25, 2024

/azp run runtime

@vargaz
Copy link
Contributor Author

vargaz commented Jan 25, 2024

/azp run runtime-wasm

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vargaz
Copy link
Contributor Author

vargaz commented Jan 26, 2024

This will not work in non-aot mode even with these changes, closing.

@vargaz vargaz closed this Jan 26, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GetFunctionPointerForDelegateTests tests fail with Specified cast is not valid on Browser
6 participants