-
Notifications
You must be signed in to change notification settings - Fork 564
[Experimental] Add alternative way of resolving UCO function pointers for Marshal Methods #9805
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
Changes from all commits
94d9a7b
408d8f6
6c039cd
9acc534
d1df4af
7667cf4
12e6a01
8f080e1
25580eb
4f5a234
5f26f54
8e12d37
9f229b2
a494313
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| using System; | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using System.Runtime.CompilerServices; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| using Android.Runtime; | ||
|
|
||
| namespace Java.Interop; | ||
|
|
||
| internal class ManagedMarshalMethodsLookupTable | ||
| { | ||
| [UnmanagedCallersOnly] | ||
| internal static unsafe void GetFunctionPointer (int assemblyIndex, int classIndex, int methodIndex, IntPtr* target) | ||
| { | ||
| try { | ||
| IntPtr result = GetFunctionPointer (assemblyIndex, classIndex, methodIndex); | ||
| if (result == IntPtr.Zero || result == (IntPtr)(-1)) { | ||
| throw new InvalidOperationException ($"Failed to get function pointer for ({assemblyIndex}, {classIndex}, {methodIndex})"); | ||
| } | ||
|
|
||
| *target = result; | ||
| } catch (Exception ex) { | ||
| AndroidEnvironment.UnhandledException (ex); | ||
| AndroidEnvironment.FailFast ("GetFunctionPointer failed: should not be reached"); | ||
| } | ||
| } | ||
|
|
||
| static IntPtr GetFunctionPointer (int assemblyIndex, int classIndex, int methodIndex) | ||
| { | ||
| // ManagedMarshalMethodsLookupGenerator generates the body of this method is generated at app build time | ||
| throw new NotImplementedException (); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,7 @@ public class GenerateJavaStubs : AndroidTask | |
| public bool LinkingEnabled { get; set; } | ||
| public bool HaveMultipleRIDs { get; set; } | ||
| public bool EnableMarshalMethods { get; set; } | ||
| public bool EnableManagedMarshalMethodsLookup { get; set; } | ||
|
|
||
| public bool Debug { get; set; } | ||
|
|
||
|
|
@@ -210,8 +211,16 @@ void Run (bool useMarshalMethods) | |
|
|
||
| foreach (var kvp in nativeCodeGenStates) { | ||
| NativeCodeGenState state = kvp.Value; | ||
| RewriteMarshalMethods (state, brokenExceptionTransitionsEnabled); | ||
| state.Classifier.AddSpecialCaseMethods (); | ||
| if (!EnableManagedMarshalMethodsLookup) { | ||
| RewriteMarshalMethods (state, brokenExceptionTransitionsEnabled); | ||
| state.Classifier.AddSpecialCaseMethods (); | ||
| } else { | ||
| // We need to run `AddSpecialCaseMethods` before `RewriteMarshalMethods` so that we can see the special case | ||
| // methods (such as TypeManager.n_Activate_mm) when generating the managed lookup tables. | ||
| state.Classifier.AddSpecialCaseMethods (); | ||
| state.ManagedMarshalMethodsLookupInfo = new ManagedMarshalMethodsLookupInfo (Log); | ||
| RewriteMarshalMethods (state, brokenExceptionTransitionsEnabled); | ||
| } | ||
|
Comment on lines
+214
to
+223
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not observe any functional changes when swapping the order of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's what CI is for: a safety net. Try it and see! ;-) We can certainly leave this for now. |
||
|
|
||
| Log.LogDebugMessage ($"[{state.TargetArch}] Number of generated marshal methods: {state.Classifier.MarshalMethods.Count}"); | ||
| if (state.Classifier.RejectedMethodCount > 0) { | ||
|
|
@@ -307,7 +316,7 @@ void RewriteMarshalMethods (NativeCodeGenState state, bool brokenExceptionTransi | |
| return; | ||
| } | ||
|
|
||
| var rewriter = new MarshalMethodsAssemblyRewriter (Log, state.TargetArch, state.Classifier, state.Resolver); | ||
| var rewriter = new MarshalMethodsAssemblyRewriter (Log, state.TargetArch, state.Classifier, state.Resolver, state.ManagedMarshalMethodsLookupInfo); | ||
| rewriter.Rewrite (brokenExceptionTransitionsEnabled); | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.