diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-09-12 11:28:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-12 11:28:18 -0700 |
commit | 6977feb0f371c31f35ab8b1304c97dc3ac155d92 (patch) | |
tree | 906215a5d915a49ff8a3e96e86f16ed26bf6c117 /src/support | |
parent | 72f72c8b4a005bbd728d7246f87b9d347c2a775f (diff) | |
download | binaryen-6977feb0f371c31f35ab8b1304c97dc3ac155d92.tar.gz binaryen-6977feb0f371c31f35ab8b1304c97dc3ac155d92.tar.bz2 binaryen-6977feb0f371c31f35ab8b1304c97dc3ac155d92.zip |
Const hoisting (#1176)
A pass that hoists repeating constants to a local, and replaces their uses with a get of that local. This can reduce binary size, but can also *increase* gzip size, so it's mostly for experimentation and not used by default.
Diffstat (limited to 'src/support')
-rw-r--r-- | src/support/hash.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/support/hash.h b/src/support/hash.h index e2d393d25..5ee3b8a3d 100644 --- a/src/support/hash.h +++ b/src/support/hash.h @@ -17,6 +17,7 @@ #ifndef wasm_support_hash_h #define wasm_support_hash_h +#include <functional> #include <stdint.h> namespace wasm { @@ -34,6 +35,10 @@ inline uint32_t rehash(uint32_t x, uint32_t y) { // see http://www.cse.yorku.ca/ return hash; } +inline size_t rehash(uint64_t x, uint64_t y) { // see boost and https://stackoverflow.com/a/2595226/1176841 + return x ^ (y + 0x9e3779b9 + (x << 6) + (x >> 2)); +} + } // namespace wasm #endif // wasm_support_hash_h |