Process Kotlin @Metadata for classes in parallel.
because parsing it; extracting necessary info; and marking such info
into members of the class don't bother each other.
Bug: 70169921, 148654451
Change-Id: I64db4fdbf02ccf0d376ae6d9487da8afef6190d4
diff --git a/src/main/java/com/android/tools/r8/R8.java b/src/main/java/com/android/tools/r8/R8.java
index 9bd2159..e351c92 100644
--- a/src/main/java/com/android/tools/r8/R8.java
+++ b/src/main/java/com/android/tools/r8/R8.java
@@ -308,7 +308,7 @@
// Compute kotlin info before setting the roots and before
// kotlin metadata annotation is removed.
- computeKotlinInfoForProgramClasses(application, appView);
+ computeKotlinInfoForProgramClasses(application, appView, executorService);
// Add synthesized -assumenosideeffects from min api if relevant.
if (options.isGeneratingDex()) {
@@ -886,17 +886,23 @@
throw new CompilationError("Discard checks failed.");
}
- private void computeKotlinInfoForProgramClasses(DexApplication application, AppView<?> appView) {
+ private void computeKotlinInfoForProgramClasses(
+ DexApplication application, AppView<?> appView, ExecutorService executorService)
+ throws ExecutionException{
if (appView.options().kotlinOptimizationOptions().disableKotlinSpecificOptimizations) {
return;
}
Kotlin kotlin = appView.dexItemFactory().kotlin;
Reporter reporter = options.reporter;
- for (DexProgramClass programClass : application.classes()) {
- KotlinInfo kotlinInfo = kotlin.getKotlinInfo(programClass, reporter);
- programClass.setKotlinInfo(kotlinInfo);
- KotlinMemberInfo.markKotlinMemberInfo(programClass, kotlinInfo, reporter);
- }
+ ThreadUtils.processItems(
+ application.classes(),
+ programClass -> {
+ KotlinInfo kotlinInfo = kotlin.getKotlinInfo(programClass, reporter);
+ programClass.setKotlinInfo(kotlinInfo);
+ KotlinMemberInfo.markKotlinMemberInfo(programClass, kotlinInfo, reporter);
+ },
+ executorService
+ );
}
private static boolean verifyNoJarApplicationReaders(List<DexProgramClass> classes) {