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

[XABT] Move scanning for ACW map JLOs to FindJavaObjectsStep. #9930

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Mar 18, 2025

Context: #9893

Building on #9893, this moves the process of scanning for JLOs needed for the ACW map generation task to the FindJavaObjectsStep "linker step".

This process needs interface JLOs, which JavaCallableWrappers doesn't support. Expanding the JCW serialization format to allow interfaces (and other ACW-needed data it didn't already support) resulted in a lot of extra processing and waste.

Instead, we expand the .jlo.xml file to have 2 sections, one for JCW needed data and one for ACW needed data:

<api>
  <jcw-types>
    <type name="MainActivity" package="crc645107ba1b8b6ee4d3" application_java_class="android.app.Application" mono_runtime_initialization="mono.MonoPackageManager.LoadApplication (context);" extends_type="android.app.Activity" partial_assembly_qualified_name="tempbuild.MainActivity, tempbuild">
      <constructors>
        <constructor name="MainActivity" method="n_.ctor:()V:" jni_signature="()V" managed_parameters="" retval="void" is_dynamically_registered="True" />
      </constructors>
      <methods>
        <method name="clone" method="n_clone:()Ljava/lang/Object;:GetCloneHandler" jni_signature="()Ljava/lang/Object;" retval="java.lang.Object" />
        <method name="onCreate" method="n_onCreate:(Landroid/os/Bundle;)V:GetOnCreate_Landroid_os_Bundle_Handler" jni_signature="(Landroid/os/Bundle;)V" params="android.os.Bundle p0" retval="void" super_call="p0" activate_call="p0" />
      </methods>
    </type>
  </jcw-types>
  <acw-types partial-assembly-name="tempbuild" module-name="tempbuild.dll">
    <type assembly-qualified-name="tempbuild.MainActivity, tempbuild, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" compat-jni-name="tempbuild.MainActivity" java-key="crc645107ba1b8b6ee4d3.MainActivity" managed-key="tempbuild.MainActivity" partial-assembly-qualified-name="tempbuild.MainActivity, tempbuild" />
  </acw-types>
</api>

Additionally, for assemblies that cannot contain JLOs that we do not need to scan, we no longer write an "empty" XML file like this: <types was_scanned="False" />. Instead, we now write an actual empty (0 byte) file to disk, which saves build time when deserializing.

Like #9893, this temporarily leaves the old ACW map generation code in place, guarded behind the $(_AndroidJLOCheckedBuild) flag. This flag generates the ACW map both the new and old way, and errors the build if there are differences. (A consistent sort was added so that both maps are sorted the same.)

@jpobst jpobst force-pushed the dev/jpobst/acw-map-2 branch 7 times, most recently from dc3da9c to dbaedaa Compare March 18, 2025 22:32
@jpobst jpobst force-pushed the dev/jpobst/acw-map-2 branch from dbaedaa to 1abe342 Compare March 19, 2025 00:02
Copy link
Member

@jonathanpeppers jonathanpeppers Mar 24, 2025

Choose a reason for hiding this comment

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

One thing I wondered about this step... If you are building a Release app with 4 RIDs, does this write a copy of the .xml file 4 times? Is there logic that detects the first RID and skips the rest?

The Java objects found are identical between all 4 RIDs. The only thing that would differ, is the BCL sets different trimmer flags based on 32 or 64-bit, different hardware intrinsics, etc. System.Private.CoreLib.dll and a few other System assemblies will differ per RID, but no Android-libraries or user-assemblies would.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants