summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime/gc_root-inl.h5
-rw-r--r--runtime/gc_root.h1
-rw-r--r--runtime/intern_table.cc150
-rw-r--r--runtime/intern_table.h38
-rw-r--r--runtime/mirror/string-inl.h11
-rw-r--r--runtime/mirror/string.cc17
-rw-r--r--runtime/mirror/string.h3
-rw-r--r--runtime/runtime.cc16
-rw-r--r--runtime/runtime.h8
-rw-r--r--runtime/transaction.cc24
-rw-r--r--runtime/transaction.h13
11 files changed, 153 insertions, 133 deletions
diff --git a/runtime/gc_root-inl.h b/runtime/gc_root-inl.h
index 482f7bca0e..2661e54261 100644
--- a/runtime/gc_root-inl.h
+++ b/runtime/gc_root-inl.h
@@ -29,5 +29,10 @@ inline MirrorType* GcRoot<MirrorType>::Read() {
return ReadBarrier::BarrierForRoot<MirrorType, kReadBarrierOption>(&root_);
}
+template<class MirrorType>
+inline void GcRoot<MirrorType>::Assign(MirrorType* value) {
+ root_ = value;
+}
+
} // namespace art
#endif // ART_RUNTIME_GC_ROOT_INL_H_
diff --git a/runtime/gc_root.h b/runtime/gc_root.h
index b10a55c1a2..3928f5d3e2 100644
--- a/runtime/gc_root.h
+++ b/runtime/gc_root.h
@@ -28,6 +28,7 @@ class PACKED(4) GcRoot {
public:
template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
ALWAYS_INLINE MirrorType* Read() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ ALWAYS_INLINE void Assign(MirrorType* value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
void VisitRoot(RootCallback* callback, void* arg, uint32_t thread_id, RootType root_type) {
callback(reinterpret_cast<mirror::Object**>(&root_), arg, thread_id, root_type);
diff --git a/runtime/intern_table.cc b/runtime/intern_table.cc
index aadd85a0f4..c66f99e50c 100644
--- a/runtime/intern_table.cc
+++ b/runtime/intern_table.cc
@@ -22,7 +22,7 @@
#include "mirror/dex_cache.h"
#include "mirror/object_array-inl.h"
#include "mirror/object-inl.h"
-#include "mirror/string.h"
+#include "mirror/string-inl.h"
#include "thread.h"
#include "utf.h"
@@ -58,25 +58,23 @@ void InternTable::VisitRoots(RootCallback* callback, void* arg, VisitRootFlags f
MutexLock mu(Thread::Current(), *Locks::intern_table_lock_);
if ((flags & kVisitRootFlagAllRoots) != 0) {
for (auto& strong_intern : strong_interns_) {
- strong_intern.second.VisitRoot(callback, arg, 0, kRootInternedString);
- DCHECK(!strong_intern.second.IsNull());
+ const_cast<GcRoot<mirror::String>&>(strong_intern).
+ VisitRoot(callback, arg, 0, kRootInternedString);
+ DCHECK(!strong_intern.IsNull());
}
} else if ((flags & kVisitRootFlagNewRoots) != 0) {
- for (auto& pair : new_strong_intern_roots_) {
- mirror::String* old_ref = pair.second.Read<kWithoutReadBarrier>();
- pair.second.VisitRoot(callback, arg, 0, kRootInternedString);
- mirror::String* new_ref = pair.second.Read<kWithoutReadBarrier>();
+ for (auto& root : new_strong_intern_roots_) {
+ mirror::String* old_ref = root.Read<kWithoutReadBarrier>();
+ root.VisitRoot(callback, arg, 0, kRootInternedString);
+ mirror::String* new_ref = root.Read<kWithoutReadBarrier>();
if (UNLIKELY(new_ref != old_ref)) {
- // Uh ohes, GC moved a root in the log. Need to search the strong interns and update the
+ // The GC moved a root in the log. Need to search the strong interns and update the
// corresponding object. This is slow, but luckily for us, this may only happen with a
// concurrent moving GC.
- for (auto it = strong_interns_.lower_bound(pair.first), end = strong_interns_.end();
- it != end && it->first == pair.first; ++it) {
- // If the class stored matches the old class, update it to the new value.
- if (old_ref == it->second.Read<kWithoutReadBarrier>()) {
- it->second = GcRoot<mirror::String>(new_ref);
- }
- }
+ auto it = strong_interns_.find(GcRoot<mirror::String>(old_ref));
+ DCHECK(it != strong_interns_.end());
+ strong_interns_.erase(it);
+ strong_interns_.insert(GcRoot<mirror::String>(new_ref));
}
}
}
@@ -92,87 +90,79 @@ void InternTable::VisitRoots(RootCallback* callback, void* arg, VisitRootFlags f
// Note: we deliberately don't visit the weak_interns_ table and the immutable image roots.
}
-mirror::String* InternTable::LookupStrong(mirror::String* s, int32_t hash_code) {
- return Lookup(&strong_interns_, s, hash_code);
+mirror::String* InternTable::LookupStrong(mirror::String* s) {
+ return Lookup(&strong_interns_, s);
}
-mirror::String* InternTable::LookupWeak(mirror::String* s, int32_t hash_code) {
+mirror::String* InternTable::LookupWeak(mirror::String* s) {
// Weak interns need a read barrier because they are weak roots.
- return Lookup(&weak_interns_, s, hash_code);
+ return Lookup(&weak_interns_, s);
}
-mirror::String* InternTable::Lookup(Table* table, mirror::String* s, int32_t hash_code) {
+mirror::String* InternTable::Lookup(Table* table, mirror::String* s) {
Locks::intern_table_lock_->AssertHeld(Thread::Current());
- for (auto it = table->lower_bound(hash_code), end = table->end();
- it != end && it->first == hash_code; ++it) {
- mirror::String* existing_string = it->second.Read();
- if (existing_string->Equals(s)) {
- return existing_string;
- }
+ auto it = table->find(GcRoot<mirror::String>(s));
+ if (LIKELY(it != table->end())) {
+ return const_cast<GcRoot<mirror::String>&>(*it).Read<kWithReadBarrier>();
}
- return NULL;
+ return nullptr;
}
-mirror::String* InternTable::InsertStrong(mirror::String* s, int32_t hash_code) {
+mirror::String* InternTable::InsertStrong(mirror::String* s) {
Runtime* runtime = Runtime::Current();
if (runtime->IsActiveTransaction()) {
- runtime->RecordStrongStringInsertion(s, hash_code);
+ runtime->RecordStrongStringInsertion(s);
}
if (log_new_roots_) {
- new_strong_intern_roots_.push_back(std::make_pair(hash_code, GcRoot<mirror::String>(s)));
+ new_strong_intern_roots_.push_back(GcRoot<mirror::String>(s));
}
- strong_interns_.insert(std::make_pair(hash_code, GcRoot<mirror::String>(s)));
+ strong_interns_.insert(GcRoot<mirror::String>(s));
return s;
}
-mirror::String* InternTable::InsertWeak(mirror::String* s, int32_t hash_code) {
+mirror::String* InternTable::InsertWeak(mirror::String* s) {
Runtime* runtime = Runtime::Current();
if (runtime->IsActiveTransaction()) {
- runtime->RecordWeakStringInsertion(s, hash_code);
+ runtime->RecordWeakStringInsertion(s);
}
- weak_interns_.insert(std::make_pair(hash_code, GcRoot<mirror::String>(s)));
+ weak_interns_.insert(GcRoot<mirror::String>(s));
return s;
}
-void InternTable::RemoveStrong(mirror::String* s, int32_t hash_code) {
- Remove(&strong_interns_, s, hash_code);
+void InternTable::RemoveStrong(mirror::String* s) {
+ Remove(&strong_interns_, s);
}
-void InternTable::RemoveWeak(mirror::String* s, int32_t hash_code) {
+void InternTable::RemoveWeak(mirror::String* s) {
Runtime* runtime = Runtime::Current();
if (runtime->IsActiveTransaction()) {
- runtime->RecordWeakStringRemoval(s, hash_code);
+ runtime->RecordWeakStringRemoval(s);
}
- Remove(&weak_interns_, s, hash_code);
+ Remove(&weak_interns_, s);
}
-void InternTable::Remove(Table* table, mirror::String* s, int32_t hash_code) {
- for (auto it = table->lower_bound(hash_code), end = table->end();
- it != end && it->first == hash_code; ++it) {
- mirror::String* existing_string = it->second.Read();
- if (existing_string == s) {
- table->erase(it);
- return;
- }
- }
+void InternTable::Remove(Table* table, mirror::String* s) {
+ auto it = table->find(GcRoot<mirror::String>(s));
+ DCHECK(it != table->end());
+ table->erase(it);
}
// Insert/remove methods used to undo changes made during an aborted transaction.
-mirror::String* InternTable::InsertStrongFromTransaction(mirror::String* s, int32_t hash_code) {
+mirror::String* InternTable::InsertStrongFromTransaction(mirror::String* s) {
DCHECK(!Runtime::Current()->IsActiveTransaction());
- return InsertStrong(s, hash_code);
+ return InsertStrong(s);
}
-mirror::String* InternTable::InsertWeakFromTransaction(mirror::String* s, int32_t hash_code) {
+mirror::String* InternTable::InsertWeakFromTransaction(mirror::String* s) {
DCHECK(!Runtime::Current()->IsActiveTransaction());
- return InsertWeak(s, hash_code);
+ return InsertWeak(s);
}
-void InternTable::RemoveStrongFromTransaction(mirror::String* s, int32_t hash_code) {
+void InternTable::RemoveStrongFromTransaction(mirror::String* s) {
DCHECK(!Runtime::Current()->IsActiveTransaction());
- RemoveStrong(s, hash_code);
+ RemoveStrong(s);
}
-void InternTable::RemoveWeakFromTransaction(mirror::String* s, int32_t hash_code) {
+void InternTable::RemoveWeakFromTransaction(mirror::String* s) {
DCHECK(!Runtime::Current()->IsActiveTransaction());
- RemoveWeak(s, hash_code);
+ RemoveWeak(s);
}
static mirror::String* LookupStringFromImage(mirror::String* s)
@@ -218,7 +208,6 @@ mirror::String* InternTable::Insert(mirror::String* s, bool is_strong) {
MutexLock mu(self, *Locks::intern_table_lock_);
DCHECK(s != NULL);
- uint32_t hash_code = s->GetHashCode();
while (UNLIKELY(!allow_new_interns_)) {
new_intern_condition_.WaitHoldingLocks(self);
@@ -226,7 +215,7 @@ mirror::String* InternTable::Insert(mirror::String* s, bool is_strong) {
if (is_strong) {
// Check the strong table for a match.
- mirror::String* strong = LookupStrong(s, hash_code);
+ mirror::String* strong = LookupStrong(s);
if (strong != NULL) {
return strong;
}
@@ -234,39 +223,39 @@ mirror::String* InternTable::Insert(mirror::String* s, bool is_strong) {
// Check the image for a match.
mirror::String* image = LookupStringFromImage(s);
if (image != NULL) {
- return InsertStrong(image, hash_code);
+ return InsertStrong(image);
}
// There is no match in the strong table, check the weak table.
- mirror::String* weak = LookupWeak(s, hash_code);
+ mirror::String* weak = LookupWeak(s);
if (weak != NULL) {
// A match was found in the weak table. Promote to the strong table.
- RemoveWeak(weak, hash_code);
- return InsertStrong(weak, hash_code);
+ RemoveWeak(weak);
+ return InsertStrong(weak);
}
// No match in the strong table or the weak table. Insert into the strong
// table.
- return InsertStrong(s, hash_code);
+ return InsertStrong(s);
}
// Check the strong table for a match.
- mirror::String* strong = LookupStrong(s, hash_code);
+ mirror::String* strong = LookupStrong(s);
if (strong != NULL) {
return strong;
}
// Check the image for a match.
mirror::String* image = LookupStringFromImage(s);
if (image != NULL) {
- return InsertWeak(image, hash_code);
+ return InsertWeak(image);
}
// Check the weak table for a match.
- mirror::String* weak = LookupWeak(s, hash_code);
+ mirror::String* weak = LookupWeak(s);
if (weak != NULL) {
return weak;
}
// Insert into the weak table.
- return InsertWeak(s, hash_code);
+ return InsertWeak(s);
}
mirror::String* InternTable::InternStrong(int32_t utf16_length, const char* utf8_data) {
@@ -296,7 +285,7 @@ mirror::String* InternTable::InternWeak(mirror::String* s) {
bool InternTable::ContainsWeak(mirror::String* s) {
MutexLock mu(Thread::Current(), *Locks::intern_table_lock_);
- const mirror::String* found = LookupWeak(s, s->GetHashCode());
+ const mirror::String* found = LookupWeak(s);
return found == s;
}
@@ -304,16 +293,33 @@ void InternTable::SweepInternTableWeaks(IsMarkedCallback* callback, void* arg) {
MutexLock mu(Thread::Current(), *Locks::intern_table_lock_);
for (auto it = weak_interns_.begin(), end = weak_interns_.end(); it != end;) {
// This does not need a read barrier because this is called by GC.
- mirror::Object* object = it->second.Read<kWithoutReadBarrier>();
+ GcRoot<mirror::String>& root = const_cast<GcRoot<mirror::String>&>(*it);
+ mirror::Object* object = root.Read<kWithoutReadBarrier>();
mirror::Object* new_object = callback(object, arg);
if (new_object == nullptr) {
- // TODO: use it = weak_interns_.erase(it) when we get a c++11 stl.
- weak_interns_.erase(it++);
+ it = weak_interns_.erase(it);
} else {
- it->second = GcRoot<mirror::String>(down_cast<mirror::String*>(new_object));
+ root.Assign(down_cast<mirror::String*>(new_object));
++it;
}
}
}
+std::size_t InternTable::StringHashEquals::operator()(const GcRoot<mirror::String>& root) {
+ if (kIsDebugBuild) {
+ Locks::mutator_lock_->AssertSharedHeld(Thread::Current());
+ }
+ return static_cast<size_t>(
+ const_cast<GcRoot<mirror::String>&>(root).Read<kWithoutReadBarrier>()->GetHashCode());
+}
+
+bool InternTable::StringHashEquals::operator()(const GcRoot<mirror::String>& a,
+ const GcRoot<mirror::String>& b) {
+ if (kIsDebugBuild) {
+ Locks::mutator_lock_->AssertSharedHeld(Thread::Current());
+ }
+ return const_cast<GcRoot<mirror::String>&>(a).Read<kWithoutReadBarrier>()->Equals(
+ const_cast<GcRoot<mirror::String>&>(b).Read<kWithoutReadBarrier>());
+}
+
} // namespace art
diff --git a/runtime/intern_table.h b/runtime/intern_table.h
index 21f80464c7..e3223c8616 100644
--- a/runtime/intern_table.h
+++ b/runtime/intern_table.h
@@ -17,7 +17,7 @@
#ifndef ART_RUNTIME_INTERN_TABLE_H_
#define ART_RUNTIME_INTERN_TABLE_H_
-#include <map>
+#include <unordered_set>
#include "base/allocator.h"
#include "base/mutex.h"
@@ -79,42 +79,48 @@ class InternTable {
void AllowNewInterns() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
private:
- typedef AllocationTrackingMultiMap<int32_t, GcRoot<mirror::String>,
- kAllocatorTagInternTable> Table;
+ class StringHashEquals {
+ public:
+ std::size_t operator()(const GcRoot<mirror::String>& root) NO_THREAD_SAFETY_ANALYSIS;
+ bool operator()(const GcRoot<mirror::String>& a, const GcRoot<mirror::String>& b)
+ NO_THREAD_SAFETY_ANALYSIS;
+ };
+ typedef std::unordered_set<GcRoot<mirror::String>, StringHashEquals, StringHashEquals,
+ TrackingAllocator<GcRoot<mirror::String>, kAllocatorTagInternTable>> Table;
mirror::String* Insert(mirror::String* s, bool is_strong)
LOCKS_EXCLUDED(Locks::intern_table_lock_)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- mirror::String* LookupStrong(mirror::String* s, int32_t hash_code)
+ mirror::String* LookupStrong(mirror::String* s)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- mirror::String* LookupWeak(mirror::String* s, int32_t hash_code)
+ mirror::String* LookupWeak(mirror::String* s)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- mirror::String* Lookup(Table* table, mirror::String* s, int32_t hash_code)
+ mirror::String* Lookup(Table* table, mirror::String* s)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- mirror::String* InsertStrong(mirror::String* s, int32_t hash_code)
+ mirror::String* InsertStrong(mirror::String* s)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
- mirror::String* InsertWeak(mirror::String* s, int32_t hash_code)
+ mirror::String* InsertWeak(mirror::String* s)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
- void RemoveStrong(mirror::String* s, int32_t hash_code)
+ void RemoveStrong(mirror::String* s)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
- void RemoveWeak(mirror::String* s, int32_t hash_code)
+ void RemoveWeak(mirror::String* s)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
- void Remove(Table* table, mirror::String* s, int32_t hash_code)
+ void Remove(Table* table, mirror::String* s)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
// Transaction rollback access.
- mirror::String* InsertStrongFromTransaction(mirror::String* s, int32_t hash_code)
+ mirror::String* InsertStrongFromTransaction(mirror::String* s)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
- mirror::String* InsertWeakFromTransaction(mirror::String* s, int32_t hash_code)
+ mirror::String* InsertWeakFromTransaction(mirror::String* s)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
- void RemoveStrongFromTransaction(mirror::String* s, int32_t hash_code)
+ void RemoveStrongFromTransaction(mirror::String* s)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
- void RemoveWeakFromTransaction(mirror::String* s, int32_t hash_code)
+ void RemoveWeakFromTransaction(mirror::String* s)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
friend class Transaction;
@@ -127,7 +133,7 @@ class InternTable {
// directly access the strings in it. Use functions that contain
// read barriers.
Table strong_interns_ GUARDED_BY(Locks::intern_table_lock_);
- std::vector<std::pair<int32_t, GcRoot<mirror::String>>> new_strong_intern_roots_
+ std::vector<GcRoot<mirror::String>> new_strong_intern_roots_
GUARDED_BY(Locks::intern_table_lock_);
// Since this contains (weak) roots, they need a read barrier. Do
// not directly access the strings in it. Use functions that contain
diff --git a/runtime/mirror/string-inl.h b/runtime/mirror/string-inl.h
index f98407b224..14d7de2ffb 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 e81e4312e7..01599ae907 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 66a5dd827d..1320ab71a3 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_);
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 5f9a3e36c9..20f01d9787 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1330,28 +1330,28 @@ void Runtime::RecordWriteArray(mirror::Array* array, size_t index, uint64_t valu
preinitialization_transaction_->RecordWriteArray(array, index, value);
}
-void Runtime::RecordStrongStringInsertion(mirror::String* s, uint32_t hash_code) const {
+void Runtime::RecordStrongStringInsertion(mirror::String* s) const {
DCHECK(IsCompiler());
DCHECK(IsActiveTransaction());
- preinitialization_transaction_->RecordStrongStringInsertion(s, hash_code);
+ preinitialization_transaction_->RecordStrongStringInsertion(s);
}
-void Runtime::RecordWeakStringInsertion(mirror::String* s, uint32_t hash_code) const {
+void Runtime::RecordWeakStringInsertion(mirror::String* s) const {
DCHECK(IsCompiler());
DCHECK(IsActiveTransaction());
- preinitialization_transaction_->RecordWeakStringInsertion(s, hash_code);
+ preinitialization_transaction_->RecordWeakStringInsertion(s);
}
-void Runtime::RecordStrongStringRemoval(mirror::String* s, uint32_t hash_code) const {
+void Runtime::RecordStrongStringRemoval(mirror::String* s) const {
DCHECK(IsCompiler());
DCHECK(IsActiveTransaction());
- preinitialization_transaction_->RecordStrongStringRemoval(s, hash_code);
+ preinitialization_transaction_->RecordStrongStringRemoval(s);
}
-void Runtime::RecordWeakStringRemoval(mirror::String* s, uint32_t hash_code) const {
+void Runtime::RecordWeakStringRemoval(mirror::String* s) const {
DCHECK(IsCompiler());
DCHECK(IsActiveTransaction());
- preinitialization_transaction_->RecordWeakStringRemoval(s, hash_code);
+ preinitialization_transaction_->RecordWeakStringRemoval(s);
}
void Runtime::SetFaultMessage(const std::string& message) {
diff --git a/runtime/runtime.h b/runtime/runtime.h
index e97af17faa..9dff745195 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -432,13 +432,13 @@ class Runtime {
mirror::Object* value, bool is_volatile) const;
void RecordWriteArray(mirror::Array* array, size_t index, uint64_t value) const
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- void RecordStrongStringInsertion(mirror::String* s, uint32_t hash_code) const
+ void RecordStrongStringInsertion(mirror::String* s) const
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
- void RecordWeakStringInsertion(mirror::String* s, uint32_t hash_code) const
+ void RecordWeakStringInsertion(mirror::String* s) const
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
- void RecordStrongStringRemoval(mirror::String* s, uint32_t hash_code) const
+ void RecordStrongStringRemoval(mirror::String* s) const
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
- void RecordWeakStringRemoval(mirror::String* s, uint32_t hash_code) const
+ void RecordWeakStringRemoval(mirror::String* s) const
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
void SetFaultMessage(const std::string& message);
diff --git a/runtime/transaction.cc b/runtime/transaction.cc
index 0cfdfc57fc..b496f25c23 100644
--- a/runtime/transaction.cc
+++ b/runtime/transaction.cc
@@ -124,23 +124,23 @@ void Transaction::RecordWriteArray(mirror::Array* array, size_t index, uint64_t
array_log.LogValue(index, value);
}
-void Transaction::RecordStrongStringInsertion(mirror::String* s, uint32_t hash_code) {
- InternStringLog log(s, hash_code, InternStringLog::kStrongString, InternStringLog::kInsert);
+void Transaction::RecordStrongStringInsertion(mirror::String* s) {
+ InternStringLog log(s, InternStringLog::kStrongString, InternStringLog::kInsert);
LogInternedString(log);
}
-void Transaction::RecordWeakStringInsertion(mirror::String* s, uint32_t hash_code) {
- InternStringLog log(s, hash_code, InternStringLog::kWeakString, InternStringLog::kInsert);
+void Transaction::RecordWeakStringInsertion(mirror::String* s) {
+ InternStringLog log(s, InternStringLog::kWeakString, InternStringLog::kInsert);
LogInternedString(log);
}
-void Transaction::RecordStrongStringRemoval(mirror::String* s, uint32_t hash_code) {
- InternStringLog log(s, hash_code, InternStringLog::kStrongString, InternStringLog::kRemove);
+void Transaction::RecordStrongStringRemoval(mirror::String* s) {
+ InternStringLog log(s, InternStringLog::kStrongString, InternStringLog::kRemove);
LogInternedString(log);
}
-void Transaction::RecordWeakStringRemoval(mirror::String* s, uint32_t hash_code) {
- InternStringLog log(s, hash_code, InternStringLog::kWeakString, InternStringLog::kRemove);
+void Transaction::RecordWeakStringRemoval(mirror::String* s) {
+ InternStringLog log(s, InternStringLog::kWeakString, InternStringLog::kRemove);
LogInternedString(log);
}
@@ -409,10 +409,10 @@ void Transaction::InternStringLog::Undo(InternTable* intern_table) {
case InternStringLog::kInsert: {
switch (string_kind_) {
case InternStringLog::kStrongString:
- intern_table->RemoveStrongFromTransaction(str_, hash_code_);
+ intern_table->RemoveStrongFromTransaction(str_);
break;
case InternStringLog::kWeakString:
- intern_table->RemoveWeakFromTransaction(str_, hash_code_);
+ intern_table->RemoveWeakFromTransaction(str_);
break;
default:
LOG(FATAL) << "Unknown interned string kind";
@@ -423,10 +423,10 @@ void Transaction::InternStringLog::Undo(InternTable* intern_table) {
case InternStringLog::kRemove: {
switch (string_kind_) {
case InternStringLog::kStrongString:
- intern_table->InsertStrongFromTransaction(str_, hash_code_);
+ intern_table->InsertStrongFromTransaction(str_);
break;
case InternStringLog::kWeakString:
- intern_table->InsertWeakFromTransaction(str_, hash_code_);
+ intern_table->InsertWeakFromTransaction(str_);
break;
default:
LOG(FATAL) << "Unknown interned string kind";
diff --git a/runtime/transaction.h b/runtime/transaction.h
index 63900493a5..21d3c98054 100644
--- a/runtime/transaction.h
+++ b/runtime/transaction.h
@@ -69,16 +69,16 @@ class Transaction {
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// Record intern string table changes.
- void RecordStrongStringInsertion(mirror::String* s, uint32_t hash_code)
+ void RecordStrongStringInsertion(mirror::String* s)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_)
LOCKS_EXCLUDED(log_lock_);
- void RecordWeakStringInsertion(mirror::String* s, uint32_t hash_code)
+ void RecordWeakStringInsertion(mirror::String* s)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_)
LOCKS_EXCLUDED(log_lock_);
- void RecordStrongStringRemoval(mirror::String* s, uint32_t hash_code)
+ void RecordStrongStringRemoval(mirror::String* s)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_)
LOCKS_EXCLUDED(log_lock_);
- void RecordWeakStringRemoval(mirror::String* s, uint32_t hash_code)
+ void RecordWeakStringRemoval(mirror::String* s)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_)
LOCKS_EXCLUDED(log_lock_);
@@ -163,8 +163,8 @@ class Transaction {
kInsert,
kRemove
};
- InternStringLog(mirror::String* s, uint32_t hash_code, StringKind kind, StringOp op)
- : str_(s), hash_code_(hash_code), string_kind_(kind), string_op_(op) {
+ InternStringLog(mirror::String* s, StringKind kind, StringOp op)
+ : str_(s), string_kind_(kind), string_op_(op) {
DCHECK(s != nullptr);
}
@@ -175,7 +175,6 @@ class Transaction {
private:
mirror::String* str_;
- uint32_t hash_code_;
StringKind string_kind_;
StringOp string_op_;
};