Merge "Parallelize unused arguments collector"
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/UnusedArgumentsCollector.java b/src/main/java/com/android/tools/r8/ir/optimize/UnusedArgumentsCollector.java
index 47b9289..9d2bb32 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/UnusedArgumentsCollector.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/UnusedArgumentsCollector.java
@@ -36,6 +36,7 @@
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
+import java.util.stream.Collectors;
public class UnusedArgumentsCollector {
@@ -89,7 +90,9 @@
Streams.stream(appView.appInfo().classes())
.map(this::runnableForClass)
.map(executorService::submit)
- .iterator());
+ // Materialize list such that all runnables are submitted to the executor service
+ // before calling awaitFutures().
+ .collect(Collectors.toList()));
if (!methodMapping.isEmpty()) {
return new UnusedArgumentsGraphLense(
diff --git a/src/main/java/com/android/tools/r8/utils/ThreadUtils.java b/src/main/java/com/android/tools/r8/utils/ThreadUtils.java
index bde7016..fb4f409 100644
--- a/src/main/java/com/android/tools/r8/utils/ThreadUtils.java
+++ b/src/main/java/com/android/tools/r8/utils/ThreadUtils.java
@@ -15,11 +15,7 @@
public static void awaitFutures(Iterable<? extends Future<?>> futures)
throws ExecutionException {
- awaitFutures(futures.iterator());
- }
-
- public static void awaitFutures(Iterator<? extends Future<?>> futureIterator)
- throws ExecutionException {
+ Iterator<? extends Future<?>> futureIterator = futures.iterator();
try {
while (futureIterator.hasNext()) {
futureIterator.next().get();