Move explicit GC after we are done initalizing all classes.

Previously we had the GC happen for each dex file, this added a
few seconds of time on boot.oat creation.

Bug: 16853450

(cherry picked from commit 093ef212b7db4c17ed62df5cac0c1ac3a24e691d)

Change-Id: Ia469838eff1550c175c3465a478d8081023601bd
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index d14aea3..efc5bb7 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -1852,10 +1852,6 @@
     thread_count = thread_count_;
   }
   context.ForAll(0, dex_file.NumClassDefs(), InitializeClass, thread_count);
-  if (IsImage()) {
-    // Prune garbage objects created during aborted transactions.
-    Runtime::Current()->GetHeap()->CollectGarbage(true);
-  }
 }
 
 void CompilerDriver::InitializeClasses(jobject class_loader,
@@ -1866,6 +1862,10 @@
     CHECK(dex_file != NULL);
     InitializeClasses(class_loader, *dex_file, dex_files, thread_pool, timings);
   }
+  if (IsImage()) {
+    // Prune garbage objects created during aborted transactions.
+    Runtime::Current()->GetHeap()->CollectGarbage(true);
+  }
 }
 
 void CompilerDriver::Compile(jobject class_loader, const std::vector<const DexFile*>& dex_files,