Reduce and speed-up class def searches.

Use the class linker for descriptor lookups from the compile driver so that
dex caches are populated.
Reduce the scope of functions for scanning class paths to just the class
linker where they are performed.
If we see more than a threshold number of find class def misses on a dex file
lazily compute an index, so that future lookups are constant time (part of the
collection code is taken from
https://android-review.googlesource.com/#/c/103865/3). Note that we take a lazy
approach so that we don't serialize on loading dex files, this avoids the
reason the index was removed in 8b2c0b9abc3f520495f4387ea040132ba85cae69.
Remove an implicit and unnecessary std::string creation for PrintableString.

Single threaded interpret-only dex2oat performance is improved by roughly 10%.

Bug: 16853450

Change-Id: Icf72df76b0a4328f2a24075e81f4ff267b9401f4
diff --git a/runtime/utf.cc b/runtime/utf.cc
index e48d6d2..02cbe3b 100644
--- a/runtime/utf.cc
+++ b/runtime/utf.cc
@@ -85,6 +85,14 @@
   return hash;
 }
 
+int32_t ComputeUtf8Hash(const char* chars) {
+  int32_t hash = 0;
+  while (*chars != '\0') {
+    hash = hash * 31 + GetUtf16FromUtf8(&chars);
+  }
+  return hash;
+}
+
 int CompareModifiedUtf8ToUtf16AsCodePointValues(const char* utf8_1, const uint16_t* utf8_2) {
   for (;;) {
     if (*utf8_1 == '\0') {