Support image classes filtering in image writer
New logic prunes classes that have any dependency on a non-image
class. This enables creating smaller images with class profiling.
Code is from class profiling CL.
Added a CHECK for guarding against creating an app boot image with
existing boot image(s).
Bug: 22858531
Change-Id: Id5f38c8122e67141b851d0f41b68d2ffd07280d0
diff --git a/compiler/image_writer.h b/compiler/image_writer.h
index b227c44..ee204c5 100644
--- a/compiler/image_writer.h
+++ b/compiler/image_writer.h
@@ -410,16 +410,18 @@
// Return true if klass is loaded by the boot class loader but not in the boot image.
bool IsBootClassLoaderNonImageClass(mirror::Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
- // Return true if klass depends on a boot class loader non image class live. We want to prune
- // these classes since we do not want any boot class loader classes in the image. This means that
+ // Return true if klass depends on a boot class loader non image class. We want to prune these
+ // classes since we do not want any boot class loader classes in the image. This means that
// we also cannot have any classes which refer to these boot class loader non image classes.
- bool ContainsBootClassLoaderNonImageClass(mirror::Class* klass)
+ // PruneAppImageClass also prunes if klass depends on a non-image class according to the compiler
+ // driver.
+ bool PruneAppImageClass(mirror::Class* klass)
SHARED_REQUIRES(Locks::mutator_lock_);
// early_exit is true if we had a cyclic dependency anywhere down the chain.
- bool ContainsBootClassLoaderNonImageClassInternal(mirror::Class* klass,
- bool* early_exit,
- std::unordered_set<mirror::Class*>* visited)
+ bool PruneAppImageClassInternal(mirror::Class* klass,
+ bool* early_exit,
+ std::unordered_set<mirror::Class*>* visited)
SHARED_REQUIRES(Locks::mutator_lock_);
static Bin BinTypeForNativeRelocationType(NativeObjectRelocationType type);