diff options
Diffstat (limited to 'runtime/intern_table.cc')
-rw-r--r-- | runtime/intern_table.cc | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/runtime/intern_table.cc b/runtime/intern_table.cc index 89c15f8..2072979 100644 --- a/runtime/intern_table.cc +++ b/runtime/intern_table.cc @@ -28,7 +28,9 @@ namespace art { InternTable::InternTable() - : intern_table_lock_("InternTable lock"), is_dirty_(false) {} + : intern_table_lock_("InternTable lock"), is_dirty_(false), allow_new_interns_(true), + new_intern_condition_("New intern condition", intern_table_lock_) { +} size_t InternTable::Size() const { MutexLock mu(Thread::Current(), intern_table_lock_); @@ -111,12 +113,30 @@ static mirror::String* LookupStringFromImage(mirror::String* s) return NULL; } +void InternTable::AllowNewInterns() { + Thread* self = Thread::Current(); + MutexLock mu(self, intern_table_lock_); + allow_new_interns_ = true; + new_intern_condition_.Broadcast(self); +} + +void InternTable::DisallowNewInterns() { + Thread* self = Thread::Current(); + MutexLock mu(self, intern_table_lock_); + allow_new_interns_ = false; +} + mirror::String* InternTable::Insert(mirror::String* s, bool is_strong) { - MutexLock mu(Thread::Current(), intern_table_lock_); + Thread* self = Thread::Current(); + MutexLock mu(self, intern_table_lock_); DCHECK(s != NULL); uint32_t hash_code = s->GetHashCode(); + while (UNLIKELY(!allow_new_interns_)) { + new_intern_condition_.WaitHoldingLocks(self); + } + if (is_strong) { // Check the strong table for a match. mirror::String* strong = Lookup(strong_interns_, s, hash_code); |