Just a general question that I can't seem to find a straight answer to anywhere. My use case is to use the fst crate in a package targeting wasm. (I think) the fst crate uses u64 arithmetic pervasively, but my use case for fst would likely be okay with just u32 (I have very few destinations).
What I think I know:
According to several different articles I was able to find, such as the answer on SO, below. Using a higher bit number on a lower bit processor will lead to the entire data of that number not fitting into a single register, which (IIUC) means that computation can result in multiple machine instructions. https://stackoverflow.com/questions/28977587/is-it-ok-to-use-64bit-integers-in-a-32bit-application
Does this same performance difference exist on wasm32 while performing arithmetic with u64s? Even if the host is running on a 64bit processor?
I could imagine that the wasm runtime might make a difference, so I'm mostly concerned about how Chrome's WebAssembly runtime might perform.
Don't know too much about wasm, so let someone more knowledgable confirm, but from my understanding, wasm does have 64 bit types, so u64 arithmetic ops should compile to single wasm instructions, which I'd guess a reasonable jit on 64-bit architecture will compile to single machine instructions.
The "32" in wasm32 means that the adress space is 32-bit, and thus usize is 32-bit. So this is a little bit different than 32-bitness of, say, x86, in which both address space and registers are 32-bit.
LLVM does not make a distinction between signed and unsigned integer types, so I don't think there's such a problem. Signed and unsigned integers differ only in the instructions that manipulate values: you can ask LLVM to generate a wrapping, an unsigned non-wrapping, a signed non-wrapping add, or ask for an explicit zero extension or sign extension. This means whatever compiler happens to generate LLVM can decide (or even change!) the signedness of an integer for each individual operation it emits.
Now I'm no expert at WebAssembly, but this official-looking document asserts that this sort of sign-agnosticism of LLVM carries over to WebAssembly integer types as well. Furthermore, there seem to be two flavors, signed and unsigned, of some integer instructions, while other instructions such as addition and subtraction behave identically due to 2's complement representation of integers.
So, based on all of this, I would conclude that you absolutely can put numbers exceeding 2^63 in a wasm i64 value.