Add logic for deduplicating in dexlayout
Added logic for dedeplicating blobs, this is only used for code items
in compact dex for now. This currently provides 0.74% code size
reduction on golem
Disabled for now since quickening is fragile and does not play well
with deduped code items currently.
Future work is to fix quickening and dedupe after quickening to get
the most code size savings.
Test: test-art-host-gtest
Bug: 63756964
Change-Id: Iec770d9c1f5171288aca8329a6ca6992375101bc
diff --git a/runtime/utils.h b/runtime/utils.h
index 789498c..7402c12 100644
--- a/runtime/utils.h
+++ b/runtime/utils.h
@@ -289,6 +289,20 @@
}
}
+// Hash bytes using a relatively fast hash.
+static inline size_t HashBytes(const uint8_t* data, size_t len) {
+ size_t hash = 0x811c9dc5;
+ for (uint32_t i = 0; i < len; ++i) {
+ hash = (hash * 16777619) ^ data[i];
+ }
+ hash += hash << 13;
+ hash ^= hash >> 7;
+ hash += hash << 3;
+ hash ^= hash >> 17;
+ hash += hash << 5;
+ return hash;
+}
+
} // namespace art
#endif // ART_RUNTIME_UTILS_H_