From 66c9df1ed77f9da986dcf87f6b9bc1a2e86c3385 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Tue, 16 Jan 2018 14:45:20 -0800 Subject: 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 --- runtime/utils.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'runtime/utils.h') diff --git a/runtime/utils.h b/runtime/utils.h index 789498ce09..7402c12280 100644 --- a/runtime/utils.h +++ b/runtime/utils.h @@ -289,6 +289,20 @@ static inline void CheckedCall(const Func& function, const char* what, Args... a } } +// 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_ -- cgit v1.2.3-59-g8ed1b