WebAssembly / WASI

WebAssembly System Interface
Other
4.84k stars 251 forks source link

WASI 64 #566

Open trcrsired opened 11 months ago

trcrsired commented 11 months ago

I am working on creating the wasi64 interface. Put an issue here so we can have a discussion.

https://github.com/WebAssembly/wasi-libc/pull/444

cpetig commented 10 months ago

As a related topic I really miss a way to express size_t in WIT/WASI, e.g. like "(un)signed-pointer" or "sptr" mapping to i32 or i64 depending on the target architecture.

A 32bit entity with no unnecessary overhead for wasm32, but flexible enough for a 64bit pointer in wasm64 where it is needed. (To be honest this probably feels unnecessary as long as you only work with wasm32 targets, my strongest motivation stems from also using WIT for native application interfaces)

This is most felt in the wasi-thread implementation for wasm64 (part of your patch) where the code doesn't match the witx definition.

PS: I searched for any discussion of this topic in the archives, but did only find posts predating wasm64 advancing to phase 3. And https://github.com/WebAssembly/memory64/issues/43 indicates that there is some work left before progressing to phase 4.

loganek commented 8 months ago

Based on the PR there's some ambiguity around naming nad potential other concerns; I'm going to prepare a few slides and discuss the concerns with the WASI subgroup in the meeting: https://github.com/WebAssembly/meetings/pull/1479

cpetig commented 8 months ago

In the meantime I learned that there are architectures where intptr_t and size_t have different size, but that might be out of scope for WIT, even though I wouldn't mind making this distinction.

E.g. see https://stackoverflow.com/questions/1464174/size-t-vs-uintptr-t

So signed-pointer and signed-size would be the long names, perhaps the shorter pointer and size and uptr and usize look more elegant?

sunfishcode commented 8 months ago

A major concern here is maintenance. wasi-libc maintenance resources are not abundant right now, and adding another dimension of targets creates more work for everyone. And the more work we do extending Preview 1, as proposed here, the more work it takes to transition to Preview 2.

trcrsired commented 7 months ago

In the meantime I learned that there are architectures where intptr_t and size_t have different size, but that might be out of scope for WIT, even though I wouldn't mind making this distinction.

E.g. see https://stackoverflow.com/questions/1464174/size-t-vs-uintptr-t

So signed-pointer and signed-size would be the long names, perhaps the shorter pointer and size and uptr and usize look more elegant?

on wasm it does not matter. Also, i do not think you should try to make wasm support these wierd architectures, because clearly wasm does not support things like i24, it only supports i8,i16,i32,i64. there are no i24 for example. So wasm only supports sizeof(size_t) == sizeof(uintptr_t) == sizeof(void*)

i did changed that to uintptr_t and size_t, but wasi folks do not want to make that change. it does not matter either.

cpetig commented 7 months ago

I just found Luke proposing idxtype from the memory64 spec in 2022 at https://github.com/WebAssembly/component-model/issues/22#issuecomment-1097203394 - so perhaps this name could become consensus.