News for hackers. Stuff that matters.
Re:Wren is a small, fast, class-based concurrent scripting l... by lioeters on Monday August 29, 2022 @12:52AM (#32634914)
wasm32 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...

---

> 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

---

> 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

Re:Wren is a small, fast, class-based concurrent scripting l... by astrange on Monday August 29, 2022 @02:09AM (#32635214)
Sorry 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.