Change intern table to unordered set.

Intern table active used bytes goes from 430k to 317k on system
server. Similar %wise savings on other apps.

Bug: 16238192

(cherry picked from commit d910fcef539e12ab181e56ec80684f39c4e95733)

Change-Id: Ic70395124435c6f420a77e6d8639404a160f395a
diff --git a/runtime/mirror/string-inl.h b/runtime/mirror/string-inl.h
index f98407b..14d7de2 100644
--- a/runtime/mirror/string-inl.h
+++ b/runtime/mirror/string-inl.h
@@ -23,6 +23,7 @@
 #include "runtime.h"
 #include "string.h"
 #include "thread.h"
+#include "utf.h"
 
 namespace art {
 namespace mirror {
@@ -67,6 +68,16 @@
   return GetCharArray()->Get(index + GetOffset());
 }
 
+inline int32_t String::GetHashCode() {
+  int32_t result = GetField32(OFFSET_OF_OBJECT_MEMBER(String, hash_code_));
+  if (UNLIKELY(result == 0)) {
+    result = ComputeHashCode();
+  }
+  DCHECK(result != 0 || ComputeUtf16Hash(GetCharArray(), GetOffset(), GetLength()) == 0)
+      << ToModifiedUtf8() << " " << result;
+  return result;
+}
+
 }  // namespace mirror
 }  // namespace art
 
diff --git a/runtime/mirror/string.cc b/runtime/mirror/string.cc
index e81e431..01599ae 100644
--- a/runtime/mirror/string.cc
+++ b/runtime/mirror/string.cc
@@ -62,19 +62,10 @@
   java_lang_String_ = GcRoot<Class>(nullptr);
 }
 
-int32_t String::GetHashCode() {
-  int32_t result = GetField32(OFFSET_OF_OBJECT_MEMBER(String, hash_code_));
-  if (UNLIKELY(result == 0)) {
-    ComputeHashCode();
-  }
-  result = GetField32(OFFSET_OF_OBJECT_MEMBER(String, hash_code_));
-  DCHECK(result != 0 || ComputeUtf16Hash(GetCharArray(), GetOffset(), GetLength()) == 0)
-          << ToModifiedUtf8() << " " << result;
-  return result;
-}
-
-void String::ComputeHashCode() {
-  SetHashCode(ComputeUtf16Hash(GetCharArray(), GetOffset(), GetLength()));
+int32_t String::ComputeHashCode() {
+  const int32_t hash_code = ComputeUtf16Hash(GetCharArray(), GetOffset(), GetLength());
+  SetHashCode(hash_code);
+  return hash_code;
 }
 
 int32_t String::GetUtfLength() {
diff --git a/runtime/mirror/string.h b/runtime/mirror/string.h
index 66a5dd8..1320ab7 100644
--- a/runtime/mirror/string.h
+++ b/runtime/mirror/string.h
@@ -66,7 +66,8 @@
 
   int32_t GetHashCode() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
-  void ComputeHashCode() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+  // Computes, stores, and returns the hash code.
+  int32_t ComputeHashCode() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
   int32_t GetUtfLength() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);