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
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 @@
   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);