summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
author Jiakai Zhang <jiakaiz@google.com> 2023-02-08 21:56:07 +0800
committer Jiakai Zhang <jiakaiz@google.com> 2023-02-15 22:47:24 +0000
commit81e468171f4822d1f9a6a2aed78589c74a1ee940 (patch)
tree9477ee60468c1466be05ab74c49f62da809b0888 /java/java.go
parent1f4542c85bfadbac6cd0860057e401393231f2e5 (diff)
Use the profiles in the APEX to dexpreopt system server jars.
After this change, if "profile_guided: true" is set, profile-guided compilation will be enabled for the jar and the ".prof" file next to the jar in the APEX ("javalib/<name>.jar.prof") will be used as the profile when dexpreopting for the prebuilt APEX. Bug: 241823638 Test: m nothing Test: - 1. (on internal master) Patch aosp/2426453. 2. Build the APEX bundle and the module SDK of com.android.wifi 3. (on tm-dev) Patch this CL and aosp/2141972. 4. Copy the APEX bundle and the module SDK built on step 2 to the source tree 5. Disable hiddenapi check 6. lunch cf_x86_64_phone-userdebug && m MODULE_BUILD_FROM_SOURCE=false com.google.android.wifi 7. cat out/soong/.intermediates/prebuilts/module_sdk/Wifi/current/prebuilt_service-wifi/android_common_com.android.wifi/dexpreopt/oat/x86_64/javalib.invocation 8. See the profile being used. Change-Id: I55a5a295e9c5d6f0564afb139c5fb7da91ab8cae
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/java/java.go b/java/java.go
index 912779e94..f1600d98a 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2002,7 +2002,8 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if di == nil {
return // An error has been reported by FindDeapexerProviderForModule.
}
- if dexOutputPath := di.PrebuiltExportPath(apexRootRelativePathToJavaLib(j.BaseModuleName())); dexOutputPath != nil {
+ dexJarFileApexRootRelative := apexRootRelativePathToJavaLib(j.BaseModuleName())
+ if dexOutputPath := di.PrebuiltExportPath(dexJarFileApexRootRelative); dexOutputPath != nil {
dexJarFile := makeDexJarPathFromPath(dexOutputPath)
j.dexJarFile = dexJarFile
installPath := android.PathForModuleInPartitionInstall(ctx, "apex", ai.ApexVariationName, apexRootRelativePathToJavaLib(j.BaseModuleName()))
@@ -2011,6 +2012,11 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.dexpreopter.installPath = j.dexpreopter.getInstallPath(ctx, installPath)
setUncompressDex(ctx, &j.dexpreopter, &j.dexer)
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
+
+ if profilePath := di.PrebuiltExportPath(dexJarFileApexRootRelative + ".prof"); profilePath != nil {
+ j.dexpreopter.inputProfilePathOnHost = profilePath
+ }
+
j.dexpreopt(ctx, dexOutputPath)
// Initialize the hiddenapi structure.
@@ -2145,11 +2151,16 @@ func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
// requiredFilesFromPrebuiltApexForImport returns information about the files that a java_import or
// java_sdk_library_import with the specified base module name requires to be exported from a
// prebuilt_apex/apex_set.
-func requiredFilesFromPrebuiltApexForImport(name string) []string {
+func requiredFilesFromPrebuiltApexForImport(name string, d *dexpreopter) []string {
+ dexJarFileApexRootRelative := apexRootRelativePathToJavaLib(name)
// Add the dex implementation jar to the set of exported files.
- return []string{
- apexRootRelativePathToJavaLib(name),
+ files := []string{
+ dexJarFileApexRootRelative,
+ }
+ if BoolDefault(d.importDexpreoptProperties.Dex_preopt.Profile_guided, false) {
+ files = append(files, dexJarFileApexRootRelative+".prof")
}
+ return files
}
// apexRootRelativePathToJavaLib returns the path, relative to the root of the apex's contents, for
@@ -2162,7 +2173,7 @@ var _ android.RequiredFilesFromPrebuiltApex = (*Import)(nil)
func (j *Import) RequiredFilesFromPrebuiltApex(_ android.BaseModuleContext) []string {
name := j.BaseModuleName()
- return requiredFilesFromPrebuiltApexForImport(name)
+ return requiredFilesFromPrebuiltApexForImport(name, &j.dexpreopter)
}
// Add compile time check for interface implementation