3 ms·
Whats wasm32 (vs just normal wasm)?
by hwers 4y ago
Whats wasm32 (vs just normal wasm)?
- lioeters 4y agowasm32 uses 32-bit pointers for memory addresses, instead of 64 (wasm64). > Why have wasm32 and wasm64, instead of just using 8 bytes for storing pointers? > A great number of applications don’t ever need as much as 4 GiB of memory. Forcing all these applications to use 8 bytes for every pointer they store would significantly increase the amount of memory they require, and decrease their effective utilization of important hardware resources such as cache and memory bandwidth. > The motivations and performance effects here should be essentially the same as those that motivated the development of the x32 ABI for Linux. > Even Knuth found it worthwhile to give us his opinion on this issue at point, a flame about 64-bit pointers. https://webassembly.org/docs/faq/#why-have-wasm32-and-wasm64-instead-of-just-using-8-bytes-for-storing-pointers https://webassembly.org/docs/faq/#why-have-wasm32-and-wasm64... --- > The x32 ABI is an application binary interface (ABI) and one of the interfaces of the Linux kernel. It allows programs to take advantage of the benefits of x86-64 instruction set..while using 32-bit pointers and thus avoiding the overhead of 64-bit pointers. https://en.wikipedia.org/wiki/X32_ABI https://en.wikipedia.org/wiki/X32_ABI --- > It is absolutely idiotic to have 64-bit pointers when I compile a program that uses less than 4 gigabytes of RAM. When such pointer values appear inside a struct, they not only waste half the memory, they effectively throw away half of the cache. https://www-cs-faculty.stanford.edu/~knuth/news08.html https://www-cs-faculty.stanford.edu/~knuth/news08.html
- astrange 4y agoSorry Knuth, but 64-bit pointers are good for security (PAC and guard regions), performance (tagged pointers), and it saves memory to not have 32 and 64 bit versions of the system libraries. It can be good to store indexes instead of pointers if you want to shrink a field though.