Add shared separate data section for compact dex
Added a shared dex data buffer for compact dex files, this buffer
is referenced by all compact dex files in a vdex file. Repurposed
the existing data_off / data_size fields in the header.
After the shared buffer is filled up, it is placed after the dex
files in the oat writer and the dex file headers are fixed up to have
the correct offsets / sizes to the shared buffer.
Motivation:
Make it easy to deduplicate data across dexes.
Bug: 63756964
Test: test-art-host
Change-Id: I17855a0c78b20be3d323d12dedb9c695962be3ed
diff --git a/dexlayout/dex_container.h b/dexlayout/dex_container.h
index 7c426cb..2b9a5f9 100644
--- a/dexlayout/dex_container.h
+++ b/dexlayout/dex_container.h
@@ -43,6 +43,9 @@
// Resize the backing storage.
virtual void Resize(size_t size) = 0;
+ // Clear the container.
+ virtual void Clear() = 0;
+
// Returns the end of the memory region.
uint8_t* End() {
return Begin() + Size();
@@ -66,6 +69,10 @@
data_.resize(size, 0u);
}
+ void Clear() OVERRIDE {
+ data_.clear();
+ }
+
private:
std::vector<uint8_t> data_;
};