Hello Andreas and Jakob,
Thanks for all your onformation, but I still have some questions.
Is keep uint32 values "sign-extended"(extend bit 31 into bits 63 through 32) or `ChangeUint32ToUint64` without zero-extension that may lead to security bugs? If it's the former, could you give more details? Thanks!
> There isn't really such a thing as "sign-extending a uint", as "uint" means "unsigned int". Zero-extension is the only extension that makes sense for uint32.
Sorry for my lax use of terminology. "sign-extending a uint" means extending the 32-bit value's bit 31 into bits 63 through 32, it's the way MIPS64 and probably RV64I handle both signed and unsigned 32-bit values.
Since MIPS64 don't have real unsigned 32-bit instructions, AFAIK, most of it's 32-bit instructions like add/addu/sub/subu/div/mul require the input values are "sign-extended" and the output wil be sign-extended too.
> I think we zero-extend most 32-bit values in V8, however there are a few cases where we must explicitly sign-extend: specifically when a (signed) int32 will be added to a 64-bit value, such as for address+offset computations.
> We do rely on 32-bit values being zero-extended in some places, so it's important to keep those tests working.
Will 32-bit values be added to 64-bit values without promotion to 64-bit? I think if the operations are all between 32-bit values, then the "sign-exntension" won't cause problems?
Besides, I thought only MIPS64 and RV64 care about this issue, X64 and ARM64 have full 32-bit registers support, why do they still rely on the zero-extension? Thanks!
Thanks,
Zhao Jiazhong