diff options
| -rw-r--r-- | dexlayout/compact_dex_writer.cc | 29 | ||||
| -rw-r--r-- | dexlayout/compact_dex_writer.h | 10 | ||||
| -rw-r--r-- | dexlayout/dexlayout.h | 1 | ||||
| -rw-r--r-- | libdexfile/dex/compact_dex_file.h | 3 | ||||
| -rw-r--r-- | test/536-checker-needs-access-check/src/Main.java | 5 |
5 files changed, 19 insertions, 29 deletions
diff --git a/dexlayout/compact_dex_writer.cc b/dexlayout/compact_dex_writer.cc index a7dad0762d..b8c6ebe2c9 100644 --- a/dexlayout/compact_dex_writer.cc +++ b/dexlayout/compact_dex_writer.cc @@ -34,9 +34,8 @@ CompactDexLevel CompactDexWriter::GetCompactDexLevel() const { return dex_layout_->GetOptions().compact_dex_level_; } -CompactDexWriter::Container::Container(bool dedupe_code_items) - : code_item_dedupe_(dedupe_code_items, &data_section_), - data_item_dedupe_(/*enabled=*/ true, &data_section_) {} +CompactDexWriter::Container::Container() + : data_item_dedupe_(&data_section_) {} uint32_t CompactDexWriter::WriteDebugInfoOffsetTable(Stream* stream) { const uint32_t start_offset = stream->Tell(); @@ -117,7 +116,10 @@ CompactDexWriter::ScopedDataSectionItem::ScopedDataSectionItem(Stream* stream, } CompactDexWriter::ScopedDataSectionItem::~ScopedDataSectionItem() { - // After having written, maybe dedupe the whole code item (excluding padding). + if (deduper_ == nullptr) { + return; + } + // After having written, maybe dedupe the whole section (excluding padding). const uint32_t deduped_offset = deduper_->Dedupe(start_offset_, stream_->Tell(), item_->GetOffset()); @@ -145,7 +147,7 @@ void CompactDexWriter::WriteCodeItem(Stream* stream, ScopedDataSectionItem data_item(stream, code_item, CompactDexFile::CodeItem::kAlignment, - code_item_dedupe_); + /* deduper= */ nullptr); CompactDexFile::CodeItem disk_code_item; @@ -209,18 +211,14 @@ void CompactDexWriter::WriteDebugInfoItem(Stream* stream, dex_ir::DebugInfoItem* } -CompactDexWriter::Deduper::Deduper(bool enabled, DexContainer::Section* section) - : enabled_(enabled), - dedupe_map_(/*__n=*/ 32, +CompactDexWriter::Deduper::Deduper(DexContainer::Section* section) + : dedupe_map_(/*__n=*/ 32, HashedMemoryRange::HashEqual(section), HashedMemoryRange::HashEqual(section)) {} uint32_t CompactDexWriter::Deduper::Dedupe(uint32_t data_start, uint32_t data_end, uint32_t item_offset) { - if (!enabled_) { - return kDidNotDedupe; - } HashedMemoryRange range {data_start, data_end - data_start}; auto existing = dedupe_map_.emplace(range, item_offset); if (!existing.second) { @@ -397,7 +395,6 @@ bool CompactDexWriter::Write(DexContainer* output, std::string* error_msg) { data_stream->Seek(std::max( static_cast<uint32_t>(output->GetDataSection()->Size()), kDataSectionAlignment)); - code_item_dedupe_ = &container->code_item_dedupe_; data_item_dedupe_ = &container->data_item_dedupe_; // Starting offset is right after the header. @@ -521,17 +518,11 @@ bool CompactDexWriter::Write(DexContainer* output, std::string* error_msg) { WriteHeader(main_stream); } - // Clear the dedupe to prevent interdex code item deduping. This does not currently work well with - // dex2oat's class unloading. The issue is that verification encounters quickened opcodes after - // the first dex gets unloaded. - code_item_dedupe_->Clear(); - return true; } std::unique_ptr<DexContainer> CompactDexWriter::CreateDexContainer() const { - return std::unique_ptr<DexContainer>( - new CompactDexWriter::Container(dex_layout_->GetOptions().dedupe_code_items_)); + return std::unique_ptr<DexContainer>(new CompactDexWriter::Container()); } } // namespace art diff --git a/dexlayout/compact_dex_writer.h b/dexlayout/compact_dex_writer.h index c81d0c722d..d78f8bebde 100644 --- a/dexlayout/compact_dex_writer.h +++ b/dexlayout/compact_dex_writer.h @@ -37,8 +37,7 @@ class CompactDexWriter : public DexWriter { public: static const uint32_t kDidNotDedupe = 0; - // if not enabled, Dedupe will always return kDidNotDedupe. - explicit Deduper(bool enabled, DexContainer::Section* section); + explicit Deduper(DexContainer::Section* section); // Deduplicate a blob of data that has been written to mem_map. // Returns the offset of the deduplicated data or kDidNotDedupe did deduplication did not occur. @@ -85,8 +84,6 @@ class CompactDexWriter : public DexWriter { }; }; - const bool enabled_; - // Dedupe map. std::unordered_map<HashedMemoryRange, uint32_t, @@ -125,11 +122,10 @@ class CompactDexWriter : public DexWriter { } private: - explicit Container(bool dedupe_code_items); + Container(); VectorSection main_section_; VectorSection data_section_; - Deduper code_item_dedupe_; Deduper data_item_dedupe_; friend class CompactDexWriter; @@ -173,8 +169,6 @@ class CompactDexWriter : public DexWriter { uint32_t owned_data_begin_ = 0u; uint32_t owned_data_end_ = 0u; - // State for where we are deduping. - Deduper* code_item_dedupe_ = nullptr; Deduper* data_item_dedupe_ = nullptr; DISALLOW_COPY_AND_ASSIGN(CompactDexWriter); diff --git a/dexlayout/dexlayout.h b/dexlayout/dexlayout.h index 60076bf59f..9bb7b8b2e8 100644 --- a/dexlayout/dexlayout.h +++ b/dexlayout/dexlayout.h @@ -67,7 +67,6 @@ class Options { bool visualize_pattern_ = false; bool update_checksum_ = false; CompactDexLevel compact_dex_level_ = CompactDexLevel::kCompactDexLevelNone; - bool dedupe_code_items_ = true; OutputFormat output_format_ = kOutputPlain; const char* output_dex_directory_ = nullptr; const char* output_file_name_ = nullptr; diff --git a/libdexfile/dex/compact_dex_file.h b/libdexfile/dex/compact_dex_file.h index f5cd924bad..9a12f4a8a5 100644 --- a/libdexfile/dex/compact_dex_file.h +++ b/libdexfile/dex/compact_dex_file.h @@ -27,7 +27,8 @@ namespace art { class CompactDexFile : public DexFile { public: static constexpr uint8_t kDexMagic[kDexMagicSize] = { 'c', 'd', 'e', 'x' }; - static constexpr uint8_t kDexMagicVersion[] = {'0', '0', '1', '\0'}; + // Last change: remove code item deduping. + static constexpr uint8_t kDexMagicVersion[] = {'0', '0', '2', '\0'}; enum class FeatureFlags : uint32_t { kDefaultMethods = 0x1, diff --git a/test/536-checker-needs-access-check/src/Main.java b/test/536-checker-needs-access-check/src/Main.java index 0dc2ab1074..bb402e5fbd 100644 --- a/test/536-checker-needs-access-check/src/Main.java +++ b/test/536-checker-needs-access-check/src/Main.java @@ -51,6 +51,11 @@ public class Main { InaccessibleClassProxy.testGetReferrersClass(); InaccessibleClassProxy.testGetReferrersClassViaAnotherClass(); + + // Execute again now that classes have been initialized, and entrypoints may have been + // updated. + InaccessibleClassProxy.testGetReferrersClass(); + InaccessibleClassProxy.testGetReferrersClassViaAnotherClass(); } /// CHECK-START: boolean Main.testInstanceOf() register (after) |