Add logging of implicitly added image classes
Change-Id: I52bc30b340032ba59e23f1ba0ef6f683c497db68
diff --git a/src/dex2oat.cc b/src/dex2oat.cc
index 0567788..6df381e 100644
--- a/src/dex2oat.cc
+++ b/src/dex2oat.cc
@@ -222,7 +222,7 @@
// We walk the roots looking for classes so that we'll pick up the
// above classes plus any classes them depend on such super
// classes, interfaces, and the required ClassLinker roots.
- UniquePtr<std::set<std::string> > image_classes(new std::set<std::string>());
+ UniquePtr<ImageWriter::DescriptorSet> image_classes(new ImageWriter::DescriptorSet);
class_linker->VisitClasses(RecordImageClassesVisitor, image_classes.get());
CHECK_NE(image_classes->size(), 0U);
return image_classes.release();
@@ -236,7 +236,7 @@
File* oat_file,
const std::string& bitcode_filename,
bool image,
- const std::set<std::string>* image_classes,
+ const ImageWriter::DescriptorSet* image_classes,
bool dump_stats,
bool dump_timings)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
@@ -313,7 +313,7 @@
bool CreateImageFile(const std::string& image_filename,
uintptr_t image_base,
- std::set<std::string>* image_classes,
+ ImageWriter::DescriptorSet* image_classes,
const std::string& oat_filename,
const std::string& oat_location,
const CompilerDriver& compiler)
@@ -431,7 +431,7 @@
static bool RecordImageClassesVisitor(mirror::Class* klass, void* arg)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- std::set<std::string>* image_classes = reinterpret_cast<std::set<std::string>*>(arg);
+ ImageWriter::DescriptorSet* image_classes = reinterpret_cast<ImageWriter::DescriptorSet*>(arg);
if (klass->IsArrayClass() || klass->IsPrimitive()) {
return true;
}
@@ -934,7 +934,7 @@
ScopedObjectAccess soa(Thread::Current());
// If --image-classes was specified, calculate the full list of classes to include in the image
- UniquePtr<std::set<std::string> > image_classes(NULL);
+ UniquePtr<ImageWriter::DescriptorSet> image_classes(NULL);
if (image_classes_filename != NULL) {
image_classes.reset(dex2oat->GetImageClassDescriptors(image_classes_filename));
if (image_classes.get() == NULL) {
diff --git a/src/image_writer.cc b/src/image_writer.cc
index fc9aabc..a989a4e 100644
--- a/src/image_writer.cc
+++ b/src/image_writer.cc
@@ -283,7 +283,12 @@
return;
}
while (!klass->IsObjectClass()) {
- image_writer->image_classes_->insert(ClassHelper(klass).GetDescriptor());
+ ClassHelper kh(klass);
+ const char* descriptor = kh.GetDescriptor();
+ std::pair<DescriptorSet::iterator, bool> result = image_writer->image_classes_->insert(descriptor);
+ if (result.second) {
+ LOG(INFO) << "Adding " << descriptor << " to image classes";
+ }
klass = klass->GetSuperClass();
}
}
diff --git a/src/image_writer.h b/src/image_writer.h
index 0cccf69..30a7f7f 100644
--- a/src/image_writer.h
+++ b/src/image_writer.h
@@ -37,7 +37,8 @@
// Write a Space built during compilation for use during execution.
class ImageWriter {
public:
- explicit ImageWriter(std::set<std::string>* image_classes)
+ typedef std::set<std::string> DescriptorSet;
+ explicit ImageWriter(DescriptorSet* image_classes)
: oat_file_(NULL), image_end_(0), image_begin_(NULL), image_classes_(image_classes),
oat_data_begin_(NULL) {}
@@ -191,7 +192,7 @@
byte* image_begin_;
// Set of classes to be include in the image, or NULL for all.
- std::set<std::string>* image_classes_;
+ DescriptorSet* image_classes_;
// Beginning target oat address for the pointers from the output image to its oat file.
const byte* oat_data_begin_;