From c11d9b8870de5f860b13c84003ade7b3f3125a52 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Thu, 19 Sep 2013 10:01:59 -0700 Subject: Re-enable concurrent system weak sweeping. Enabled by disallowing new system weaks during the pause and re-allowing it after the system weaks have been swept. Reduces GC pause by ~1ms. Fixes pause regression caused by fix for Bug: 10626133 Change-Id: If49d33e7ef19cb728ed3cef5187acfa53b9b05d8 --- runtime/intern_table.cc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'runtime/intern_table.cc') 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); -- cgit v1.1