Skip to content

Conversation

@grendello
Copy link
Contributor

Add code which classifies methods selected by JavaCallableWrapperGenerator
and decides whether they are to be registered dynamically or using the
future native code marshal methods.

If a type JavaCallableWrapperGenerator is processing is found to not
have any dynamically registered methods, then the code to register them
is no longer generated.

@grendello grendello force-pushed the marshal-methods-infra branch from 2658493 to 89a0c2c Compare July 4, 2022 17:34
@jonpryor
Copy link
Contributor

jonpryor commented Jul 8, 2022

In-progress commit message:

Context: https://github.com/xamarin/xamarin-android/pull/7123
Context: fb94d598bddf7818d841914dd4f565cf5cd0bbac

Instead of having `JavaCallableWrapperGenerator` care about and
collect marshal methods override information, introduce a new
`JavaCallableMethodClassifier` type, and use that as the integration
point:

	public abstract partial class JavaCallableMethodClassifier {
	    public abstract bool ShouldBeDynamicallyRegistered 
	            TypeDefinition topType,
	            MethodDefinition registeredMethod,
	            MethodDefinition implementedMethod,
	            CustomAttribute registerAttribute
	    );
	}

An instance of `JavaCallableMethodClassifier` can now be provided to
the `JavaCallableWrapperGenerator` constructor.  If provided, then
`ShouldBeDynamicallyRegistered()` will be used to control which
methods are added to `__md_methods` and `Runtime.register()`.

If a type `JavaCallableWrapperGenerator` is processing doesn't have
any dynamically registered methods, then the code to register them
is no longer generated.

@jonpryor
Copy link
Contributor

jonpryor commented Jul 8, 2022

@grendello wrote in the PR description:

If a type JavaCallableWrapperGenerator is processing doesn't have
any dynamically registered methods, then the code to register them
is no longer generated.

What should happen in Debug builds? (Not necessarily relevant here, but it came to mind.) I don't think we want to require LLVM Marshal Methods for Debug builds, so is the plan to provide a JavaCallableMethodClassifier in Debug builds which flags all methods as dynamically registered?

@grendello
Copy link
Contributor Author

@grendello wrote in the PR description:

If a type JavaCallableWrapperGenerator is processing doesn't have
any dynamically registered methods, then the code to register them
is no longer generated.

What should happen in Debug builds? (Not necessarily relevant here, but it came to mind.) I don't think we want to require LLVM Marshal Methods for Debug builds, so is the plan to provide a JavaCallableMethodClassifier in Debug builds which flags all methods as dynamically registered?

We just don't pass any classifier in this case

grendello added 9 commits July 8, 2022 21:27
Add code which classifies methods selected by `JavaCallableWrapperGenerator`
and decides whether they are to be registered dynamically or using the
future native code marshal methods.

If a type `JavaCallableWrapperGenerator` is processing is found to not
have any dynamically registered methods, then the code to register them
is no longer generated.
@grendello grendello force-pushed the marshal-methods-infra branch from 39a31cc to 8c8938d Compare July 8, 2022 19:57
@jonpryor jonpryor merged commit 3e4a3c4 into dotnet:main Jul 9, 2022
@grendello grendello deleted the marshal-methods-infra branch July 11, 2022 07:29
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants