Rewrite retrieval of resolved classes.

Use ClassLinker::VisitClasses() instead of walking over dex
cache type arrays. The old technique relies on the dex cache
holding references to all resolved classes, an assumption
that we're going to break soon.

Test: m test-art-host-run-test-595-profile-saving
Bug: 30627598
Change-Id: Icae71f53b5a33ff931d83aa8d44cc182889f26da
diff --git a/runtime/dex_cache_resolved_classes.h b/runtime/dex_cache_resolved_classes.h
index f53ca4a..bebdf0d 100644
--- a/runtime/dex_cache_resolved_classes.h
+++ b/runtime/dex_cache_resolved_classes.h
@@ -44,6 +44,10 @@
     return dex_location_.compare(other.dex_location_);
   }
 
+  bool AddClass(dex::TypeIndex index) const {
+    return classes_.insert(index).second;
+  }
+
   template <class InputIt>
   void AddClasses(InputIt begin, InputIt end) const {
     classes_.insert(begin, end);