diff options
author | Mathieu Chartier <mathieuc@google.com> | 2014-08-29 18:16:58 -0700 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2014-09-02 14:39:49 -0700 |
commit | cdfd39f579574a75b98e7ad48c69826b00361b27 (patch) | |
tree | 0f057472d19bf290766e20ea3ad63d0b28ee83a1 /runtime/mirror | |
parent | 9a4f02722051955e536d6aacb776d637a6713545 (diff) | |
download | art-cdfd39f579574a75b98e7ad48c69826b00361b27.zip art-cdfd39f579574a75b98e7ad48c69826b00361b27.tar.gz art-cdfd39f579574a75b98e7ad48c69826b00361b27.tar.bz2 |
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
Diffstat (limited to 'runtime/mirror')
-rw-r--r-- | runtime/mirror/string-inl.h | 11 | ||||
-rw-r--r-- | runtime/mirror/string.cc | 17 | ||||
-rw-r--r-- | runtime/mirror/string.h | 3 |
3 files changed, 17 insertions, 14 deletions
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 @@ inline uint16_t String::CharAt(int32_t index) { 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 @@ void String::ResetClass() { 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 @@ class MANAGED String FINAL : public Object { 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_); |