Revert "Add one LinearAlloc per ClassLoader"

Times out on 32bit target/host for 132-daemon-locks-shutdown test.

Bug: 22720414

This reverts commit 356412e2b7ba3fde164bc08a44fee0ddc19c54e1.

Change-Id: I5ab3a09e88a5ad8c306a27d2606ecbecc80b9326
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index f705330..fee7066 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -403,13 +403,9 @@
       SHARED_REQUIRES(Locks::mutator_lock_)
       REQUIRES(!Roles::uninterruptible_);
 
-  LengthPrefixedArray<ArtField>* AllocArtFieldArray(Thread* self,
-                                                    LinearAlloc* allocator,
-                                                    size_t length);
+  LengthPrefixedArray<ArtField>* AllocArtFieldArray(Thread* self, size_t length);
 
-  LengthPrefixedArray<ArtMethod>* AllocArtMethodArray(Thread* self,
-                                                      LinearAlloc* allocator,
-                                                      size_t length);
+  LengthPrefixedArray<ArtMethod>* AllocArtMethodArray(Thread* self, size_t length);
 
   mirror::PointerArray* AllocPointerArray(Thread* self, size_t length)
       SHARED_REQUIRES(Locks::mutator_lock_)
@@ -550,24 +546,17 @@
   // entries are roots, but potentially not image classes.
   void DropFindArrayClassCache() SHARED_REQUIRES(Locks::mutator_lock_);
 
-  // Clean up class loaders, this needs to happen after JNI weak globals are cleared.
-  void CleanupClassLoaders()
-      SHARED_REQUIRES(Locks::mutator_lock_)
-      REQUIRES(!Locks::classlinker_classes_lock_);
-
-  static LinearAlloc* GetAllocatorForClassLoader(mirror::ClassLoader* class_loader)
-      SHARED_REQUIRES(Locks::mutator_lock_);
-
  private:
-  struct ClassLoaderData {
-    jobject weak_root;  // Weak root to enable class unloading.
-    ClassTable* class_table;
-    LinearAlloc* allocator;
-  };
-
+  // The RemoveClearedLoaders version removes cleared weak global class loaders and frees their
+  // class tables. This version can only be called with reader access to the
+  // classlinker_classes_lock_ since it modifies the class_loaders_ list.
+  void VisitClassLoadersAndRemoveClearedLoaders(ClassLoaderVisitor* visitor)
+      REQUIRES(Locks::classlinker_classes_lock_)
+      SHARED_REQUIRES(Locks::mutator_lock_);
   void VisitClassLoaders(ClassLoaderVisitor* visitor) const
       SHARED_REQUIRES(Locks::classlinker_classes_lock_, Locks::mutator_lock_);
 
+
   void VisitClassesInternal(ClassVisitor* visitor)
       SHARED_REQUIRES(Locks::classlinker_classes_lock_, Locks::mutator_lock_);
 
@@ -837,8 +826,8 @@
   std::vector<const OatFile*> oat_files_ GUARDED_BY(dex_lock_);
 
   // This contains the class loaders which have class tables. It is populated by
-  // InsertClassTableForClassLoader.
-  std::list<ClassLoaderData> class_loaders_
+  // InsertClassTableForClassLoader. Weak roots to enable class unloading.
+  std::list<jweak> class_loaders_
       GUARDED_BY(Locks::classlinker_classes_lock_);
 
   // Boot class path table. Since the class loader for this is null.