Closed orangeC23 closed 1 year ago
8 bytes is 64 bits. 4 bytes is 32 bits.
When passed by value, integers smaller than 32 bits are put in an i32, 64 bit integers are put in i64, and f32 and f64 are only used for floats of that size. When passed by reference, i32 is used as a pointer into linear memory.
The witx
crate contains code to calculate the size and alignment of members. WASI was first specified as a C header file, and then witx was created to encode those definitions in a more easily machine-readable manner. Therefore, witx type layout, and calling convention (i.e. whether values are passed as immediates or as references into memory) are defined by clang's wasm32-wasi ABI. https://github.com/WebAssembly/WASI/blob/main/legacy/tools/witx/src/layout.rs contains the layout calculations, which we tested at length to match clang's.
Thanks for your answer !
Could you please answer my questions?
(1)In the documentation :https://github.com/WebAssembly/WASI/blob/0ba0c5e2e37625ca5a6d3e4255a998dfaa3efc52/phases/snapshot/docs.md
There are variable types in WASI, including U32, variant,record, etc. How to map these variable types to Wasm variable types(i32,i64,f32,f64)?
(2)
For example, in the documentation https://github.com/WebAssembly/WASI/blob/0ba0c5e2e37625ca5a6d3e4255a998dfaa3efc52/phases/snapshot/docs.md, the size of variable "size" is 8, which is less than 32. Does it means the mapping variable is i32 in WASM binaries?