diff options
author | 2018-01-29 05:18:24 -0800 | |
---|---|---|
committer | 2018-01-29 06:06:49 -0800 | |
commit | 807b21b2364eee0770d1e24e5f34d71014afbac2 (patch) | |
tree | 5b505e6ae4a4cd67b3a4684f9cb7c2803440f6ca | |
parent | 7a5a3036f9d8f08871c1c6e03dfa25d3641593e2 (diff) |
Clean up some compact dex comments
Bug: 63756964
Test: test-art-host
Change-Id: If8748db7a9e68b6a82656fd9ec8fd8072e92af97
-rw-r--r-- | dexlayout/compact_dex_writer.cc | 7 | ||||
-rw-r--r-- | dexlayout/dex_ir_builder.h | 4 | ||||
-rw-r--r-- | dexlayout/dexlayout.h | 2 | ||||
-rw-r--r-- | dexlayout/dexlayout_test.cc | 4 |
4 files changed, 11 insertions, 6 deletions
diff --git a/dexlayout/compact_dex_writer.cc b/dexlayout/compact_dex_writer.cc index 092539fe93..08438c4f4a 100644 --- a/dexlayout/compact_dex_writer.cc +++ b/dexlayout/compact_dex_writer.cc @@ -121,11 +121,14 @@ CompactDexWriter::ScopedDataSectionItem::~ScopedDataSectionItem() { const uint32_t deduped_offset = deduper_->Dedupe(start_offset_, stream_->Tell(), item_->GetOffset()); - // In case we dedupe to something with wrong alignment, just say we didn't dedupe. + // If we deduped, only use the deduped offset if the alignment matches the required alignment. + // Otherwise, return without deduping. if (deduped_offset != Deduper::kDidNotDedupe && IsAlignedParam(deduped_offset, alignment_)) { + // Update the IR offset to the offset of the deduped item. item_->SetOffset(deduped_offset); + // Clear the written data for the item so that the stream write doesn't abort in the future. stream_->Clear(start_offset_, stream_->Tell() - start_offset_); - // Undo the offset for all that we wrote since we deduped. + // Since we deduped, restore the offset to the original position. stream_->Seek(start_offset_); } } diff --git a/dexlayout/dex_ir_builder.h b/dexlayout/dex_ir_builder.h index 43b5290756..9f5377fe56 100644 --- a/dexlayout/dex_ir_builder.h +++ b/dexlayout/dex_ir_builder.h @@ -27,8 +27,8 @@ class Options; namespace dex_ir { -// Eagerly assign offsets assigns offsets based on the original offsets in the input dex file. If -// this not done, dex_ir::Item::GetOffset will abort when reading uninitialized offsets. +// Eagerly assign offsets based on the original offsets in the input dex file. If this is not done, +// dex_ir::Item::GetOffset will abort when reading uninitialized offsets. dex_ir::Header* DexIrBuilder(const DexFile& dex_file, bool eagerly_assign_offsets, const Options& options); diff --git a/dexlayout/dexlayout.h b/dexlayout/dexlayout.h index e66710fa55..d2f9cb9ce5 100644 --- a/dexlayout/dexlayout.h +++ b/dexlayout/dexlayout.h @@ -72,6 +72,8 @@ class Options { const char* output_dex_directory_ = nullptr; const char* output_file_name_ = nullptr; const char* profile_file_name_ = nullptr; + // Filter that removes classes that don't have a matching descriptor (during IR creation). + // This speeds up cases when the output only requires a single class. std::set<std::string> class_filter_; }; diff --git a/dexlayout/dexlayout_test.cc b/dexlayout/dexlayout_test.cc index e93ade1412..be272fcf2c 100644 --- a/dexlayout/dexlayout_test.cc +++ b/dexlayout/dexlayout_test.cc @@ -823,9 +823,9 @@ TEST_F(DexLayoutTest, ClassFilter) { &error_msg)); ASSERT_TRUE(output_dex_file != nullptr); - ASSERT_EQ(output_dex_file->NumClassDefs(), 1u); + ASSERT_EQ(output_dex_file->NumClassDefs(), options.class_filter_.size()); for (uint32_t i = 0; i < output_dex_file->NumClassDefs(); ++i) { - // Check that every class is in the filter. + // Check that every class in the output dex file is in the filter. const DexFile::ClassDef& class_def = output_dex_file->GetClassDef(i); ASSERT_TRUE(options.class_filter_.find(output_dex_file->GetClassDescriptor(class_def)) != options.class_filter_.end()); |