-
Notifications
You must be signed in to change notification settings - Fork 538
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
Enable marshal methods support by default #7351
Merged
Merged
Changes from 94 commits
Commits
Show all changes
141 commits
Select commit
Hold shift + click to select a range
35f4e24
Implement marshal methods LLVM IR executable code generator.
grendello e34f88e
[marshal methods] Runtime fixes and missing features
grendello eb15bd2
Update
grendello a80e4a1
TODOs and CWLs
grendello 49751f7
Update JI
grendello 803b3e3
Merge branch 'main' into mm-codegen
grendello e6101c1
Merge branch 'mm-codegen' into mm-runtime
grendello 657aff0
[WIP] Generate full native symbol names when necessary
grendello e8d3026
Handle enums properly (except when there are arrays of them)
grendello 4d7ec30
Merge branch 'main' into mm-codegen
grendello 39068d3
Merge branch 'mm-codegen' into mm-runtime
grendello 82ece43
Generate correct native names and process overloads properly
grendello acd5bc8
When a class is first seen, make sure to set class index properly
grendello 9a476d8
Merge branch 'main' into mm-codegen
grendello 8d2503f
Merge branch 'mm-codegen' into mm-runtime
grendello f913d24
Merge branch 'main' into mm-codegen
grendello 52c99db
Merge branch 'mm-codegen' into mm-runtime
grendello e5358f4
Trying to get the MAUI sample app running
grendello 2f15f67
Merge branch 'main' into mm-codegen
grendello 21c066f
Merge branch 'mm-codegen' into mm-runtime
grendello 3c8901a
MAUI app ran with marshal methods for the first time
grendello 7dc40fc
Check array dimensions when classifying methods
grendello 2b2ce55
Merge branch 'main' into mm-codegen
grendello 9c38c68
Merge branch 'mm-codegen' into mm-runtime
grendello 85f2cfa
Merge branch 'main' into mm-codegen
grendello 024b5f5
Merge branch 'mm-codegen' into mm-runtime
grendello 4d92570
We need to generate wrappers for methods with non-blittable params
grendello 20a2f00
Blittable wrapper generator progress
grendello 2d3c043
Non-blittable marshal method wrappers implemented
grendello 071e9d3
Merge branch 'main' into mm-codegen
grendello 710242e
Merge branch 'mm-codegen' into mm-runtime
grendello af91895
Fix non-blittable wrapper method generation
grendello 673836c
Merge branch 'main' into mm-codegen
grendello ca2f92d
Merge branch 'mm-codegen' into mm-runtime
grendello 10e63e2
Merge branch 'main' into mm-codegen
grendello 238417e
Merge branch 'mm-codegen' into mm-runtime
grendello 72c4b60
Disable some debug CWLs
grendello eb94adc
Merge branch 'mm-codegen' into mm-runtime
grendello a8471cd
Add some debugging info to function pointer lookups
grendello cfaabf2
Escape double quotes in function attribute value
grendello 8ca61bb
Merge branch 'main' into mm-codegen
grendello a473f27
Merge branch 'mm-codegen' into mm-runtime
grendello d99b7e3
Fix and optimize debugging info for class and method names
grendello cfa1b30
Reorganize code, move error handling to the end of function
grendello 9c9612d
Merge branch 'main' into mm-runtime
grendello 334619b
Disable marshal methods for PR
grendello c9332a8
Move some code behind the ENABLE_MARSHAL_METHODS flag
grendello e518a4e
Remove workarounds for methods with non-blittable types
grendello 905e784
Build marshal methods support unconditionally
grendello f29f0d2
Remove debugging messages
grendello 6ca1245
Update apkdesc files
grendello b988b7f
Merge branch 'mm-runtime' into mm-cleanup-and-enable
grendello 63bf193
Fix a failing test
grendello 3530c39
Merge branch 'mm-runtime' into mm-cleanup-and-enable
grendello c516792
Merge branch 'main' into mm-runtime
grendello c8a2d9f
Implement some requested changes
grendello e8f3215
Merge branch 'mm-runtime' into mm-cleanup-and-enable
grendello b60c767
Don't package mono.android.jar when marshal methods are enabled
grendello 0aa3e95
Merge branch 'main' into mm-runtime
grendello e3ac595
Merge branch 'mm-runtime' into mm-cleanup-and-enable
grendello 49895b8
Merge branch 'main' into mm-runtime
grendello a8cfd90
Merge branch 'mm-runtime' into mm-cleanup-and-enable
grendello 92fa671
Remove JI workaround
grendello f37b4dc
Merge branch 'mm-runtime' into mm-cleanup-and-enable
grendello 09678bd
Don't register dynamically methods for which we generate JCWs
grendello d60fc08
[WIP] Some cleanup + special cases
grendello 6b116bf
Merge branch 'main' into mm-runtime
grendello 1d88be2
Merge branch 'mm-runtime' into mm-cleanup-and-enable
grendello aea0b0f
TypeManager special case now works
grendello e1e59f0
Merge branch 'main' into mm-runtime
grendello aaff9f5
Merge branch 'mm-runtime' into mm-cleanup-and-enable
grendello df04d47
Merge branch 'main' into mm-runtime
grendello 7e9761f
Merge branch 'mm-runtime' into mm-cleanup-and-enable
grendello f17ad9f
Fix Debug mode and Release w/o marshal methods
grendello 7a00e0e
Make AOT work (with trimming)
grendello d3d9007
Merge branch 'main' into mm-runtime
grendello 73237a2
Merge branch 'mm-runtime' into mm-cleanup-and-enable
grendello b459e4a
Merge branch 'main' into mm-runtime
grendello dfcf734
Merge branch 'mm-runtime' into mm-cleanup-and-enable
grendello 5dccadb
Time to test things
grendello fc83958
Merge branch 'main' into mm-cleanup-and-enable
grendello 8bdb607
Merge branch 'main' into mm-cleanup-and-enable
grendello cd832c7
Turn a couple of warnings into debug messages for now
grendello a9995b0
Update apkdesc files
grendello 86d9fca
Try to avoid locked files on Windows
grendello 1162a09
Merge branch 'main' into mm-cleanup-and-enable
grendello 65471a8
Try to unbreak build of tests
grendello 7f87a37
Don't require the `EnableMarshalMethods` parameter
grendello ea4c57f
Merge branch 'main' into mm-cleanup-and-enable
grendello 115c6fa
Remove the check, it's incorrect
grendello 222163e
Avoid warning about duplicate files to add to apk
grendello 5bd03e2
Merge branch 'main' into mm-cleanup-and-enable
grendello e635b27
Update apkdesc files
grendello 221ad8f
Let's see if it breaks any tests (it works locally)
grendello d03092d
Merge branch 'main' into mm-cleanup-and-enable
grendello e1a621e
Merge branch 'main' into mm-cleanup-and-enable
grendello f9bca3c
Update apkdesc files
grendello 977a060
Hunting for reasons of the crashes
grendello 09eeb7e
Merge branch 'main' into mm-cleanup-and-enable
grendello 312d84e
Refactor the JNIEnv class
grendello b143c95
Merge branch 'main' into mm-cleanup-and-enable
grendello c20ae31
Generate assembly image cache array even if marshal methods disabled
grendello 8c9ceca
Most problems solved, the crashes make sense now
grendello 2b33563
Put the assembly reader settings back in
grendello 94d9bea
Merge branch 'main' into mm-cleanup-and-enable
grendello 73277aa
Fix copying of rewritten assemblies
grendello 5b14a70
Fix a typo and relax requirements on GenerateJavaStubs.IntermediateOu…
grendello 9077b6a
Fix unhandled exception propagation
grendello 32347b7
Fix builds of apps with linking and just a single RID
grendello ddedcc3
[WIP] Investigating a Mono.Android crash
grendello aed7b2d
Merge branch 'main' into mm-cleanup-and-enable
grendello 2aa7cfe
Mono.Android.NET_Tests crash investigations continued
grendello 92fb339
TODO
grendello d3c54a0
Merge branch 'main' into mm-cleanup-and-enable
grendello 170b5d1
Factor out bits of code to a separate assembly
grendello 3fdc653
Merge branch 'main' into mm-cleanup-and-enable
grendello 504ced9
[WIP] Exception wrapper generator in assembly rewriter
grendello be9280e
Merge branch 'main' into mm-cleanup-and-enable
grendello 983ad70
Exception wrapper appears to work now
grendello 7d201e3
Fix a handful of CI test failures
grendello 35d49d4
Remove unnecessary argument
grendello 1ebb5d8
Fix a couple more causes for test failures
grendello 62a5138
More tests fixed
grendello 9852cc5
Merge branch 'main' into mm-cleanup-and-enable
grendello fe2ae06
Fix tests which use callbacks with Android.Graphics.Color
grendello e1609d9
Let's see if the failing tests work with these changes
grendello 98655ea
Oops, forgot to put that back in
grendello 5d138d0
Copy PR 7406 to test if it works for marshal methods
grendello 71aafd5
Merge branch 'main' into mm-cleanup-and-enable
grendello d708edc
Merge branch 'main' into mm-cleanup-and-enable
grendello 7124851
Disable marshal methods for Designer tests
grendello 9be7e6b
Add docs
grendello edcf092
See if we can get crash logs from designer tests
grendello 48c3328
Let's see if this fixes the designer failures
grendello 5781643
Merge branch 'main' into mm-cleanup-and-enable
grendello 5f433b1
Remove debug logging
grendello 8b1d3f9
Address reviews
grendello 724de1d
Merge branch 'main' into mm-cleanup-and-enable
grendello d26d9e1
Get rid of dead code
grendello d5016fe
Update documentation
grendello f8db2d2
Fix indentation and trailing whitespace
grendello File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/Xamarin.Android.Build.Tasks/Tasks/CreateTypeManagerJava.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Text; | ||
using System; | ||
|
||
using Microsoft.Android.Build.Tasks; | ||
using Microsoft.Build.Framework; | ||
|
||
namespace Xamarin.Android.Tasks | ||
{ | ||
public class CreateTypeManagerJava : AndroidTask | ||
{ | ||
public override string TaskPrefix => "CTMJ"; | ||
|
||
[Required] | ||
public string ResourceName { get; set; } | ||
|
||
[Required] | ||
public string OutputFilePath { get; set; } | ||
|
||
static readonly Assembly ExecutingAssembly = Assembly.GetExecutingAssembly (); | ||
|
||
public override bool RunTask () | ||
{ | ||
string? content = ReadResource (ResourceName); | ||
|
||
if (String.IsNullOrEmpty (content)) { | ||
return false; | ||
} | ||
|
||
var result = new StringBuilder (); | ||
bool ignoring = false; | ||
foreach (string line in content.Split ('\n')) { | ||
if (!ignoring) { | ||
if (ignoring = line.StartsWith ("//#MARSHAL_METHODS:START", StringComparison.Ordinal)) { | ||
continue; | ||
} | ||
result.AppendLine (line); | ||
} else if (line.StartsWith ("//#MARSHAL_METHODS:END", StringComparison.Ordinal)) { | ||
ignoring = false; | ||
} | ||
} | ||
|
||
if (result.Length == 0) { | ||
Log.LogDebugMessage ("TypeManager.java not generated, empty resource data"); | ||
return false; | ||
} | ||
|
||
using (var ms = new MemoryStream ()) { | ||
using (var sw = new StreamWriter (ms)) { | ||
sw.Write (result.ToString ()); | ||
sw.Flush (); | ||
|
||
if (Files.CopyIfStreamChanged (ms, OutputFilePath)) { | ||
Log.LogDebugMessage ($"Wrote resource {OutputFilePath}."); | ||
} else { | ||
Log.LogDebugMessage ($"Resource {OutputFilePath} is unchanged. Skipping."); | ||
} | ||
} | ||
} | ||
|
||
return !Log.HasLoggedErrors; | ||
} | ||
|
||
string? ReadResource (string resourceName) | ||
{ | ||
using (var from = ExecutingAssembly.GetManifestResourceStream (resourceName)) { | ||
if (from == null) { | ||
Log.LogCodedError ("XA0116", Properties.Resources.XA0116, resourceName); | ||
return null; | ||
} | ||
|
||
using (var sr = new StreamReader (from)) { | ||
return sr.ReadToEnd (); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not following exactly how
@(_AotResolvedFileToPublish)
is used. Does some target use it later?Is it possible that the
libaot-*.so
files don't actually make it to the.apk
with these changes?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is converted to
ResolvedFileToPublish
here https://github.com/xamarin/xamarin-android/pull/7351/files#diff-e2c60a31385c6fbadf9b9f439d3681ee357077bf3e66f181a0ddb02b9d98adf1R1668, while if it returned@(ResolvedFileToPublish)
, it would duplicate the items that were in the group before the target was invoked.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
<Output TaskParameter="TargetOutputs">
expression doesn't care what is the name of items returned by the called target - it just takes the items and copies them with the new name specified inItemName
. And since we use_AotResolvedFileToPublish
in theReturns
attribute of the_AndroidAotAndComputeFilesToPublishForRuntimeIdentifiers
target, we don't get duplicates ofResolvedFileToPublish
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see it now. 👍