Merge commit 'c6655726b8004dc0398868901e375e7c9ad7a9d6' into dev-release
diff --git a/build.gradle b/build.gradle
index 4feb96d..d9be6a4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -434,14 +434,6 @@
"proto",
"protobuf-lite",
"retrace_internal",
- "youtube/youtube.android_12.10",
- "youtube/youtube.android_12.17",
- "youtube/youtube.android_12.22",
- "youtube/youtube.android_13.37",
- "youtube/youtube.android_14.19",
- "youtube/youtube.android_14.44",
- "youtube/youtube.android_15.08",
- "youtube/youtube.android_15.09",
"youtube/youtube.android_15.33",
"youtube/youtube.android_16.12"
],
@@ -1919,6 +1911,9 @@
}
}
+def testTimes = [:]
+def numberOfTestTimesToPrint = 40
+
test {
if (project.hasProperty('generate_golden_files_to')) {
systemProperty 'generate_golden_files_to', project.property('generate_golden_files_to')
@@ -1963,10 +1958,26 @@
systemProperty 'desugar_jdk_libs', project.property('desugar_jdk_libs')
}
+ if (project.hasProperty('print_times') || project.hasProperty('one_line_per_test')) {
+ afterTest { desc, result ->
+ def executionTime = (result.endTime - result.startTime) / 1000
+ testTimes["${desc.name} [${desc.className}]"] = executionTime
+ }
+ afterSuite { desc, result ->
+ // parent is null if all tests are done.
+ if (desc.parent == null) {
+ def sortedTimes = testTimes.sort({e1, e2 -> e2.value <=> e1.value})
+ sortedTimes.eachWithIndex{key, value, i ->
+ if (i < numberOfTestTimesToPrint) println "$key: $value"}
+ }
+ }
+ }
+
if (project.hasProperty('one_line_per_test')) {
beforeTest { desc ->
println "Start executing test ${desc.name} [${desc.className}]"
}
+
afterTest { desc, result ->
if (result.resultType == TestResult.ResultType.FAILURE) {
printStackTrace(result)
diff --git a/infra/config/global/cr-buildbucket.cfg b/infra/config/global/cr-buildbucket.cfg
index 959f32b..c1038e4 100644
--- a/infra/config/global/cr-buildbucket.cfg
+++ b/infra/config/global/cr-buildbucket.cfg
@@ -149,12 +149,21 @@
}
}
builders {
- name: "linux"
+ name: "linux-dex-default"
mixins: "linux"
mixins: "normal"
priority: 26
recipe {
- properties: "tool:r8"
+ properties_j: "test_options:[\"--runtimes=dex-default\", \"--tool=r8\", \"--no_internal\", \"--all_tests\", \"--one_line_per_test\", \"--archive_failures\"]"
+ }
+ }
+ builders {
+ name: "linux-none"
+ mixins: "linux"
+ mixins: "normal"
+ priority: 26
+ recipe {
+ properties_j: "test_options:[\"--runtimes=none\", \"--no_internal\", \"--one_line_per_test\", \"--archive_failures\"]"
}
}
builders {
@@ -185,11 +194,19 @@
}
}
builders {
- name: "linux_release"
+ name: "linux-dex-default_release"
mixins: "normal"
mixins: "linux"
recipe {
- properties: "tool:r8"
+ properties_j: "test_options:[\"--runtimes=dex-default\", \"--tool=r8\", \"--no_internal\", \"--all_tests\", \"--one_line_per_test\", \"--archive_failures\"]"
+ }
+ }
+ builders {
+ name: "linux-none_release"
+ mixins: "normal"
+ mixins: "linux"
+ recipe {
+ properties_j: "test_options:[\"--runtimes=none\", \"--no_internal\", \"--one_line_per_test\", \"--archive_failures\"]"
}
}
builders {
diff --git a/infra/config/global/luci-milo.cfg b/infra/config/global/luci-milo.cfg
index 1d4ce51..5b0bb98 100644
--- a/infra/config/global/luci-milo.cfg
+++ b/infra/config/global/luci-milo.cfg
@@ -11,9 +11,14 @@
short_name: "archive"
}
builders {
- name: "buildbucket/luci.r8.ci/linux"
+ name: "buildbucket/luci.r8.ci/linux-dex-default"
category: "R8"
- short_name: "linux"
+ short_name: "dex-default"
+ }
+ builders {
+ name: "buildbucket/luci.r8.ci/linux-none"
+ category: "R8"
+ short_name: "none"
}
builders {
name: "buildbucket/luci.r8.ci/linux-jdk8"
@@ -111,9 +116,14 @@
short_name: "archive"
}
builders {
- name: "buildbucket/luci.r8.ci/linux_release"
+ name: "buildbucket/luci.r8.ci/linux-dex-default_release"
category: "R8 release"
- short_name: "linux"
+ short_name: "dex-default"
+ }
+ builders {
+ name: "buildbucket/luci.r8.ci/linux-none_release"
+ category: "R8 release"
+ short_name: "none"
}
builders {
name: "buildbucket/luci.r8.ci/linux-jdk8_release"
diff --git a/infra/config/global/luci-scheduler.cfg b/infra/config/global/luci-scheduler.cfg
index edc7dbf..d6c888e 100644
--- a/infra/config/global/luci-scheduler.cfg
+++ b/infra/config/global/luci-scheduler.cfg
@@ -26,7 +26,8 @@
refs: "refs/heads/main"
}
triggers: "archive"
- triggers: "linux"
+ triggers: "linux-dex-default"
+ triggers: "linux-none"
triggers: "linux-jdk8"
triggers: "linux-jdk9"
triggers: "linux-jdk11"
@@ -76,7 +77,8 @@
path_regexps: "src/main/java/com/android/tools/r8/Version.java"
}
triggers: "archive_release"
- triggers: "linux_release"
+ triggers: "linux-dex-default_release"
+ triggers: "linux-none_release"
triggers: "linux-jdk8_release"
triggers: "linux-jdk9_release"
triggers: "linux-jdk11_release"
@@ -176,7 +178,7 @@
}
job {
- id: "linux"
+ id: "linux-dex-default"
acl_sets: "default"
triggering_policy: {
kind: GREEDY_BATCHING
@@ -185,7 +187,21 @@
buildbucket {
server: "cr-buildbucket.appspot.com"
bucket: "luci.r8.ci"
- builder: "linux"
+ builder: "linux-dex-default"
+ }
+}
+
+job {
+ id: "linux-none"
+ acl_sets: "default"
+ triggering_policy: {
+ kind: GREEDY_BATCHING
+ max_concurrent_invocations: 6
+ }
+ buildbucket {
+ server: "cr-buildbucket.appspot.com"
+ bucket: "luci.r8.ci"
+ builder: "linux-none"
}
}
@@ -573,7 +589,7 @@
}
job {
- id: "linux_release"
+ id: "linux-dex-default_release"
acl_sets: "default"
triggering_policy: {
max_batch_size: 1
@@ -582,7 +598,21 @@
buildbucket {
server: "cr-buildbucket.appspot.com"
bucket: "luci.r8.ci"
- builder: "linux_release"
+ builder: "linux-dex-default_release"
+ }
+}
+
+job {
+ id: "linux-none_release"
+ acl_sets: "default"
+ triggering_policy: {
+ max_batch_size: 1
+ max_concurrent_invocations: 3
+ }
+ buildbucket {
+ server: "cr-buildbucket.appspot.com"
+ bucket: "luci.r8.ci"
+ builder: "linux-none_release"
}
}
diff --git a/src/main/java/com/android/tools/r8/dex/ApplicationWriter.java b/src/main/java/com/android/tools/r8/dex/ApplicationWriter.java
index fa7e21d..1db8182 100644
--- a/src/main/java/com/android/tools/r8/dex/ApplicationWriter.java
+++ b/src/main/java/com/android/tools/r8/dex/ApplicationWriter.java
@@ -646,7 +646,7 @@
// TODO(b/181636450): Reconsider the code mapping setup now that synthetics are never
// duplicated in outputs.
boolean isSharedSynthetic =
- appView.getSyntheticItems().getSynthesizingContexts(clazz.getType()).size() > 1;
+ appView.getSyntheticItems().getSynthesizingContextTypes(clazz.getType()).size() > 1;
clazz.forEachMethod(
method -> {
DexCode code =
diff --git a/src/main/java/com/android/tools/r8/dex/FileWriter.java b/src/main/java/com/android/tools/r8/dex/FileWriter.java
index 889fc27..9b7c9da 100644
--- a/src/main/java/com/android/tools/r8/dex/FileWriter.java
+++ b/src/main/java/com/android/tools/r8/dex/FileWriter.java
@@ -690,7 +690,7 @@
writeEncodedFields(clazz.staticFields());
writeEncodedFields(clazz.instanceFields());
boolean isSharedSynthetic =
- appInfo.getSyntheticItems().getSynthesizingContexts(clazz.getType()).size() > 1;
+ appInfo.getSyntheticItems().getSynthesizingContextTypes(clazz.getType()).size() > 1;
writeEncodedMethods(clazz.directMethods(), isSharedSynthetic);
writeEncodedMethods(clazz.virtualMethods(), isSharedSynthetic);
}
diff --git a/src/main/java/com/android/tools/r8/dex/VirtualFile.java b/src/main/java/com/android/tools/r8/dex/VirtualFile.java
index e44973a..fa17d7c 100644
--- a/src/main/java/com/android/tools/r8/dex/VirtualFile.java
+++ b/src/main/java/com/android/tools/r8/dex/VirtualFile.java
@@ -330,7 +330,7 @@
// Assign dedicated virtual files for all program classes.
for (DexProgramClass clazz : appView.appInfo().classes()) {
Collection<DexType> contexts =
- appView.getSyntheticItems().getSynthesizingContexts(clazz.getType());
+ appView.getSyntheticItems().getSynthesizingContextTypes(clazz.getType());
// TODO(b/181636450): Simplify this making use of the assumption that synthetics are never
// duplicated.
if (!combineSyntheticClassesWithPrimaryClass || contexts.isEmpty()) {
@@ -354,7 +354,7 @@
}
for (DexProgramClass synthetic : synthetics) {
for (DexType context :
- appView.getSyntheticItems().getSynthesizingContexts(synthetic.getType())) {
+ appView.getSyntheticItems().getSynthesizingContextTypes(synthetic.getType())) {
DexProgramClass inputType = appView.definitionForProgramType(context);
VirtualFile file = files.get(inputType);
file.addClass(synthetic);
diff --git a/src/main/java/com/android/tools/r8/features/ClassToFeatureSplitMap.java b/src/main/java/com/android/tools/r8/features/ClassToFeatureSplitMap.java
index c8c462b..f460b50 100644
--- a/src/main/java/com/android/tools/r8/features/ClassToFeatureSplitMap.java
+++ b/src/main/java/com/android/tools/r8/features/ClassToFeatureSplitMap.java
@@ -22,10 +22,8 @@
import com.android.tools.r8.utils.InternalOptions;
import com.android.tools.r8.utils.Reporter;
import com.google.common.collect.Sets;
-import java.util.Collection;
import java.util.HashMap;
import java.util.IdentityHashMap;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -95,6 +93,10 @@
public int compareFeatureSplitsForDexTypes(DexType a, DexType b, SyntheticItems syntheticItems) {
FeatureSplit featureSplitA = getFeatureSplit(a, syntheticItems);
FeatureSplit featureSplitB = getFeatureSplit(b, syntheticItems);
+ return compareFeatureSplits(featureSplitA, featureSplitB);
+ }
+
+ public int compareFeatureSplits(FeatureSplit featureSplitA, FeatureSplit featureSplitB) {
assert featureSplitA != null;
assert featureSplitB != null;
if (featureSplitA == featureSplitB) {
@@ -129,26 +131,20 @@
}
public FeatureSplit getFeatureSplit(DexType type, SyntheticItems syntheticItems) {
- Collection<DexType> contexts = syntheticItems.getSynthesizingContexts(type);
- if (!contexts.isEmpty()) {
- Iterator<DexType> iterator = contexts.iterator();
- DexType context = iterator.next();
- FeatureSplit feature = classToFeatureSplitMap.getOrDefault(context, FeatureSplit.BASE);
- assert verifyConsistentFeatureContexts(iterator, feature);
+ FeatureSplit feature = classToFeatureSplitMap.get(type);
+ if (feature != null) {
return feature;
}
- return classToFeatureSplitMap.getOrDefault(type, FeatureSplit.BASE);
- }
-
- private boolean verifyConsistentFeatureContexts(
- Iterator<DexType> contextIterator, FeatureSplit feature) {
- while (contextIterator.hasNext()) {
- assert feature
- == classToFeatureSplitMap.getOrDefault(contextIterator.next(), FeatureSplit.BASE);
+ feature = syntheticItems.getContextualFeatureSplit(type);
+ if (feature != null) {
+ return feature;
}
- return true;
+ return FeatureSplit.BASE;
}
+ // Note, this predicate may be misleading as the map does not include synthetics.
+ // In practice it should not be an issue as there should not be a way to have a feature shrink
+ // to only contain synthetic content. At a minimum the entry points of the feature must remain.
public boolean isEmpty() {
return classToFeatureSplitMap.isEmpty();
}
diff --git a/src/main/java/com/android/tools/r8/horizontalclassmerging/SyntheticArgumentClass.java b/src/main/java/com/android/tools/r8/horizontalclassmerging/SyntheticArgumentClass.java
index c8cc19e..88a4755 100644
--- a/src/main/java/com/android/tools/r8/horizontalclassmerging/SyntheticArgumentClass.java
+++ b/src/main/java/com/android/tools/r8/horizontalclassmerging/SyntheticArgumentClass.java
@@ -53,7 +53,7 @@
private DexProgramClass synthesizeClass(DexProgramClass context, SyntheticKind syntheticKind) {
return appView
.getSyntheticItems()
- .createFixedClass(syntheticKind, context, appView.dexItemFactory(), builder -> {});
+ .createFixedClass(syntheticKind, context, appView, builder -> {});
}
public SyntheticArgumentClass build(Collection<MergeGroup> mergeGroups) {
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java b/src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
index 832fd8c..cc28692 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
@@ -1442,7 +1442,7 @@
.createMethod(
SyntheticNaming.SyntheticKind.BACKPORT,
methodProcessingContext.createUniqueContext(),
- appView.dexItemFactory(),
+ appView,
builder ->
builder
.setProto(getProto(appView.dexItemFactory()))
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/RecordRewriter.java b/src/main/java/com/android/tools/r8/ir/desugar/RecordRewriter.java
index 5770e22..b9a8880 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/RecordRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/RecordRewriter.java
@@ -228,7 +228,7 @@
.createMethod(
SyntheticNaming.SyntheticKind.RECORD_HELPER,
methodProcessingContext.createUniqueContext(),
- factory,
+ appView,
builder ->
builder
.setProto(helperProto)
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/itf/InterfaceMethodRewriter.java b/src/main/java/com/android/tools/r8/ir/desugar/itf/InterfaceMethodRewriter.java
index 0899b2d..180c2aa 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/itf/InterfaceMethodRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/itf/InterfaceMethodRewriter.java
@@ -25,6 +25,7 @@
import com.android.tools.r8.errors.Unimplemented;
import com.android.tools.r8.graph.AppInfo;
import com.android.tools.r8.graph.AppView;
+import com.android.tools.r8.graph.ClasspathOrLibraryClass;
import com.android.tools.r8.graph.DexApplication.Builder;
import com.android.tools.r8.graph.DexCallSite;
import com.android.tools.r8.graph.DexClass;
@@ -455,7 +456,7 @@
.createMethod(
SyntheticNaming.SyntheticKind.STATIC_INTERFACE_CALL,
methodProcessingContext.createUniqueContext(),
- factory,
+ appView,
syntheticMethodBuilder ->
syntheticMethodBuilder
.setProto(invokedMethod.proto)
@@ -907,18 +908,18 @@
private static void recordCompanionClassReference(
AppView<?> appView, DexClassAndMethod method, DexMethod rewritten) {
+ ClasspathOrLibraryClass context = method.getHolder().asClasspathOrLibraryClass();
// If the interface class is a program class, we shouldn't need to synthesize the companion
// class on the classpath.
- if (method.getHolder().isProgramClass()) {
+ if (context == null) {
return;
}
-
appView
.getSyntheticItems()
.ensureDirectMethodOnSyntheticClasspathClassWhileMigrating(
SyntheticKind.COMPANION_CLASS,
rewritten.getHolderType(),
- method.getHolder(),
+ context,
appView,
rewritten,
builder ->
@@ -1149,7 +1150,7 @@
if (consumer != null) {
Origin dependencyOrigin = dependency.getOrigin();
java.util.Collection<DexType> dependents =
- appInfo.getSyntheticItems().getSynthesizingContexts(dependent.getType());
+ appInfo.getSyntheticItems().getSynthesizingContextTypes(dependent.getType());
if (dependents.isEmpty()) {
reportDependencyEdge(consumer, dependencyOrigin, dependent);
} else {
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/lambda/LambdaInstructionDesugaring.java b/src/main/java/com/android/tools/r8/ir/desugar/lambda/LambdaInstructionDesugaring.java
index 667397b..ad1cacb 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/lambda/LambdaInstructionDesugaring.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/lambda/LambdaInstructionDesugaring.java
@@ -148,7 +148,7 @@
.createClass(
SyntheticNaming.SyntheticKind.LAMBDA,
methodProcessingContext.createUniqueContext(),
- appView.dexItemFactory(),
+ appView,
builder -> box.set(new LambdaClass(builder, appView, this, context, descriptor)));
// Immediately set the actual program class on the lambda.
LambdaClass lambdaClass = box.get();
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/nest/NestBasedAccessDesugaring.java b/src/main/java/com/android/tools/r8/ir/desugar/nest/NestBasedAccessDesugaring.java
index a3bdc56..a7f094e 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/nest/NestBasedAccessDesugaring.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/nest/NestBasedAccessDesugaring.java
@@ -325,7 +325,7 @@
.createFixedClass(
SyntheticKind.INIT_TYPE_ARGUMENT,
method.asProgramMethod().getHolder(),
- dexItemFactory,
+ appView,
builder -> {})
.getType();
} else {
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/twr/TwrCloseResourceInstructionDesugaring.java b/src/main/java/com/android/tools/r8/ir/desugar/twr/TwrCloseResourceInstructionDesugaring.java
index 30e7702..212259a 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/twr/TwrCloseResourceInstructionDesugaring.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/twr/TwrCloseResourceInstructionDesugaring.java
@@ -71,7 +71,7 @@
.createMethod(
SyntheticKind.TWR_CLOSE_RESOURCE,
methodProcessingContext.createUniqueContext(),
- appView.dexItemFactory(),
+ appView,
methodBuilder ->
methodBuilder
.setAccessFlags(MethodAccessFlags.createPublicStaticSynthetic())
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/Outliner.java b/src/main/java/com/android/tools/r8/ir/optimize/Outliner.java
index 2f32c5c..f7a59dd 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/Outliner.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/Outliner.java
@@ -1367,7 +1367,7 @@
.createMethod(
SyntheticKind.OUTLINE,
methodProcessingContext.createUniqueContext(),
- appView.dexItemFactory(),
+ appView,
builder -> {
builder
.setAccessFlags(
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/ServiceLoaderRewriter.java b/src/main/java/com/android/tools/r8/ir/optimize/ServiceLoaderRewriter.java
index d532b9b..9b9dc08 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/ServiceLoaderRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/ServiceLoaderRewriter.java
@@ -193,7 +193,7 @@
.createMethod(
SyntheticKind.SERVICE_LOADER,
methodProcessingContext.createUniqueContext(),
- appView.dexItemFactory(),
+ appView,
builder ->
builder
.setAccessFlags(MethodAccessFlags.createPublicStaticSynthetic())
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/UtilityMethodsForCodeOptimizations.java b/src/main/java/com/android/tools/r8/ir/optimize/UtilityMethodsForCodeOptimizations.java
index 687a9bf..953a78c 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/UtilityMethodsForCodeOptimizations.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/UtilityMethodsForCodeOptimizations.java
@@ -38,7 +38,7 @@
syntheticItems.createMethod(
SyntheticNaming.SyntheticKind.TO_STRING_IF_NOT_NULL,
methodProcessingContext.createUniqueContext(),
- dexItemFactory,
+ appView,
builder ->
builder
.setAccessFlags(MethodAccessFlags.createPublicStaticSynthetic())
@@ -65,7 +65,7 @@
syntheticItems.createMethod(
SyntheticNaming.SyntheticKind.THROW_CCE_IF_NOT_NULL,
positionContext,
- dexItemFactory,
+ appView,
builder ->
builder
.setAccessFlags(MethodAccessFlags.createPublicStaticSynthetic())
@@ -93,7 +93,7 @@
syntheticItems.createMethod(
SyntheticNaming.SyntheticKind.THROW_IAE,
methodProcessingContext.createUniqueContext(),
- dexItemFactory,
+ appView,
builder ->
builder
.setAccessFlags(MethodAccessFlags.createPublicStaticSynthetic())
@@ -119,7 +119,7 @@
syntheticItems.createMethod(
SyntheticNaming.SyntheticKind.THROW_ICCE,
methodProcessingContext.createUniqueContext(),
- dexItemFactory,
+ appView,
builder ->
builder
.setAccessFlags(MethodAccessFlags.createPublicStaticSynthetic())
@@ -147,7 +147,7 @@
syntheticItems.createMethod(
SyntheticNaming.SyntheticKind.THROW_NSME,
methodProcessingContext.createUniqueContext(),
- dexItemFactory,
+ appView,
builder ->
builder
.setAccessFlags(MethodAccessFlags.createPublicStaticSynthetic())
diff --git a/src/main/java/com/android/tools/r8/retrace/internal/RetraceClassResultImpl.java b/src/main/java/com/android/tools/r8/retrace/internal/RetraceClassResultImpl.java
index fd8ebb6..1163213 100644
--- a/src/main/java/com/android/tools/r8/retrace/internal/RetraceClassResultImpl.java
+++ b/src/main/java/com/android/tools/r8/retrace/internal/RetraceClassResultImpl.java
@@ -157,7 +157,7 @@
if (mappedRanges == null || mappedRanges.getMappedRanges().isEmpty()) {
return null;
}
- if (position <= 0) {
+ if (position < 0) {
return mappedRanges.getMappedRanges();
}
List<MappedRange> mappedRangesForPosition = mappedRanges.allRangesForLine(position, false);
diff --git a/src/main/java/com/android/tools/r8/shaking/MainDexInfo.java b/src/main/java/com/android/tools/r8/shaking/MainDexInfo.java
index 96e263c..5be14a3 100644
--- a/src/main/java/com/android/tools/r8/shaking/MainDexInfo.java
+++ b/src/main/java/com/android/tools/r8/shaking/MainDexInfo.java
@@ -113,7 +113,7 @@
return false;
}
DexType type = reference.getContextType();
- for (DexType context : synthetics.getSynthesizingContexts(type)) {
+ for (DexType context : synthetics.getSynthesizingContextTypes(type)) {
if (items.contains(context)) {
return true;
}
diff --git a/src/main/java/com/android/tools/r8/shaking/MissingClasses.java b/src/main/java/com/android/tools/r8/shaking/MissingClasses.java
index 0330dca..aa87461 100644
--- a/src/main/java/com/android/tools/r8/shaking/MissingClasses.java
+++ b/src/main/java/com/android/tools/r8/shaking/MissingClasses.java
@@ -191,7 +191,9 @@
// Rewrite the synthetic context to its synthesizing contexts.
Set<DexReference> synthesizingContextReferences =
- appView.getSyntheticItems().getSynthesizingContexts(clazz, synthesizingContextOracle);
+ appView
+ .getSyntheticItems()
+ .getSynthesizingContextReferences(clazz, synthesizingContextOracle);
assert synthesizingContextReferences != null;
assert !synthesizingContextReferences.isEmpty();
for (DexReference synthesizingContextReference : synthesizingContextReferences) {
diff --git a/src/main/java/com/android/tools/r8/synthesis/SynthesizingContext.java b/src/main/java/com/android/tools/r8/synthesis/SynthesizingContext.java
index 04ec40a..6a611dc 100644
--- a/src/main/java/com/android/tools/r8/synthesis/SynthesizingContext.java
+++ b/src/main/java/com/android/tools/r8/synthesis/SynthesizingContext.java
@@ -6,8 +6,9 @@
import static com.android.tools.r8.utils.DescriptorUtils.getBinaryNameFromDescriptor;
import static com.android.tools.r8.utils.DescriptorUtils.getDescriptorFromClassBinaryName;
+import com.android.tools.r8.FeatureSplit;
import com.android.tools.r8.graph.AppView;
-import com.android.tools.r8.graph.DexClass;
+import com.android.tools.r8.graph.ClasspathOrLibraryClass;
import com.android.tools.r8.graph.DexProgramClass;
import com.android.tools.r8.graph.DexType;
import com.android.tools.r8.graph.GraphLens.NonIdentityGraphLens;
@@ -37,37 +38,55 @@
private final DexType inputContextType;
private final Origin inputContextOrigin;
- static SynthesizingContext fromNonSyntheticInputContext(DexClass context) {
+ private final FeatureSplit featureSplit;
+
+ static SynthesizingContext fromNonSyntheticInputContext(ClasspathOrLibraryClass context) {
// A context that is itself non-synthetic is the single context, thus both the input context
// and synthesizing context coincide.
return new SynthesizingContext(
- context.getContextType(), context.getContextType(), context.getOrigin());
+ context.getContextType(),
+ context.getContextType(),
+ context.getOrigin(),
+ // Synthesizing from a non-program context is just considered to be "base".
+ FeatureSplit.BASE);
}
static SynthesizingContext fromType(DexType type) {
- return new SynthesizingContext(type, type, Origin.unknown());
+ // This method should only be used for synthesizing from a non-program context!
+ // Thus we have no origin info and place the context in the "base" feature.
+ return new SynthesizingContext(type, type, Origin.unknown(), FeatureSplit.BASE);
}
- static SynthesizingContext fromNonSyntheticInputContext(ProgramDefinition context) {
+ static SynthesizingContext fromNonSyntheticInputContext(
+ ProgramDefinition context, FeatureSplit featureSplit) {
// A context that is itself non-synthetic is the single context, thus both the input context
// and synthesizing context coincide.
return new SynthesizingContext(
- context.getContextType(), context.getContextType(), context.getOrigin());
+ context.getContextType(), context.getContextType(), context.getOrigin(), featureSplit);
}
static SynthesizingContext fromSyntheticInputClass(
- DexProgramClass clazz, DexType synthesizingContextType) {
+ DexProgramClass clazz, DexType synthesizingContextType, AppView<?> appView) {
assert synthesizingContextType != null;
// A context that is itself synthetic must denote a synthesizing context from which to ensure
// hygiene. This synthesizing context type is encoded on the synthetic for intermediate builds.
- return new SynthesizingContext(synthesizingContextType, clazz.type, clazz.origin);
+ FeatureSplit featureSplit =
+ appView
+ .appInfoForDesugaring()
+ .getClassToFeatureSplitMap()
+ .getFeatureSplit(clazz, appView.getSyntheticItems());
+ return new SynthesizingContext(synthesizingContextType, clazz.type, clazz.origin, featureSplit);
}
private SynthesizingContext(
- DexType synthesizingContextType, DexType inputContextType, Origin inputContextOrigin) {
+ DexType synthesizingContextType,
+ DexType inputContextType,
+ Origin inputContextOrigin,
+ FeatureSplit featureSplit) {
this.synthesizingContextType = synthesizingContextType;
this.inputContextType = inputContextType;
this.inputContextOrigin = inputContextOrigin;
+ this.featureSplit = featureSplit;
}
@Override
@@ -81,10 +100,18 @@
.compare(this, other);
}
+ DexType getSynthesizingContextType() {
+ return synthesizingContextType;
+ }
+
Origin getInputContextOrigin() {
return inputContextOrigin;
}
+ FeatureSplit getFeatureSplit() {
+ return featureSplit;
+ }
+
SynthesizingContext rewrite(NonIdentityGraphLens lens) {
DexType rewrittenInputeContextType = lens.lookupType(inputContextType);
DexType rewrittenSynthesizingContextType = lens.lookupType(synthesizingContextType);
@@ -92,11 +119,10 @@
&& rewrittenSynthesizingContextType == synthesizingContextType
? this
: new SynthesizingContext(
- rewrittenSynthesizingContextType, rewrittenInputeContextType, inputContextOrigin);
- }
-
- DexType getSynthesizingContextType() {
- return synthesizingContextType;
+ rewrittenSynthesizingContextType,
+ rewrittenInputeContextType,
+ inputContextOrigin,
+ featureSplit);
}
void registerPrefixRewriting(DexType hygienicType, AppView<?> appView) {
@@ -128,7 +154,10 @@
@Override
public String toString() {
- return "SynthesizingContext{" + getSynthesizingContextType() + "}";
+ return "SynthesizingContext{"
+ + getSynthesizingContextType()
+ + (featureSplit != FeatureSplit.BASE ? ", feature:" + featureSplit : "")
+ + "}";
}
// TODO(b/181858113): Remove once deprecated main-dex-list is removed.
diff --git a/src/main/java/com/android/tools/r8/synthesis/SyntheticDefinition.java b/src/main/java/com/android/tools/r8/synthesis/SyntheticDefinition.java
index f6577d3..3c91d68 100644
--- a/src/main/java/com/android/tools/r8/synthesis/SyntheticDefinition.java
+++ b/src/main/java/com/android/tools/r8/synthesis/SyntheticDefinition.java
@@ -81,13 +81,7 @@
// single context.
getContext().getSynthesizingContextType().hashWithTypeEquivalence(hasher, map);
}
- if (!classToFeatureSplitMap.isEmpty()) {
- hasher.putInt(
- classToFeatureSplitMap
- .getFeatureSplit(getContext().getSynthesizingContextType(), syntheticItems)
- .hashCode());
- }
-
+ hasher.putInt(context.getFeatureSplit().hashCode());
internalComputeHash(hasher, map);
return hasher.hash();
}
@@ -121,17 +115,12 @@
return order;
}
}
- if (!classToFeatureSplitMap.isEmpty()) {
- DexType synthesizingContextType = this.getContext().getSynthesizingContextType();
- DexType otherSynthesizingContextType = other.getContext().getSynthesizingContextType();
- if (!classToFeatureSplitMap.isInSameFeatureOrBothInBase(
- synthesizingContextType, otherSynthesizingContextType, syntheticItems)) {
- int order =
- classToFeatureSplitMap.compareFeatureSplitsForDexTypes(
- synthesizingContextType, otherSynthesizingContextType, syntheticItems);
- assert order != 0;
- return order;
- }
+ if (getContext().getFeatureSplit() != other.getContext().getFeatureSplit()) {
+ int order =
+ classToFeatureSplitMap.compareFeatureSplits(
+ context.getFeatureSplit(), other.getContext().getFeatureSplit());
+ assert order != 0;
+ return order;
}
RepresentativeMap map = null;
// If the synthetics have been moved include the original types in the equivalence.
diff --git a/src/main/java/com/android/tools/r8/synthesis/SyntheticItems.java b/src/main/java/com/android/tools/r8/synthesis/SyntheticItems.java
index b90083a..6a539f0 100644
--- a/src/main/java/com/android/tools/r8/synthesis/SyntheticItems.java
+++ b/src/main/java/com/android/tools/r8/synthesis/SyntheticItems.java
@@ -3,9 +3,12 @@
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.synthesis;
+import com.android.tools.r8.FeatureSplit;
import com.android.tools.r8.contexts.CompilationContext.UniqueContext;
+import com.android.tools.r8.features.ClassToFeatureSplitMap;
import com.android.tools.r8.graph.AppInfo;
import com.android.tools.r8.graph.AppView;
+import com.android.tools.r8.graph.ClasspathOrLibraryClass;
import com.android.tools.r8.graph.DexApplication;
import com.android.tools.r8.graph.DexClass;
import com.android.tools.r8.graph.DexClasspathClass;
@@ -123,8 +126,7 @@
synthetics.committed.builderForSyntheticInputs();
// TODO(b/158159959): Consider identifying synthetics in the input reader to speed this up.
for (DexProgramClass clazz : appView.appInfo().classes()) {
- SyntheticMarker marker =
- SyntheticMarker.stripMarkerFromClass(clazz, appView.dexItemFactory());
+ SyntheticMarker marker = SyntheticMarker.stripMarkerFromClass(clazz, appView);
if (marker.isSyntheticMethods()) {
clazz.forEachProgramMethod(
// TODO(b/158159959): Support having multiple methods per class.
@@ -260,7 +262,37 @@
return isSyntheticClass(clazz.type);
}
- public Collection<DexType> getSynthesizingContexts(DexType type) {
+ public FeatureSplit getContextualFeatureSplit(DexType type) {
+ List<SynthesizingContext> contexts = getSynthesizingContexts(type);
+ if (contexts.isEmpty()) {
+ return null;
+ }
+ assert verifyAllContextsHaveSameFeature(contexts);
+ return contexts.get(0).getFeatureSplit();
+ }
+
+ private boolean verifyAllContextsHaveSameFeature(List<SynthesizingContext> contexts) {
+ assert !contexts.isEmpty();
+ FeatureSplit featureSplit = contexts.get(0).getFeatureSplit();
+ for (int i = 1; i < contexts.size(); i++) {
+ assert featureSplit == contexts.get(i).getFeatureSplit();
+ }
+ return true;
+ }
+
+ private List<SynthesizingContext> getSynthesizingContexts(DexType type) {
+ SyntheticReference<?, ?, ?> reference = committed.getNonLegacyItem(type);
+ if (reference != null) {
+ return Collections.singletonList(reference.getContext());
+ }
+ SyntheticDefinition<?, ?, ?> definition = pending.nonLegacyDefinitions.get(type);
+ if (definition != null) {
+ return Collections.singletonList(definition.getContext());
+ }
+ return Collections.emptyList();
+ }
+
+ public Collection<DexType> getSynthesizingContextTypes(DexType type) {
SyntheticReference<?, ?, ?> reference = committed.getNonLegacyItem(type);
if (reference != null) {
return Collections.singletonList(reference.getContext().getSynthesizingContextType());
@@ -281,7 +313,7 @@
}
// TODO(b/180091213): Implement this and remove client provided the oracle.
- public Set<DexReference> getSynthesizingContexts(
+ public Set<DexReference> getSynthesizingContextReferences(
DexProgramClass clazz, SynthesizingContextOracle oracle) {
assert isSyntheticClass(clazz);
return oracle.getSynthesizingContexts(clazz);
@@ -317,7 +349,14 @@
return ListUtils.map(pending.legacyClasses.values(), LegacySyntheticDefinition::getDefinition);
}
- private SynthesizingContext getSynthesizingContext(ProgramDefinition context) {
+ private SynthesizingContext getSynthesizingContext(
+ ProgramDefinition context, AppView<?> appView) {
+ return getSynthesizingContext(
+ context, appView.appInfoForDesugaring().getClassToFeatureSplitMap());
+ }
+
+ private SynthesizingContext getSynthesizingContext(
+ ProgramDefinition context, ClassToFeatureSplitMap featureSplits) {
DexType contextType = context.getContextType();
SyntheticDefinition<?, ?, ?> existingDefinition = pending.nonLegacyDefinitions.get(contextType);
if (existingDefinition != null) {
@@ -328,7 +367,8 @@
return existingReference.getContext();
}
// This context is not nested in an existing synthetic context so create a new "leaf" context.
- return SynthesizingContext.fromNonSyntheticInputContext(context);
+ FeatureSplit featureSplit = featureSplits.getFeatureSplit(context, this);
+ return SynthesizingContext.fromNonSyntheticInputContext(context, featureSplit);
}
// Addition and creation of synthetic items.
@@ -358,16 +398,16 @@
public DexProgramClass createClass(
SyntheticKind kind,
UniqueContext context,
- DexItemFactory factory,
+ AppView<?> appView,
Consumer<SyntheticProgramClassBuilder> fn) {
// Obtain the outer synthesizing context in the case the context itself is synthetic.
// This is to ensure a flat input-type -> synthetic-item mapping.
- SynthesizingContext outerContext = getSynthesizingContext(context.getClassContext());
+ SynthesizingContext outerContext = getSynthesizingContext(context.getClassContext(), appView);
DexType type =
SyntheticNaming.createInternalType(
- kind, outerContext, context.getSyntheticSuffix(), factory);
+ kind, outerContext, context.getSyntheticSuffix(), appView.dexItemFactory());
SyntheticProgramClassBuilder classBuilder =
- new SyntheticProgramClassBuilder(type, outerContext, factory);
+ new SyntheticProgramClassBuilder(type, outerContext, appView.dexItemFactory());
fn.accept(classBuilder);
DexProgramClass clazz = classBuilder.build();
addPendingDefinition(new SyntheticProgramClassDefinition(kind, outerContext, clazz));
@@ -378,14 +418,14 @@
public DexProgramClass createFixedClass(
SyntheticKind kind,
DexProgramClass context,
- DexItemFactory factory,
+ AppView<?> appView,
Consumer<SyntheticProgramClassBuilder> fn) {
// Obtain the outer synthesizing context in the case the context itself is synthetic.
// This is to ensure a flat input-type -> synthetic-item mapping.
- SynthesizingContext outerContext = getSynthesizingContext(context);
- DexType type = SyntheticNaming.createFixedType(kind, outerContext, factory);
+ SynthesizingContext outerContext = getSynthesizingContext(context, appView);
+ DexType type = SyntheticNaming.createFixedType(kind, outerContext, appView.dexItemFactory());
SyntheticProgramClassBuilder classBuilder =
- new SyntheticProgramClassBuilder(type, outerContext, factory);
+ new SyntheticProgramClassBuilder(type, outerContext, appView.dexItemFactory());
fn.accept(classBuilder);
DexProgramClass clazz = classBuilder.build();
addPendingDefinition(new SyntheticProgramClassDefinition(kind, outerContext, clazz));
@@ -409,7 +449,7 @@
}
// Obtain the outer synthesizing context in the case the context itself is synthetic.
// This is to ensure a flat input-type -> synthetic-item mapping.
- SynthesizingContext outerContext = getSynthesizingContext(context);
+ SynthesizingContext outerContext = getSynthesizingContext(context, appView);
SyntheticProgramClassBuilder classBuilder =
new SyntheticProgramClassBuilder(legacyType, outerContext, appView.dexItemFactory());
fn.accept(classBuilder);
@@ -436,7 +476,7 @@
// like a hygienic synthetic, but use the legacyType passed as parameter instead of the
// hygienic type.
private DexClasspathClass ensureFixedClasspathClassWhileMigrating(
- SyntheticKind kind, DexType legacyType, DexClass context, AppView<?> appView) {
+ SyntheticKind kind, DexType legacyType, ClasspathOrLibraryClass context, AppView<?> appView) {
synchronized (context) {
DexClass dexClass = appView.definitionFor(legacyType);
if (dexClass != null) {
@@ -460,7 +500,7 @@
public void ensureDirectMethodOnSyntheticClasspathClassWhileMigrating(
SyntheticKind kind,
DexType legacyType,
- DexClass context,
+ ClasspathOrLibraryClass context,
AppView<?> appView,
DexMethod method,
Consumer<SyntheticMethodBuilder> builderConsumer) {
@@ -498,25 +538,26 @@
public ProgramMethod createMethod(
SyntheticKind kind,
UniqueContext context,
- DexItemFactory factory,
+ AppView<?> appView,
Consumer<SyntheticMethodBuilder> fn) {
- return createMethod(kind, context.getClassContext(), factory, fn, context::getSyntheticSuffix);
+ return createMethod(kind, context.getClassContext(), appView, fn, context::getSyntheticSuffix);
}
private ProgramMethod createMethod(
SyntheticKind kind,
ProgramDefinition context,
- DexItemFactory factory,
+ AppView<?> appView,
Consumer<SyntheticMethodBuilder> fn,
Supplier<String> syntheticIdSupplier) {
assert nextSyntheticId != INVALID_ID_AFTER_SYNTHETIC_FINALIZATION;
// Obtain the outer synthesizing context in the case the context itself is synthetic.
// This is to ensure a flat input-type -> synthetic-item mapping.
- SynthesizingContext outerContext = getSynthesizingContext(context);
+ SynthesizingContext outerContext = getSynthesizingContext(context, appView);
DexType type =
- SyntheticNaming.createInternalType(kind, outerContext, syntheticIdSupplier.get(), factory);
+ SyntheticNaming.createInternalType(
+ kind, outerContext, syntheticIdSupplier.get(), appView.dexItemFactory());
SyntheticProgramClassBuilder classBuilder =
- new SyntheticProgramClassBuilder(type, outerContext, factory);
+ new SyntheticProgramClassBuilder(type, outerContext, appView.dexItemFactory());
DexProgramClass clazz =
classBuilder
.addMethod(fn.andThen(m -> m.setName(SyntheticNaming.INTERNAL_SYNTHETIC_METHOD_PREFIX)))
diff --git a/src/main/java/com/android/tools/r8/synthesis/SyntheticMarker.java b/src/main/java/com/android/tools/r8/synthesis/SyntheticMarker.java
index 03b7e36..d68558d 100644
--- a/src/main/java/com/android/tools/r8/synthesis/SyntheticMarker.java
+++ b/src/main/java/com/android/tools/r8/synthesis/SyntheticMarker.java
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.synthesis;
+import com.android.tools.r8.graph.AppView;
import com.android.tools.r8.graph.ClassAccessFlags;
import com.android.tools.r8.graph.DexAnnotation;
import com.android.tools.r8.graph.DexAnnotationSet;
@@ -28,26 +29,27 @@
kind, context.getSynthesizingContextType(), factory)));
}
- public static SyntheticMarker stripMarkerFromClass(
- DexProgramClass clazz, DexItemFactory factory) {
- SyntheticMarker marker = internalStripMarkerFromClass(clazz, factory);
+ public static SyntheticMarker stripMarkerFromClass(DexProgramClass clazz, AppView<?> appView) {
+ SyntheticMarker marker = internalStripMarkerFromClass(clazz, appView);
assert marker != NO_MARKER
- || DexAnnotation.getSynthesizedClassAnnotationContextType(clazz.annotations(), factory)
+ || DexAnnotation.getSynthesizedClassAnnotationContextType(
+ clazz.annotations(), appView.dexItemFactory())
== null;
return marker;
}
private static SyntheticMarker internalStripMarkerFromClass(
- DexProgramClass clazz, DexItemFactory factory) {
+ DexProgramClass clazz, AppView<?> appView) {
ClassAccessFlags flags = clazz.accessFlags;
- if (clazz.superType != factory.objectType) {
+ if (clazz.superType != appView.dexItemFactory().objectType) {
return NO_MARKER;
}
if (!flags.isSynthetic() || flags.isAbstract() || flags.isEnum()) {
return NO_MARKER;
}
Pair<SyntheticKind, DexType> info =
- DexAnnotation.getSynthesizedClassAnnotationContextType(clazz.annotations(), factory);
+ DexAnnotation.getSynthesizedClassAnnotationContextType(
+ clazz.annotations(), appView.dexItemFactory());
if (info == null) {
return NO_MARKER;
}
@@ -65,7 +67,8 @@
}
}
clazz.setAnnotations(DexAnnotationSet.empty());
- return new SyntheticMarker(kind, SynthesizingContext.fromSyntheticInputClass(clazz, context));
+ return new SyntheticMarker(
+ kind, SynthesizingContext.fromSyntheticInputClass(clazz, context, appView));
}
private static final SyntheticMarker NO_MARKER = new SyntheticMarker(null, null);
diff --git a/src/test/java/com/android/tools/r8/internal/D8YouTubeDeployJarVerificationTest.java b/src/test/java/com/android/tools/r8/internal/D8YouTubeDeployJarVerificationTest.java
deleted file mode 100644
index f6de3f9..0000000
--- a/src/test/java/com/android/tools/r8/internal/D8YouTubeDeployJarVerificationTest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.internal;
-
-import com.android.tools.r8.CompilationMode;
-import com.android.tools.r8.R8RunArtTestsTest.CompilerUnderTest;
-import org.junit.Test;
-
-public class D8YouTubeDeployJarVerificationTest extends YouTubeCompilationTestBase {
-
- public D8YouTubeDeployJarVerificationTest() {
- super(12, 17);
- }
-
- @Test
- public void buildDebugFromDeployJar() throws Exception {
- runAndCheckVerification(
- CompilerUnderTest.D8, CompilationMode.DEBUG, base + APK, null, base + DEPLOY_JAR);
- }
-
- @Test
- public void buildReleaseFromDeployJar() throws Exception {
- runAndCheckVerification(
- CompilerUnderTest.D8, CompilationMode.RELEASE, base + APK, null, base + DEPLOY_JAR);
- }
-}
diff --git a/src/test/java/com/android/tools/r8/internal/YouTubeCompilationTestBase.java b/src/test/java/com/android/tools/r8/internal/YouTubeCompilationTestBase.java
index b9c868c..b3853ef 100644
--- a/src/test/java/com/android/tools/r8/internal/YouTubeCompilationTestBase.java
+++ b/src/test/java/com/android/tools/r8/internal/YouTubeCompilationTestBase.java
@@ -18,9 +18,7 @@
public abstract class YouTubeCompilationTestBase extends CompilationTestBase {
- static final String APK = "YouTubeRelease_unsigned.apk";
static final String DEPLOY_JAR = "YouTubeRelease_deploy.jar";
- static final String PG_JAR = "YouTubeRelease_proguard.jar";
static final String PG_MAP = "YouTubeRelease_proguard.map";
static final String PG_CONF = "YouTubeRelease_proguard.config";
static final String PG_PROTO_CONF = "YouTubeRelease_proto_safety.pgconf";
@@ -120,9 +118,4 @@
Path getReleaseProguardMap() {
return Paths.get(base).resolve(PG_MAP);
}
-
- void runR8AndCheckVerification(CompilationMode mode, String input) throws Exception {
- runAndCheckVerification(
- CompilerUnderTest.R8, mode, base + APK, null, null, ImmutableList.of(base + input));
- }
}
diff --git a/src/test/java/com/android/tools/r8/internal/YouTubeDeployJarVerificationTest.java b/src/test/java/com/android/tools/r8/internal/YouTubeDeployJarVerificationTest.java
deleted file mode 100644
index f6b78f6..0000000
--- a/src/test/java/com/android/tools/r8/internal/YouTubeDeployJarVerificationTest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.internal;
-
-import com.android.tools.r8.CompilationMode;
-import com.android.tools.r8.R8RunArtTestsTest.CompilerUnderTest;
-import org.junit.Test;
-
-public class YouTubeDeployJarVerificationTest extends YouTubeCompilationTestBase {
-
- public YouTubeDeployJarVerificationTest() {
- super(12, 17);
- }
-
- @Test
- public void buildDebugFromDeployJar() throws Exception {
- runAndCheckVerification(
- CompilerUnderTest.R8, CompilationMode.DEBUG, base + APK, null, base + DEPLOY_JAR);
- }
-
- @Test
- public void buildReleaseFromDeployJar() throws Exception {
- runAndCheckVerification(
- CompilerUnderTest.R8, CompilationMode.RELEASE, base + APK, null, base + DEPLOY_JAR);
- }
-}
diff --git a/src/test/java/com/android/tools/r8/internal/YouTubeDexVerificationTest.java b/src/test/java/com/android/tools/r8/internal/YouTubeDexVerificationTest.java
deleted file mode 100644
index 32b7973..0000000
--- a/src/test/java/com/android/tools/r8/internal/YouTubeDexVerificationTest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.internal;
-
-import com.android.tools.r8.CompilationMode;
-import org.junit.Test;
-
-public class YouTubeDexVerificationTest extends YouTubeCompilationTestBase {
-
- public YouTubeDexVerificationTest() {
- super(12, 17);
- }
-
- @Test
- public void buildDebugFromDex() throws Exception {
- runR8AndCheckVerification(CompilationMode.DEBUG, APK);
- }
-
- @Test
- public void buildReleaseFromDex() throws Exception {
- runR8AndCheckVerification(CompilationMode.RELEASE, APK);
- }
-}
diff --git a/src/test/java/com/android/tools/r8/internal/YouTubeProguardJarVerificationTest.java b/src/test/java/com/android/tools/r8/internal/YouTubeProguardJarVerificationTest.java
deleted file mode 100644
index ffe4e14..0000000
--- a/src/test/java/com/android/tools/r8/internal/YouTubeProguardJarVerificationTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.internal;
-
-import com.android.tools.r8.CompilationMode;
-import com.android.tools.r8.R8RunArtTestsTest.CompilerUnderTest;
-import com.google.common.collect.ImmutableList;
-import org.junit.Test;
-
-public class YouTubeProguardJarVerificationTest extends YouTubeCompilationTestBase {
-
- public YouTubeProguardJarVerificationTest() {
- super(12, 17);
- }
-
- @Test
- public void buildDebugFromProguardJar() throws Exception {
- runAndCheckVerification(
- CompilerUnderTest.R8,
- CompilationMode.DEBUG,
- base + APK,
- null,
- options -> options.testing.disableStackMapVerification = true,
- ImmutableList.of(base + PG_JAR));
- }
-
- @Test
- public void buildReleaseFromProguardJar() throws Exception {
- runAndCheckVerification(
- CompilerUnderTest.R8,
- CompilationMode.RELEASE,
- base + APK,
- null,
- options -> options.testing.disableStackMapVerification = true,
- ImmutableList.of(base + PG_JAR));
- }
-}
diff --git a/src/test/java/com/android/tools/r8/internal/YouTubeV1217TreeShakeJarVerificationTest.java b/src/test/java/com/android/tools/r8/internal/YouTubeV1217TreeShakeJarVerificationTest.java
deleted file mode 100644
index 5f39a31..0000000
--- a/src/test/java/com/android/tools/r8/internal/YouTubeV1217TreeShakeJarVerificationTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.internal;
-
-import static org.junit.Assert.assertTrue;
-
-import com.android.tools.r8.CompilationMode;
-import com.android.tools.r8.R8RunArtTestsTest.CompilerUnderTest;
-import com.android.tools.r8.StringConsumer.FileConsumer;
-import com.android.tools.r8.utils.AndroidApp;
-import com.google.common.collect.ImmutableList;
-import java.io.File;
-import java.nio.file.Path;
-import org.junit.Test;
-
-public class YouTubeV1217TreeShakeJarVerificationTest extends YouTubeCompilationTestBase {
-
- public YouTubeV1217TreeShakeJarVerificationTest() {
- super(12, 17);
- }
-
- @Test
- public void buildAndTreeShakeFromDeployJar() throws Exception {
- Path proguardMapPath = File.createTempFile("mapping", ".txt", temp.getRoot()).toPath();
- int maxSize = 20000000;
- AndroidApp app =
- runAndCheckVerification(
- CompilerUnderTest.R8,
- CompilationMode.RELEASE,
- base + APK,
- ImmutableList.of(base + PG_CONF),
- options -> options.proguardMapConsumer = new FileConsumer(proguardMapPath),
- // Don't pass any inputs. The input will be read from the -injars in the Proguard
- // configuration file.
- ImmutableList.of());
- int bytes = app.applicationSize();
- assertTrue("Expected max size of " + maxSize + ", got " + bytes, bytes < maxSize);
- }
-}
diff --git a/src/test/java/com/android/tools/r8/internal/YouTubeV1419TreeShakeJarVerificationTest.java b/src/test/java/com/android/tools/r8/internal/YouTubeV1419TreeShakeJarVerificationTest.java
deleted file mode 100644
index 42fc8f7..0000000
--- a/src/test/java/com/android/tools/r8/internal/YouTubeV1419TreeShakeJarVerificationTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.internal;
-
-import static com.android.tools.r8.ToolHelper.isLocalDevelopment;
-import static com.android.tools.r8.ToolHelper.shouldRunSlowTests;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
-
-import com.android.tools.r8.R8TestCompileResult;
-import com.android.tools.r8.TestParameters;
-import com.android.tools.r8.TestParametersCollection;
-import com.android.tools.r8.ToolHelper;
-import com.android.tools.r8.graph.DexItemFactory;
-import com.android.tools.r8.utils.AndroidApiLevel;
-import com.android.tools.r8.utils.codeinspector.CodeInspector;
-import com.android.tools.r8.utils.codeinspector.analysis.ProtoApplicationStats;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class YouTubeV1419TreeShakeJarVerificationTest extends YouTubeCompilationTestBase {
-
- private static final int MAX_SIZE = 27500000;
-
- @Parameters(name = "{0}")
- public static TestParametersCollection data() {
- return getTestParameters().withNoneRuntime().build();
- }
-
- public YouTubeV1419TreeShakeJarVerificationTest(TestParameters parameters) {
- super(14, 19);
- parameters.assertNoneRuntime();
- }
-
- @Test
- public void testR8() throws Exception {
- // TODO(b/141603168): Enable this on the bots.
- assumeTrue(isLocalDevelopment());
- assumeTrue(shouldRunSlowTests());
-
- LibrarySanitizer librarySanitizer =
- new LibrarySanitizer(temp).addProguardConfigurationFiles(getKeepRuleFiles()).sanitize();
-
- R8TestCompileResult compileResult =
- testForR8(Backend.DEX)
- .addKeepRuleFiles(librarySanitizer.getSanitizedProguardConfiguration())
- .addLibraryFiles(librarySanitizer.getSanitizedLibrary())
- .addMainDexRuleFiles(getMainDexRuleFiles())
- .allowDiagnosticMessages()
- .allowUnusedProguardConfigurationRules()
- .setMinApi(AndroidApiLevel.H_MR2)
- .compile()
- .assertAllInfoMessagesMatch(
- containsString("Proguard configuration rule does not match anything"))
- .assertAllWarningMessagesMatch(containsString("Ignoring option:"));
-
- if (ToolHelper.isLocalDevelopment()) {
- DexItemFactory dexItemFactory = new DexItemFactory();
- ProtoApplicationStats original =
- new ProtoApplicationStats(dexItemFactory, new CodeInspector(getProgramFiles()));
- ProtoApplicationStats actual =
- new ProtoApplicationStats(dexItemFactory, compileResult.inspector(), original);
- ProtoApplicationStats baseline =
- new ProtoApplicationStats(
- dexItemFactory, new CodeInspector(getReleaseApk(), getReleaseProguardMap()));
- System.out.println(actual.getStats(baseline));
- }
-
- int applicationSize = compileResult.app.applicationSize();
- System.out.println(applicationSize);
-
- assertTrue(
- "Expected max size of " + MAX_SIZE + ", got " + applicationSize,
- applicationSize < MAX_SIZE);
- }
-}
diff --git a/src/test/java/com/android/tools/r8/internal/YouTubeV1444TreeShakeJarVerificationTest.java b/src/test/java/com/android/tools/r8/internal/YouTubeV1444TreeShakeJarVerificationTest.java
deleted file mode 100644
index a998521..0000000
--- a/src/test/java/com/android/tools/r8/internal/YouTubeV1444TreeShakeJarVerificationTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.internal;
-
-import static com.android.tools.r8.ToolHelper.isLocalDevelopment;
-import static com.android.tools.r8.ToolHelper.shouldRunSlowTests;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
-
-import com.android.tools.r8.R8TestCompileResult;
-import com.android.tools.r8.TestParameters;
-import com.android.tools.r8.TestParametersCollection;
-import com.android.tools.r8.ToolHelper;
-import com.android.tools.r8.graph.DexItemFactory;
-import com.android.tools.r8.utils.AndroidApiLevel;
-import com.android.tools.r8.utils.codeinspector.CodeInspector;
-import com.android.tools.r8.utils.codeinspector.analysis.ProtoApplicationStats;
-import java.nio.file.Paths;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class YouTubeV1444TreeShakeJarVerificationTest extends YouTubeCompilationTestBase {
-
- private static final boolean DUMP = false;
- private static final int MAX_SIZE = 27500000;
-
- @Parameters(name = "{0}")
- public static TestParametersCollection data() {
- return getTestParameters().withNoneRuntime().build();
- }
-
- public YouTubeV1444TreeShakeJarVerificationTest(TestParameters parameters) {
- super(14, 44);
- parameters.assertNoneRuntime();
- }
-
- @Test
- public void testR8() throws Exception {
- // TODO(b/141603168): Enable this on the bots.
- assumeTrue(isLocalDevelopment());
- assumeTrue(shouldRunSlowTests());
-
- LibrarySanitizer librarySanitizer =
- new LibrarySanitizer(temp)
- .addProgramFiles(getProgramFiles())
- .addLibraryFiles(getLibraryFiles())
- .sanitize()
- .assertSanitizedProguardConfigurationIsEmpty();
-
- R8TestCompileResult compileResult =
- testForR8(Backend.DEX)
- .addProgramFiles(getProgramFiles())
- .addLibraryFiles(librarySanitizer.getSanitizedLibrary())
- .addKeepRuleFiles(getKeepRuleFiles())
- .addMainDexRuleFiles(getMainDexRuleFiles())
- .setMinApi(AndroidApiLevel.H_MR2)
- .allowDiagnosticMessages()
- .allowUnusedProguardConfigurationRules()
- .compile();
-
- if (ToolHelper.isLocalDevelopment()) {
- if (DUMP) {
- long time = System.currentTimeMillis();
- compileResult.writeToZip(Paths.get("YouTubeV1444-" + time + ".zip"));
- compileResult.writeProguardMap(Paths.get("YouTubeV1444-" + time + ".map"));
- }
-
- DexItemFactory dexItemFactory = new DexItemFactory();
- ProtoApplicationStats original =
- new ProtoApplicationStats(dexItemFactory, new CodeInspector(getProgramFiles()));
- ProtoApplicationStats actual =
- new ProtoApplicationStats(dexItemFactory, compileResult.inspector(), original);
- ProtoApplicationStats baseline =
- new ProtoApplicationStats(
- dexItemFactory, new CodeInspector(getReleaseApk(), getReleaseProguardMap()));
- System.out.println(actual.getStats(baseline));
- }
-
- int applicationSize = compileResult.app.applicationSize();
- System.out.println(applicationSize);
-
- assertTrue(
- "Expected max size of " + MAX_SIZE + ", got " + applicationSize,
- applicationSize < MAX_SIZE);
- }
-}
diff --git a/src/test/java/com/android/tools/r8/internal/YouTubeV1508TreeShakeJarVerificationTest.java b/src/test/java/com/android/tools/r8/internal/YouTubeV1508TreeShakeJarVerificationTest.java
deleted file mode 100644
index eccb336d..0000000
--- a/src/test/java/com/android/tools/r8/internal/YouTubeV1508TreeShakeJarVerificationTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright (c) 2020, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.internal;
-
-import static com.android.tools.r8.ToolHelper.isLocalDevelopment;
-import static com.android.tools.r8.ToolHelper.shouldRunSlowTests;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
-
-import com.android.tools.r8.R8TestCompileResult;
-import com.android.tools.r8.TestParameters;
-import com.android.tools.r8.TestParametersCollection;
-import com.android.tools.r8.ToolHelper;
-import com.android.tools.r8.graph.DexItemFactory;
-import com.android.tools.r8.utils.AndroidApiLevel;
-import com.android.tools.r8.utils.codeinspector.CodeInspector;
-import com.android.tools.r8.utils.codeinspector.analysis.ProtoApplicationStats;
-import java.nio.file.Paths;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class YouTubeV1508TreeShakeJarVerificationTest extends YouTubeCompilationTestBase {
-
- private static final boolean DUMP = false;
- private static final int MAX_SIZE = 27500000;
-
- @Parameters(name = "{0}")
- public static TestParametersCollection data() {
- return getTestParameters().withNoneRuntime().build();
- }
-
- public YouTubeV1508TreeShakeJarVerificationTest(TestParameters parameters) {
- super(15, 8);
- parameters.assertNoneRuntime();
- }
-
- @Test
- public void testR8() throws Exception {
- // TODO(b/141603168): Enable this on the bots.
- assumeTrue(isLocalDevelopment());
- assumeTrue(shouldRunSlowTests());
-
- LibrarySanitizer librarySanitizer =
- new LibrarySanitizer(temp)
- .addProgramFiles(getProgramFiles())
- .addLibraryFiles(getLibraryFiles())
- .sanitize()
- .assertSanitizedProguardConfigurationIsEmpty();
-
- R8TestCompileResult compileResult =
- testForR8(Backend.DEX)
- .addProgramFiles(getProgramFiles())
- .addLibraryFiles(librarySanitizer.getSanitizedLibrary())
- .addKeepRuleFiles(getKeepRuleFiles())
- .addMainDexRuleFiles(getMainDexRuleFiles())
- .allowDiagnosticMessages()
- .allowUnusedProguardConfigurationRules()
- .setMinApi(AndroidApiLevel.H_MR2)
- .compile();
-
- if (ToolHelper.isLocalDevelopment()) {
- if (DUMP) {
- long time = System.currentTimeMillis();
- compileResult.writeToZip(Paths.get("YouTubeV1508-" + time + ".zip"));
- compileResult.writeProguardMap(Paths.get("YouTubeV1508-" + time + ".map"));
- }
-
- DexItemFactory dexItemFactory = new DexItemFactory();
- ProtoApplicationStats original =
- new ProtoApplicationStats(dexItemFactory, new CodeInspector(getProgramFiles()));
- ProtoApplicationStats actual =
- new ProtoApplicationStats(dexItemFactory, compileResult.inspector(), original);
- ProtoApplicationStats baseline =
- new ProtoApplicationStats(
- dexItemFactory, new CodeInspector(getReleaseApk(), getReleaseProguardMap()));
- System.out.println(actual.getStats(baseline));
- }
-
- int applicationSize = compileResult.app.applicationSize();
- System.out.println(applicationSize);
-
- assertTrue(
- "Expected max size of " + MAX_SIZE + ", got " + applicationSize,
- applicationSize < MAX_SIZE);
- }
-}
diff --git a/third_party/youtube/youtube.android_12.10.tar.gz.sha1 b/third_party/youtube/youtube.android_12.10.tar.gz.sha1
deleted file mode 100644
index b158784..0000000
--- a/third_party/youtube/youtube.android_12.10.tar.gz.sha1
+++ /dev/null
@@ -1 +0,0 @@
-63e48370be53db00638fae52ffc9d4161df6c6ff
\ No newline at end of file
diff --git a/third_party/youtube/youtube.android_12.17.tar.gz.sha1 b/third_party/youtube/youtube.android_12.17.tar.gz.sha1
deleted file mode 100644
index d64239b..0000000
--- a/third_party/youtube/youtube.android_12.17.tar.gz.sha1
+++ /dev/null
@@ -1 +0,0 @@
-258a23ca677435c44d014a51c6d9737ebc8f2dcf
\ No newline at end of file
diff --git a/third_party/youtube/youtube.android_12.22.tar.gz.sha1 b/third_party/youtube/youtube.android_12.22.tar.gz.sha1
deleted file mode 100644
index 8f6813c..0000000
--- a/third_party/youtube/youtube.android_12.22.tar.gz.sha1
+++ /dev/null
@@ -1 +0,0 @@
-73c4880898d734064815d0426d8fe84ee6d075b4
\ No newline at end of file
diff --git a/third_party/youtube/youtube.android_13.37.tar.gz.sha1 b/third_party/youtube/youtube.android_13.37.tar.gz.sha1
deleted file mode 100644
index ffc92a8..0000000
--- a/third_party/youtube/youtube.android_13.37.tar.gz.sha1
+++ /dev/null
@@ -1 +0,0 @@
-533819c8e988bfbcdd7bc3dbd17e0d374c4ba9ab
\ No newline at end of file
diff --git a/third_party/youtube/youtube.android_14.19.tar.gz.sha1 b/third_party/youtube/youtube.android_14.19.tar.gz.sha1
deleted file mode 100644
index eee098b..0000000
--- a/third_party/youtube/youtube.android_14.19.tar.gz.sha1
+++ /dev/null
@@ -1 +0,0 @@
-32d92330cfa672f687f80969bb6eeb5af5b9bd01
\ No newline at end of file
diff --git a/third_party/youtube/youtube.android_14.44.tar.gz.sha1 b/third_party/youtube/youtube.android_14.44.tar.gz.sha1
deleted file mode 100644
index bdf9586..0000000
--- a/third_party/youtube/youtube.android_14.44.tar.gz.sha1
+++ /dev/null
@@ -1 +0,0 @@
-368f0029be6a0a2629ba8f05ea6954a3a859115e
\ No newline at end of file
diff --git a/third_party/youtube/youtube.android_15.08.tar.gz.sha1 b/third_party/youtube/youtube.android_15.08.tar.gz.sha1
deleted file mode 100644
index 357adeb..0000000
--- a/third_party/youtube/youtube.android_15.08.tar.gz.sha1
+++ /dev/null
@@ -1 +0,0 @@
-dc8d9b8f89d9284336897fa4cb2a925ff9e07c67
\ No newline at end of file
diff --git a/third_party/youtube/youtube.android_15.09.tar.gz.sha1 b/third_party/youtube/youtube.android_15.09.tar.gz.sha1
deleted file mode 100644
index b5c44a1..0000000
--- a/third_party/youtube/youtube.android_15.09.tar.gz.sha1
+++ /dev/null
@@ -1 +0,0 @@
-6acec0dc032536d90798060badaed13154c92685
\ No newline at end of file
diff --git a/tools/compiledump.py b/tools/compiledump.py
index 15b4f85..b508c6f 100755
--- a/tools/compiledump.py
+++ b/tools/compiledump.py
@@ -342,20 +342,41 @@
print(subprocess.check_output(cmd, stderr=subprocess.STDOUT))
return 0
except subprocess.CalledProcessError as e:
- if not args.nolib and version != 'source':
- stacktrace = os.path.join(temp, 'stacktrace')
- open(stacktrace, 'w+').write(e.output.decode('UTF-8'))
- local_map = utils.R8LIB_MAP if version == 'main' else None
- hash_or_version = None if version == 'main' else version
- print("=" * 80)
- print(" RETRACED OUTPUT")
- print("=" * 80)
- retrace.run(
- local_map, hash_or_version, stacktrace, is_hash(version), no_r8lib=False)
- else:
+ if args.nolib \
+ or version == 'source' \
+ or not try_retrace_output(e, version, temp):
print(e.output.decode('UTF-8'))
return 1
+def try_retrace_output(e, version, temp):
+ try:
+ stacktrace = os.path.join(temp, 'stacktrace')
+ open(stacktrace, 'w+').write(e.output.decode('UTF-8'))
+ print("=" * 80)
+ print(" RETRACED OUTPUT")
+ print("=" * 80)
+ retrace.run(get_map_file(version, temp), stacktrace, no_r8lib=False)
+ return True
+ except Exception as e2:
+ print("Failed to retrace for version: %s" % version)
+ print(e2)
+ return False
+
+def get_map_file(version, temp):
+ if version == 'main':
+ return utils.R8LIB_MAP
+ download_path = archive.GetUploadDestination(
+ version,
+ 'r8lib.jar.map',
+ is_hash(version))
+ if utils.file_exists_on_cloud_storage(download_path):
+ map_path = os.path.join(temp, 'mapping.map')
+ utils.download_file_from_cloud_storage(download_path, map_path)
+ return map_path
+ else:
+ print('Could not find map file from argument: %s.' % version)
+ return None
+
def run(args, otherargs):
if (args.loop):
count = 1
diff --git a/tools/internal_test.py b/tools/internal_test.py
index e267763..2571efc 100755
--- a/tools/internal_test.py
+++ b/tools/internal_test.py
@@ -38,6 +38,8 @@
import utils
import run_on_app
+import youtube_data
+
# How often the bot/tester should check state
PULL_DELAY = 30
TEST_RESULT_DIR = 'internal'
@@ -74,11 +76,11 @@
},
{
'app': 'youtube',
- 'version': '12.22',
- 'find-xmx-min': 750,
- 'find-xmx-max': 1150,
- 'find-xmx-range': 32,
- 'oom-threshold': 950,
+ 'version': youtube_data.LATEST_VERSION,
+ 'find-xmx-min': 2800,
+ 'find-xmx-max': 3200,
+ 'find-xmx-range': 64,
+ 'oom-threshold': 3000,
# TODO(b/143431825): Youtube can OOM randomly in memory configurations
# that should work.
'skip-find-xmx-max': True,
diff --git a/tools/retrace.py b/tools/retrace.py
index ea06566..c087b31 100755
--- a/tools/retrace.py
+++ b/tools/retrace.py
@@ -3,14 +3,14 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
-import archive
import argparse
import jdk
import subprocess
import sys
-import tempfile
+
import utils
+
def parse_arguments():
parser = argparse.ArgumentParser(
description = 'R8lib wrapper for retrace tool.')
@@ -60,12 +60,11 @@
return run(
map_path,
args.stacktrace,
- args.commit_hash is not None,
args.no_r8lib,
quiet=args.quiet,
debug=args.debug_agent)
-def run(map_path, stacktrace, is_hash, no_r8lib, quiet=False, debug=False):
+def run(map_path, stacktrace, no_r8lib, quiet=False, debug=False):
retrace_args = [jdk.GetJavaExecutable()]
if debug:
diff --git a/tools/run_on_app.py b/tools/run_on_app.py
index 60cd4f1..c775aa0 100755
--- a/tools/run_on_app.py
+++ b/tools/run_on_app.py
@@ -396,7 +396,7 @@
version = options.version or '20180926'
data = nest_data
elif options.app == 'youtube':
- version = options.version or '12.22'
+ version = options.version or youtube_data.LATEST_VERSION
data = youtube_data
elif options.app == 'chrome':
version = options.version or '180917'
diff --git a/tools/run_proguard_dx_on_app.py b/tools/run_proguard_dx_on_app.py
deleted file mode 100755
index bb1d72a..0000000
--- a/tools/run_proguard_dx_on_app.py
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-
-# Run ProGuard and the DX (= D8) tool on GmsCore V10.
-
-from __future__ import print_function
-from glob import glob
-from os import makedirs
-from os.path import exists, join, splitext
-from subprocess import check_call
-import argparse
-import fnmatch
-import gmscore_data
-import jdk
-import os
-import stat
-import sys
-import time
-
-import gmail_data
-import gmscore_data
-import golem
-import proguard
-import utils
-import youtube_data
-
-APPS = ['gmscore', 'youtube']
-DX_JAR = join(utils.REPO_ROOT, 'tools', 'linux', 'dx', 'framework', 'dx.jar')
-
-def parse_arguments(argv):
- parser = argparse.ArgumentParser(
- description = 'Run ProGuard and the DX tool on GmsCore V10.')
- parser.add_argument('--app', required = True, choices = APPS)
- parser.add_argument('--out',
- help = 'Output directory for the DX tool.',
- default = os.getcwd())
- parser.add_argument('--golem',
- help = 'Link in third party dependencies.',
- default = False,
- action = 'store_true')
- parser.add_argument('--print-runtimeraw',
- metavar = 'BENCHMARKNAME',
- help = 'Print the line \'<BENCHMARKNAME>(RunTimeRaw): <elapsed>' +
- ' ms\' at the end where <elapsed> is the elapsed time in' +
- ' milliseconds.')
- parser.add_argument('--print-memoryuse',
- metavar='BENCHMARKNAME',
- help='Print the line \'<BENCHMARKNAME>(MemoryUse):' +
- ' <mem>\' at the end where <mem> is the peak' +
- ' peak resident set size (VmHWM) in bytes.')
- parser.add_argument('--print-dexsegments',
- metavar = 'BENCHMARKNAME',
- help = 'Print the sizes of individual dex segments as ' +
- '\'<BENCHMARKNAME>-<segment>(CodeSize): <bytes>\'')
- return parser.parse_args(argv)
-
-def Main(argv):
- options = parse_arguments(argv)
- if options.golem:
- golem.link_third_party()
- utils.check_java_version()
- outdir = options.out
-
- if options.app == 'gmscore':
- version = 'v10'
- data = gmscore_data
- base = data.V10_BASE
- elif options.app == 'youtube':
- version = '12.22'
- data = youtube_data
- base = data.V12_22_BASE
- else:
- raise Exception('Unexpected')
-
-
- args = ['-forceprocessing']
-
- if not outdir.endswith('.zip') and not outdir.endswith('.jar') \
- and not exists(outdir):
- makedirs(outdir)
-
-
- values_deploy = data.VERSIONS[version]['deploy']
- values_proguarded = data.VERSIONS[version]['proguarded']
- assert 'pgconf' in values_deploy
-
- for pgconf in values_deploy['pgconf']:
- args.extend(['@' + pgconf])
-
- # find seeds file
- inputs = data.VERSIONS[version]['proguarded']['inputs']
- assert len(inputs) == 1
- basename_wo_ext = splitext(os.path.basename(inputs[0]))[0]
- seeds_filename = basename_wo_ext + '.seeds'
-
- seeds_files = []
- for root, dirnames, filenames in os.walk(join(base, 'blaze-out')):
- for filename in fnmatch.filter(filenames, seeds_filename):
- seeds_files.append(os.path.join(root, filename))
- assert len(seeds_files) == 1
-
- seeds_path = seeds_files[0]
- proguarded_jar_path = splitext(seeds_path)[0] + '.jar'
-
- # Remove write-protection from seeds file. The seeds file is an output of
- # ProGuard so it aborts if this is not writeable.
- st = os.stat(seeds_path)
- os.chmod(seeds_path,
- st.st_mode | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH)
-
- t0 = time.time()
-
- proguard_memoryuse = None
-
- with utils.TempDir() as temp:
- track_memory_file = None
- if options.print_memoryuse:
- track_memory_file = join(temp, utils.MEMORY_USE_TMP_FILE)
- proguard.run(
- args,
- version='pg_internal',
- track_memory_file = track_memory_file,
- stdout=open(os.devnull, 'w'))
- if options.print_memoryuse:
- proguard_memoryuse = utils.grep_memoryuse(track_memory_file)
-
- # run dex on the result
- jar = DX_JAR
-
- with utils.TempDir() as temp:
- track_memory_file = None
- cmd = []
- if options.print_memoryuse:
- track_memory_file = join(temp, utils.MEMORY_USE_TMP_FILE)
- cmd.extend(['tools/track_memory.sh', track_memory_file])
- cmd.extend([jdk.GetJavaExecutable(), '-jar', jar, '--multi-dex',
- '--output=' + outdir])
- if 'min-api' in values_proguarded:
- cmd.append('--min-sdk-version=' + values_proguarded['min-api'])
- cmd.extend(['--dex', proguarded_jar_path])
- utils.PrintCmd(cmd);
- check_call(cmd)
- if options.print_memoryuse:
- dx_memoryuse = utils.grep_memoryuse(track_memory_file)
- print('{}(MemoryUse): {}'
- .format(options.print_memoryuse,
- max(proguard_memoryuse, dx_memoryuse)))
-
- if options.print_runtimeraw:
- print('{}(RunTimeRaw): {} ms'
- .format(options.print_runtimeraw, 1000.0 * (time.time() - t0)))
-
- if options.print_dexsegments:
- dex_files = glob(os.path.join(outdir, '*.dex'))
- utils.print_dexsegments(options.print_dexsegments, dex_files)
-
-if __name__ == '__main__':
- sys.exit(Main(sys.argv[1:]))
diff --git a/tools/run_proguard_dx_on_gmscore.py b/tools/run_proguard_dx_on_gmscore.py
deleted file mode 100755
index 5a6e42a..0000000
--- a/tools/run_proguard_dx_on_gmscore.py
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-
-# Run ProGuard and the DX or CompatDX (= D8) tool on GmsCore V10.
-
-import sys
-
-import run_proguard_dx_on_app
-
-if __name__ == '__main__':
- sys.exit(run_proguard_dx_on_app.Main(sys.argv[1:] + ['--app', 'gmscore']))
diff --git a/tools/test.py b/tools/test.py
index 6734106..6f3fe83 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -167,6 +167,9 @@
help='Use alternative desugared library configuration.')
result.add_option('--desugared-library', '--desugared_library',
help='Build and use desugared library from GitHub.')
+ result.add_option('--print-times', '--print_times',
+ help='Print the execution time of the slowest tests..',
+ default=False, action='store_true')
return result.parse_args()
def archive_failures():
@@ -383,6 +386,8 @@
# Legacy testing populates the runtimes based on dex_vm.
vms_to_test = [options.dex_vm] if options.dex_vm != "all" else ALL_ART_VMS
+ if options.print_times:
+ gradle_args.append('-Pprint_times=true')
for art_vm in vms_to_test:
vm_suffix = "_" + options.dex_vm_kind if art_vm != "default" else ""
runtimes = ['dex-' + art_vm]
diff --git a/tools/youtube_data.py b/tools/youtube_data.py
index 04d9e1f..d12cfb6 100644
--- a/tools/youtube_data.py
+++ b/tools/youtube_data.py
@@ -2,7 +2,6 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
-import glob
import os
import utils
@@ -10,256 +9,20 @@
ANDROID_L_API = '21'
BASE = os.path.join(utils.THIRD_PARTY, 'youtube')
-V12_10_BASE = os.path.join(BASE, 'youtube.android_12.10')
-V12_10_PREFIX = os.path.join(V12_10_BASE, 'YouTubeRelease')
-
-V12_17_BASE = os.path.join(BASE, 'youtube.android_12.17')
-V12_17_PREFIX = os.path.join(V12_17_BASE, 'YouTubeRelease')
-
-V12_22_BASE = os.path.join(BASE, 'youtube.android_12.22')
-V12_22_PREFIX = os.path.join(V12_22_BASE, 'YouTubeRelease')
-
-V13_37_BASE = os.path.join(BASE, 'youtube.android_13.37')
-V13_37_PREFIX = os.path.join(V13_37_BASE, 'YouTubeRelease')
-
-V14_19_BASE = os.path.join(BASE, 'youtube.android_14.19')
-V14_19_PREFIX = os.path.join(V14_19_BASE, 'YouTubeRelease')
-
-V14_44_BASE = os.path.join(BASE, 'youtube.android_14.44')
-V14_44_PREFIX = os.path.join(V14_44_BASE, 'YouTubeRelease')
-
-V15_08_BASE = os.path.join(BASE, 'youtube.android_15.08')
-V15_08_PREFIX = os.path.join(V15_08_BASE, 'YouTubeRelease')
-
-V15_09_BASE = os.path.join(BASE, 'youtube.android_15.09')
-V15_09_PREFIX = os.path.join(V15_09_BASE, 'YouTubeRelease')
-
V15_33_BASE = os.path.join(BASE, 'youtube.android_15.33')
V15_33_PREFIX = os.path.join(V15_33_BASE, 'YouTubeRelease')
V16_12_BASE = os.path.join(BASE, 'youtube.android_16.12')
V16_12_PREFIX = os.path.join(V16_12_BASE, 'YouTubeRelease')
-# NOTE: we always use android.jar for SDK v25, later we might want to revise it
-# to use proper android.jar version for each of youtube version separately.
-ANDROID_JAR = utils.get_android_jar(25)
+LATEST_VERSION = '16.12'
VERSIONS = {
- '12.10': {
- 'dex' : {
- 'inputs': [os.path.join(V12_10_BASE, 'YouTubeRelease_unsigned.apk')],
- 'pgmap': '%s_proguard.map' % V12_10_PREFIX,
- 'libraries' : [ANDROID_JAR],
- 'min-api' : ANDROID_L_API,
- },
- 'deploy' : {
- 'inputs': ['%s_deploy.jar' % V12_10_PREFIX],
- 'pgconf': ['%s_proguard.config' % V12_10_PREFIX,
- '%s/proguardsettings/YouTubeRelease_proguard.config' % utils.THIRD_PARTY,
- utils.IGNORE_WARNINGS_RULES],
- 'min-api' : ANDROID_L_API,
- }
- # The 'proguarded' version cannot be handled by D8/R8 because there are
- # parameter annotations for parameters that do not exist, which is not
- # handled gracefully by ASM (see b/116089492).
- #'proguarded' : {
- # 'inputs': ['%s_proguard.jar' % V12_10_PREFIX],
- # 'pgmap': '%s_proguard.map' % V12_10_PREFIX,
- # 'min-api' : ANDROID_L_API,
- #}
- },
- '12.17': {
- 'dex' : {
- 'inputs': [os.path.join(V12_17_BASE, 'YouTubeRelease_unsigned.apk')],
- 'pgmap': '%s_proguard.map' % V12_17_PREFIX,
- 'libraries' : [ANDROID_JAR],
- 'min-api' : ANDROID_L_API,
- },
- 'deploy' : {
- 'inputs': ['%s_deploy.jar' % V12_17_PREFIX],
- 'pgconf': ['%s_proguard.config' % V12_17_PREFIX,
- '%s/proguardsettings/YouTubeRelease_proguard.config' % utils.THIRD_PARTY,
- utils.IGNORE_WARNINGS_RULES],
- 'min-api' : ANDROID_L_API,
- },
- 'proguarded' : {
- 'inputs': ['%s_proguard.jar' % V12_17_PREFIX],
- 'pgmap': '%s_proguard.map' % V12_17_PREFIX,
- 'min-api' : ANDROID_L_API,
- }
- },
- '12.22': {
- 'dex' : {
- 'inputs': [os.path.join(V12_22_BASE, 'YouTubeRelease_unsigned.apk')],
- 'pgmap': '%s_proguard.map' % V12_22_PREFIX,
- 'libraries' : [ANDROID_JAR],
- 'min-api' : ANDROID_L_API,
- },
- 'deploy' : {
- 'inputs': ['%s_deploy.jar' % V12_22_PREFIX],
- 'pgconf': [
- '%s_proguard.config' % V12_22_PREFIX,
- '%s/proguardsettings/YouTubeRelease_proguard.config' % utils.THIRD_PARTY,
- utils.IGNORE_WARNINGS_RULES],
- 'maindexrules' : [
- os.path.join(V12_22_BASE, 'mainDexClasses.rules'),
- os.path.join(V12_22_BASE, 'main-dex-classes-release.cfg'),
- os.path.join(V12_22_BASE, 'main_dex_YouTubeRelease_proguard.cfg')],
- },
- 'proguarded' : {
- 'inputs': ['%s_proguard.jar' % V12_22_PREFIX],
- 'pgmap': '%s_proguard.map' % V12_22_PREFIX,
- 'min-api' : ANDROID_L_API,
- }
- },
- '13.37': {
- 'dex' : {
- 'inputs': [os.path.join(V13_37_BASE, 'YouTubeRelease_unsigned.apk')],
- 'pgmap': '%s_proguard.map' % V13_37_PREFIX,
- 'libraries' : [ANDROID_JAR],
- 'min-api' : ANDROID_L_API,
- },
- 'deploy' : {
- 'inputs': ['%s_deploy.jar' % V13_37_PREFIX],
- 'pgconf': [
- '%s_proguard.config' % V13_37_PREFIX,
- '%s/proguardsettings/YouTubeRelease_proguard.config' % utils.THIRD_PARTY,
- utils.IGNORE_WARNINGS_RULES],
- # Build for native multi dex, as Currently R8 cannot meet the main-dex
- # constraints.
- #'maindexrules' : [
- # os.path.join(V13_37_BASE, 'mainDexClasses.rules'),
- # os.path.join(V13_37_BASE, 'main-dex-classes-release-optimized.cfg'),
- # os.path.join(V13_37_BASE, 'main_dex_YouTubeRelease_proguard.cfg')],
- 'min-api' : ANDROID_L_API,
- },
- 'proguarded' : {
- 'inputs': ['%s_proguard.jar' % V13_37_PREFIX],
- 'pgmap': '%s_proguard.map' % V13_37_PREFIX,
- 'min-api' : ANDROID_L_API,
- }
- },
- '14.19': {
- 'dex' : {
- 'inputs': [os.path.join(V14_19_BASE, 'YouTubeRelease_unsigned.apk')],
- 'pgmap': '%s_proguard.map' % V14_19_PREFIX,
- 'libraries' : [ANDROID_JAR],
- 'min-api' : ANDROID_L_API,
- },
- 'deploy' : {
- 'inputs': ['%s_deploy.jar' % V14_19_PREFIX],
- 'pgconf': [
- '%s_proguard.config' % V14_19_PREFIX,
- '%s/proguardsettings/YouTubeRelease_proguard.config' % utils.THIRD_PARTY,
- utils.IGNORE_WARNINGS_RULES],
- 'maindexrules' : [
- os.path.join(V14_19_BASE, 'mainDexClasses.rules'),
- os.path.join(V14_19_BASE, 'main-dex-classes-release-optimized.pgcfg'),
- os.path.join(V14_19_BASE, 'main_dex_YouTubeRelease_proguard.cfg')],
- 'min-api' : ANDROID_H_MR2_API,
- },
- 'proguarded' : {
- 'inputs': ['%s_proguard.jar' % V14_19_PREFIX],
- 'pgmap': '%s_proguard.map' % V14_19_PREFIX,
- 'min-api' : ANDROID_L_API,
- }
- },
- '14.44': {
- 'dex' : {
- 'inputs': [os.path.join(V14_44_BASE, 'YouTubeRelease_unsigned.apk')],
- 'pgmap': '%s_proguard.map' % V14_44_PREFIX,
- 'libraries' : [ANDROID_JAR],
- 'min-api' : ANDROID_L_API,
- },
- 'deploy' : {
- # When -injars and -libraryjars are used for specifying inputs library
- # sanitization is on by default. For this version of YouTube -injars and
- # -libraryjars are not used, but library sanitization is still required.
- 'sanitize_libraries': True,
- 'inputs': ['%s_deploy.jar' % V14_44_PREFIX],
- 'libraries' : [os.path.join(V14_44_BASE, 'legacy_YouTubeRelease_combined_library_jars.jar')],
- 'pgconf': [
- '%s_proguard.config' % V14_44_PREFIX,
- '%s/proguardsettings/YouTubeRelease_proguard.config' % utils.THIRD_PARTY,
- utils.IGNORE_WARNINGS_RULES],
- 'maindexrules' : [
- os.path.join(V14_44_BASE, 'mainDexClasses.rules'),
- os.path.join(V14_44_BASE, 'main-dex-classes-release-optimized.pgcfg'),
- os.path.join(V14_44_BASE, 'main_dex_YouTubeRelease_proguard.cfg')],
- 'min-api' : ANDROID_H_MR2_API,
- },
- 'proguarded' : {
- 'inputs': ['%s_proguard.jar' % V14_44_PREFIX],
- 'pgmap': '%s_proguard.map' % V14_44_PREFIX,
- 'min-api' : ANDROID_L_API,
- }
- },
- '15.08': {
- 'dex' : {
- 'inputs': [os.path.join(V15_08_BASE, 'YouTubeRelease_unsigned.apk')],
- 'pgmap': '%s_proguard.map' % V15_08_PREFIX,
- 'libraries' : [ANDROID_JAR],
- 'min-api' : ANDROID_L_API,
- },
- 'deploy' : {
- # When -injars and -libraryjars are used for specifying inputs library
- # sanitization is on by default. For this version of YouTube -injars and
- # -libraryjars are not used, but library sanitization is still required.
- 'sanitize_libraries': True,
- 'inputs': ['%s_deploy.jar' % V15_08_PREFIX],
- 'libraries' : [os.path.join(V15_08_BASE, 'legacy_YouTubeRelease_combined_library_jars.jar')],
- 'pgconf': [
- '%s_proguard.config' % V15_08_PREFIX,
- '%s_proto_safety.pgcfg' % V15_08_PREFIX,
- '%s/proguardsettings/YouTubeRelease_proguard.config' % utils.THIRD_PARTY,
- utils.IGNORE_WARNINGS_RULES],
- 'maindexrules' : [
- os.path.join(V15_08_BASE, 'mainDexClasses.rules'),
- os.path.join(V15_08_BASE, 'main-dex-classes-release-optimized.pgcfg'),
- os.path.join(V15_08_BASE, 'main_dex_YouTubeRelease_proguard.cfg')],
- 'min-api' : ANDROID_H_MR2_API,
- },
- 'proguarded' : {
- 'inputs': ['%s_proguard.jar' % V15_08_PREFIX],
- 'pgmap': '%s_proguard.map' % V15_08_PREFIX,
- 'min-api' : ANDROID_L_API,
- }
- },
- '15.09': {
- 'dex' : {
- 'inputs': [os.path.join(V15_09_BASE, 'YouTubeRelease_unsigned.apk')],
- 'pgmap': '%s_proguard.map' % V15_09_PREFIX,
- 'libraries' : [ANDROID_JAR],
- 'min-api' : ANDROID_L_API,
- },
- 'deploy' : {
- # When -injars and -libraryjars are used for specifying inputs library
- # sanitization is on by default. For this version of YouTube -injars and
- # -libraryjars are not used, but library sanitization is still required.
- 'sanitize_libraries': True,
- 'inputs': ['%s_deploy.jar' % V15_09_PREFIX],
- 'libraries' : [os.path.join(V15_09_BASE, 'legacy_YouTubeRelease_combined_library_jars.jar')],
- 'pgconf': [
- '%s_proguard.config' % V15_09_PREFIX,
- '%s/proguardsettings/YouTubeRelease_proguard.config' % utils.THIRD_PARTY,
- utils.IGNORE_WARNINGS_RULES],
- 'maindexrules' : [
- os.path.join(V15_09_BASE, 'mainDexClasses.rules'),
- os.path.join(V15_09_BASE, 'main-dex-classes-release-optimized.pgcfg'),
- os.path.join(V15_09_BASE, 'main_dex_YouTubeRelease_proguard.cfg')],
- 'min-api' : ANDROID_H_MR2_API,
- },
- 'proguarded' : {
- 'inputs': ['%s_proguard.jar' % V15_09_PREFIX],
- 'pgmap': '%s_proguard.map' % V15_09_PREFIX,
- 'min-api' : ANDROID_L_API,
- }
- },
'15.33': {
'dex' : {
'inputs': [os.path.join(V15_33_BASE, 'YouTubeRelease_unsigned.apk')],
'pgmap': '%s_proguard.map' % V15_33_PREFIX,
- 'libraries' : [ANDROID_JAR],
+ 'libraries' : [utils.get_android_jar(25)],
'min-api' : ANDROID_L_API,
},
'deploy' : {