Make allocation tracker use less memory

The allocation tracker no longer keeps recently allocated objects live.
Instead it just keeps their class objects live as strong roots. This fixed
the gc-stress test failure for 098-ddmc.

Also fixed the issue in DisableNewSystemWeak() for allocation tracker,
by making new allocation to wait until GC's sweeping to complete. I didn't
feel any significant slowdown with this wait.

Bug: 20037135
Change-Id: I6a98188832cf7ee478007e3788e742dc6e18f7b8
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 54a3235..1c75bd0 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -706,10 +706,24 @@
       EXCLUSIVE_LOCKS_REQUIRED(Locks::alloc_tracker_lock_);
 
   void VisitAllocationRecords(RootVisitor* visitor) const
-      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+      LOCKS_EXCLUDED(Locks::alloc_tracker_lock_);
 
   void SweepAllocationRecords(IsMarkedCallback* visitor, void* arg) const
-      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+      LOCKS_EXCLUDED(Locks::alloc_tracker_lock_);
+
+  void DisallowNewAllocationRecords() const
+      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+      LOCKS_EXCLUDED(Locks::alloc_tracker_lock_);
+
+  void AllowNewAllocationRecords() const
+      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+      LOCKS_EXCLUDED(Locks::alloc_tracker_lock_);
+
+  void EnsureNewAllocationRecordsDisallowed() const
+      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+      LOCKS_EXCLUDED(Locks::alloc_tracker_lock_);
 
  private:
   class ConcurrentGCTask;