klapaucius / vector-hashtables

Other
33 stars 5 forks source link

Add wasm32 support #20

Closed andy0130tw closed 11 months ago

andy0130tw commented 12 months ago

In my attempt to port Agda to WebAssembly via the official WASM backend, I notice that the hash table always hangs or makes illegal memory access. Upon further investigation, it turns out that there is actually a warning during compiling:

src-gen/Data/Vector/Hashtables/Internal/Mask.hs:10:8: warning: [GHC-97441] [-Woverflowed-literals]
    Literal 9223372036854775807 is out of the Int range -2147483648..2147483647
   |
10 | mask = 0x7FFFFFFFFFFFFFFF :: Int
   |        ^^^^^^^^^^^^^^^^^^

Since wasm32 has only 32-bit address space, selecting the 64-bit mask constant apparently causes some undefined behavior. This patch adds an extra condition for wasm32 to use the 32-bit mask.

ulysses4ever commented 11 months ago

Should we do a release? @swamp-agr?

swamp-agr commented 11 months ago

Please find release on Hackage: https://hackage.haskell.org/package/vector-hashtables-0.1.1.4