summaryrefslogtreecommitdiff
path: root/java/dexpreopt.go
diff options
context:
space:
mode:
author Spandan Das <spandandas@google.com> 2024-01-25 22:12:50 +0000
committer Spandan Das <spandandas@google.com> 2024-01-30 18:04:52 +0000
commit2ea84dd0dc034d982e867e7dec97b713b68ce3bf (patch)
tree73062cdf6401eef787b7bbd2158213406179a636 /java/dexpreopt.go
parente21a8d4dc6ef36c7de97254e40acfd389e887a2d (diff)
Propagate profile_guided requirement of imports to top-level apex
For prebuilts, the dexpreopt rules of system server jars are now generated from the context of the top-level prebuilt apex and not in the context of the shim java_import modules. Since `dex_preopt.profile_guided` property is defined in java_import, this needs to be bubbled up to the top-level apex. This will be done using deapxerInfo. If profile_guided of a transitive java_import is true, the deapexed .prof file will be set as dexreopter.inputProfilePathOnHost before invoking dexpreopter.dexpreopt. This ensures that only that java_import undergoes profile guided dexpreopt, and not every other transitive java_import Test: go test ./apex -run TestPrebuiltStandaloneSystemserverclasspathFragmentContents Test: lunch cf_x86_64_only_phone-next-userdebug && m $ANDROID_PRODUCT_OUT/system/framework/oat/x86_64/apex@com.android.art@javalib@service-art.jar@classes.odex Test: du -sh $ANDROID_PRODUCT_OUT/system/framework/oat/x86_64/apex@com.android.art@javalib@service-art.jar@classes.odex 24K Bug: 308790457 Change-Id: Ibf46ecb400b3f126b243fc8d27b08d9a1aa4cc97
Diffstat (limited to 'java/dexpreopt.go')
-rw-r--r--java/dexpreopt.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 4c0a0a155..9db9b1b46 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -282,6 +282,17 @@ func (d *Dexpreopter) DexpreoptPrebuiltApexSystemServerJars(ctx android.ModuleCo
d.installPath = android.PathForModuleInPartitionInstall(ctx, "", strings.TrimPrefix(dexpreopt.GetSystemServerDexLocation(ctx, dc, libraryName), "/"))
// generate the rules for creating the .odex and .vdex files for this system server jar
dexJarFile := di.PrebuiltExportPath(ApexRootRelativePathToJavaLib(libraryName))
+
+ d.inputProfilePathOnHost = nil // reset: TODO(spandandas): Make dexpreopter stateless
+ if android.InList(libraryName, di.GetDexpreoptProfileGuidedExportedModuleNames()) {
+ // Set the profile path to guide optimization
+ prof := di.PrebuiltExportPath(ApexRootRelativePathToJavaLib(libraryName) + ".prof")
+ if prof == nil {
+ ctx.ModuleErrorf("Could not find a .prof file in this prebuilt apex")
+ }
+ d.inputProfilePathOnHost = prof
+ }
+
d.dexpreopt(ctx, libraryName, dexJarFile)
}
@@ -354,6 +365,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, libName string, dexJa
var profileClassListing android.OptionalPath
var profileBootListing android.OptionalPath
profileIsTextListing := false
+
if d.inputProfilePathOnHost != nil {
profileClassListing = android.OptionalPathForPath(d.inputProfilePathOnHost)
} else if BoolDefault(d.dexpreoptProperties.Dex_preopt.Profile_guided, true) && !forPrebuiltApex(ctx) {