summaryrefslogtreecommitdiff
path: root/java/dex_test.go
diff options
context:
space:
mode:
author Spandan Das <spandandas@google.com> 2024-05-20 22:23:10 +0000
committer Spandan Das <spandandas@google.com> 2024-05-29 01:05:05 +0000
commit3dbda18e808f79bb94d57b645f686a9f737cdc76 (patch)
treee276ada4a581c8db8f2f9c8e0f4130eece756fa6 /java/dex_test.go
parent1705676dd0ccaf56724ea6e0cfbddd0a73c2b802 (diff)
Use r8/d8 optimized profile for dexpreopt
Currently, dexpreopt supports profile guided optimization. This does not work well with r8/d8 optimization, since the checked-in profile will not match the dex signatures after r8/d8 has optimized the dex code. This CL introduces a new property `dex_preopt.enable_profile_rewrting`. If set, the checked-in profile will passed as `input` to r8 via `--art-profile <input> <output>`. The <output> from the previous command will be used as the profile for dexpreopt. Test: m nothing --no-skip-soong-tests Test: m CredentialManager with https://ag.corp.google.com/27448930 and obfuscation turned on Test: nm -U symbol.odex # contains obfuscated methods Bug: 335418838 Change-Id: I53beed9ed76f013262f1c503de0f2b74997c2a7f
Diffstat (limited to 'java/dex_test.go')
-rw-r--r--java/dex_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/java/dex_test.go b/java/dex_test.go
index 1ecdae0c5..eb017d5e9 100644
--- a/java/dex_test.go
+++ b/java/dex_test.go
@@ -662,3 +662,30 @@ func TestProguardFlagsInheritanceAppImport(t *testing.T) {
android.AssertStringDoesContain(t, "expected aarimports's proguard flags",
appR8.Args["r8Flags"], "proguard.txt")
}
+
+func TestR8FlagsArtProfile(t *testing.T) {
+ result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, `
+ android_app {
+ name: "app",
+ srcs: ["foo.java"],
+ platform_apis: true,
+ dex_preopt: {
+ profile_guided: true,
+ profile: "profile.txt.prof",
+ enable_profile_rewriting: true,
+ },
+ }
+ `)
+
+ app := result.ModuleForTests("app", "android_common")
+ appR8 := app.Rule("r8")
+ android.AssertStringDoesContain(t, "expected --art-profile in app r8 flags",
+ appR8.Args["r8Flags"], "--art-profile")
+
+ appDexpreopt := app.Rule("dexpreopt")
+ android.AssertStringDoesContain(t,
+ "expected --art-profile output to be used to create .prof binary",
+ appDexpreopt.RuleParams.Command,
+ "--create-profile-from=out/soong/.intermediates/app/android_common/profile.prof.txt --output-profile-type=app",
+ )
+}