Live data from Hacker News

Up to 4GB of Memory in WebAssembly

v8.dev

11–20 of 86 posts

Re: Up to 4GB of Memory in WebAssembly

#11
post #10

So, will we need to have 4GB of ram to run Javascripts now? :)

Taken seriously: RAM often does get offloaded to disk as needed, so realistically this changes nothing in terms of specs needed to handle what's in memory.

Taken less seriously: Do you not already need this just to run JIRA on Chrome? Or apps on Electron, generally?

Re: Up to 4GB of Memory in WebAssembly

#12

Why do we need to support stating the length ~~"2^32+1"~~ 2^32?

It would be "2^32", not "2^32+1". 2^32 isn't representable in a 32-bit integer, the same way 256 isn't representable in an 8-bit integer--the maximum is 2^8-1, or 255.

But the argument that they need to represent 2^32 and therefore that's why they used 64-bit integers is dubious. No 32-bit WebAssembly program could ever operate on and pass an object as large as 2^32 bytes because the code and data structures for the smallest possible program would already take up more than 1 byte in that 32-bit address space.

Re: Up to 4GB of Memory in WebAssembly

#14
post #12

Why do we need to support stating the length ~~"2^32+1"~~ 2^32?

It would be "2^32", not "2^32+1". 2^32 isn't representable in a 32-bit integer, the same way 256 isn't representable in an 8-bit integer--the maximum is 2^8-1, or 255. But the argument that they need to represent 2^32 and therefore that's why they used 64-bit integers is dubious. No 32-bit WebAssembly program could ever operate on and pass an object as large as 2^32 bytes because the code and data structures for the…

As is mentioned in the article, u64 was used to future proof for wasm's upcoming memory64 type: https://github.com/WebAssembly/memory64/blob/master/proposal...

Re: Up to 4GB of Memory in WebAssembly

#15
post #14
post #12

Earlier quoted context omitted.

It would be "2^32", not "2^32+1". 2^32 isn't representable in a 32-bit integer, the same way 256 isn't representable in an 8-bit integer--the maximum is 2^8-1, or 255. But the argument that they need to represent 2^32 and therefore that's why they used 64-bit integers is dubious. No 32-bit WebAssembly program could ever operate on and pass an object as large as 2^32 bytes because the code and data structures for the…

As is mentioned in the article, u64 was used to future proof for wasm's upcoming memory64 type: https://github.com/WebAssembly/memory64/blob/master/proposal...

Yeah, so what are they going to do when they then claim to need to to represent the length 2^64?

Re: Up to 4GB of Memory in WebAssembly

#16
I wish new platforms would embrace 64 bit as the default. C and C++ for all common platforms use 32 bit literals and prefer 32 bit operations (char * short => int). Rust made a similar mistake. Java arrays use 32 bit subscripts, etc... I don't have a single computer (including my phone) using 32 bit pointers, but integers are stuck in the late 80s. (We already had 64 bit DEC alphas in the early 90s)

For a web page, 4 gig seems like a courtesy limitation to users, but that should be enforced by the browser refusing to suck up the entire computer rather than the language being unable to. I routinely write (non-web) applications which use arrays larger than 4 gigasamples.

Re: Up to 4GB of Memory in WebAssembly

#18
post #16

I wish new platforms would embrace 64 bit as the default. C and C++ for all common platforms use 32 bit literals and prefer 32 bit operations (char * short => int). Rust made a similar mistake. Java arrays use 32 bit subscripts, etc... I don't have a single computer (including my phone) using 32 bit pointers, but integers are stuck in the late 80s. (We already had 64 bit DEC alphas in the early 90s) For a web page, 4…

I'm pretty sure rust uses usize, which is 64 bits on modern architectures.

Re: Up to 4GB of Memory in WebAssembly

#19
post #16

I wish new platforms would embrace 64 bit as the default. C and C++ for all common platforms use 32 bit literals and prefer 32 bit operations (char * short => int). Rust made a similar mistake. Java arrays use 32 bit subscripts, etc... I don't have a single computer (including my phone) using 32 bit pointers, but integers are stuck in the late 80s. (We already had 64 bit DEC alphas in the early 90s) For a web page, 4…

I'm pretty sure rust uses usize, which is 64 bits on modern architectures.

Rust literals will infer their type from context if possible. Otherwise I believe the default is i32. There are also literal suffixes. So you can 999u64 of 999.02f64 if you want.

Re: Up to 4GB of Memory in WebAssembly

#20
post #16

I wish new platforms would embrace 64 bit as the default. C and C++ for all common platforms use 32 bit literals and prefer 32 bit operations (char * short => int). Rust made a similar mistake. Java arrays use 32 bit subscripts, etc... I don't have a single computer (including my phone) using 32 bit pointers, but integers are stuck in the late 80s. (We already had 64 bit DEC alphas in the early 90s) For a web page, 4…

I'm pretty sure rust uses usize, which is 64 bits on modern architectures.

usize can even be 16 bits, when targeting small microcontrollers and vintage architectures.
Post reply on HN