diff options
author | 2019-07-24 13:19:29 +0100 | |
---|---|---|
committer | 2019-07-24 22:28:54 +0100 | |
commit | e710242b5c42477c2bf4d6f34581cc608bff0fc8 (patch) | |
tree | 31874fe3c9b862902e4510d545833ca1f112c84c /java | |
parent | 2b78fda70513fdfd18b826020d704a699ee45d71 (diff) |
Add support for generating boot profiles.
Test: /system/etc/boot-image.bprof is generated
Test: /system/framework/services.bprof is generated
Bug: 119800099
Change-Id: I50f0b665ff104feca4a26dd229625f00013db251
Diffstat (limited to 'java')
-rw-r--r-- | java/dexpreopt.go | 4 | ||||
-rw-r--r-- | java/dexpreopt_bootjars.go | 47 |
2 files changed, 51 insertions, 0 deletions
diff --git a/java/dexpreopt.go b/java/dexpreopt.go index ed12fe6d2..6214dac44 100644 --- a/java/dexpreopt.go +++ b/java/dexpreopt.go @@ -143,6 +143,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo strippedDexJarFile := android.PathForModuleOut(ctx, "dexpreopt", dexJarFile.Base()) var profileClassListing android.OptionalPath + var profileBootListing android.OptionalPath profileIsTextListing := false if BoolDefault(d.dexpreoptProperties.Dex_preopt.Profile_guided, true) { // If dex_preopt.profile_guided is not set, default it based on the existence of the @@ -150,6 +151,8 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo if String(d.dexpreoptProperties.Dex_preopt.Profile) != "" { profileClassListing = android.OptionalPathForPath( android.PathForModuleSrc(ctx, String(d.dexpreoptProperties.Dex_preopt.Profile))) + profileBootListing = android.ExistentPathForSource(ctx, + ctx.ModuleDir(), String(d.dexpreoptProperties.Dex_preopt.Profile)+"-boot") profileIsTextListing = true } else { profileClassListing = android.ExistentPathForSource(ctx, @@ -169,6 +172,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo ProfileClassListing: profileClassListing, ProfileIsTextListing: profileIsTextListing, + ProfileBootListing: profileBootListing, EnforceUsesLibraries: d.enforceUsesLibs, PresentOptionalUsesLibraries: d.optionalUsesLibs, diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index 4ef5bcf4b..19e92b730 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -216,6 +216,7 @@ func buildBootImage(ctx android.SingletonContext, config bootImageConfig) *bootI } profile := bootImageProfileRule(ctx, image, missingDeps) + bootFrameworkProfileRule(ctx, image, missingDeps) var allFiles android.Paths @@ -424,6 +425,52 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missin var bootImageProfileRuleKey = android.NewOnceKey("bootImageProfileRule") +func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath { + global := dexpreoptGlobalConfig(ctx) + + if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() { + return nil + } + return ctx.Config().Once(bootFrameworkProfileRuleKey, func() interface{} { + tools := global.Tools + + rule := android.NewRuleBuilder() + rule.MissingDeps(missingDeps) + + // Some branches like master-art-host don't have frameworks/base, so manually + // handle the case that the default is missing. Those branches won't attempt to build the profile rule, + // and if they do they'll get a missing deps error. + defaultProfile := "frameworks/base/config/boot-profile.txt" + path := android.ExistentPathForSource(ctx, defaultProfile) + var bootFrameworkProfile android.Path + if path.Valid() { + bootFrameworkProfile = path.Path() + } else { + missingDeps = append(missingDeps, defaultProfile) + bootFrameworkProfile = android.PathForOutput(ctx, "missing") + } + + profile := image.dir.Join(ctx, "boot.bprof") + + rule.Command(). + Text(`ANDROID_LOG_TAGS="*:e"`). + Tool(tools.Profman). + Flag("--generate-boot-profile"). + FlagWithInput("--create-profile-from=", bootFrameworkProfile). + FlagForEachInput("--apk=", image.dexPaths.Paths()). + FlagForEachArg("--dex-location=", image.dexLocations). + FlagWithOutput("--reference-profile-file=", profile) + + rule.Install(profile, "/system/etc/boot-image.bprof") + rule.Build(pctx, ctx, "bootFrameworkProfile", "profile boot framework jars") + image.profileInstalls = append(image.profileInstalls, rule.Installs()...) + + return profile + }).(android.WritablePath) +} + +var bootFrameworkProfileRuleKey = android.NewOnceKey("bootFrameworkProfileRule") + func dumpOatRules(ctx android.SingletonContext, image *bootImage) { var archs []android.ArchType for arch := range image.images { |