Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasi 64 support by adding _wasm64 API sets #44

Closed
trcrsired opened this issue Dec 12, 2023 · 9 comments
Closed

wasi 64 support by adding _wasm64 API sets #44

trcrsired opened this issue Dec 12, 2023 · 9 comments

Comments

@trcrsired
Copy link

See:
WebAssembly/wasi-libc#444

I think the wasi API can have its _i64 version to implement ptr for 64 bit instead of making the API the same. This will make things much easier to support for VM that needs to run for both 32 and 64.

We do it transparently in the wasi-libc so vm does not need to change anything.

@trcrsired trcrsired changed the title wasi 64 support wasi 64 support by adding _i64 API sets Dec 12, 2023
@sbc100
Copy link
Member

sbc100 commented Dec 12, 2023

Maybe _wasm64 would be more descriptive?

Also maybe the wasm64 should go be part of the common prefix rather than suffixed?

@yamt
Copy link
Contributor

yamt commented Dec 13, 2023

This will make things much easier to support for VM that needs to run for both 32 and 64.

can you give me an example where it's much easier?
i suppose the functions affected by wasm64 usually take i64 instead of i32 and thus have different function types already. it isn't obvious to me why using different names can help implementations.

@trcrsired
Copy link
Author

trcrsired commented Dec 14, 2023

This will make things much easier to support for VM that needs to run for both 32 and 64.

can you give me an example where it's much easier? i suppose the functions affected by wasm64 usually take i64 instead of i32 and thus have different function types already. it isn't obvious to me why using different names can help implementations.

I am currently assisting in the integration of a 64-bit API into an existing project VM named WAVM. This VM automatically generates function signatures based on their definitions. Previously, I had to handle interfacing with LLVM, which was cumbersome. However, by simply adding "_i64" postfix APIs, I no longer need to deal with that complexity.
https://github.com/trcrsired/WAVM/blob/c63f13d60ca33d6436360a223d6aefb0fdd02731/Lib/WASI/WASIFile.cpp#L238

Also, most of the entire tooling systems are built based on assuming address and size being i32. By adding new API names to 64 bit only would not break any existing tools but reusing them. (Well, you just add new APIs) It just makes it much easier to implement.

By the way, if you want to run wasm32 and wasm64 apps in a VM like this, new APIs could do them both easily.

Maybe _wasm64 would be more descriptive?

Also maybe the wasm64 should go be part of the common prefix rather than suffixed?

Maybe.

@trcrsired
Copy link
Author

Changed to wasm64

trcrsired/wasi-libc@c889960

@trcrsired trcrsired changed the title wasi 64 support by adding _i64 API sets wasi 64 support by adding _wasm64 API sets Dec 14, 2023
@yamt
Copy link
Contributor

yamt commented Dec 15, 2023

This will make things much easier to support for VM that needs to run for both 32 and 64.

can you give me an example where it's much easier? i suppose the functions affected by wasm64 usually take i64 instead of i32 and thus have different function types already. it isn't obvious to me why using different names can help implementations.

I am currently assisting in the integration of a 64-bit API into an existing project VM named WAVM. This VM automatically generates function signatures based on their definitions. Previously, I had to handle interfacing with LLVM, which was cumbersome. However, by simply adding "_i64" postfix APIs, I no longer need to deal with that complexity. https://github.com/trcrsired/WAVM/blob/c63f13d60ca33d6436360a223d6aefb0fdd02731/Lib/WASI/WASIFile.cpp#L238

generate signatures from which definitions?
can you explain a bit for those of us who is not familiar with wavm?
do you mean it has some troubles to handle two functions with the same name but with different signatures?

Also, most of the entire tooling systems are built based on assuming address and size being i32. By adding new API names to 64 bit only would not break any existing tools but reusing them. (Well, you just add new APIs) It just makes it much easier to implement.

well, this issue is about core wasm import names, right?

my question is, what's wrong with having the following two functions with the same name?

  • 32-bit version of fd_write: (param i32 i32 i32 i32) (result i32)
  • 64-bit version of fd_write: (param i32 i64 i32 i64) (result i32)

@trcrsired
Copy link
Author

trcrsired commented Dec 15, 2023

This will make things much easier to support for VM that needs to run for both 32 and 64.

can you give me an example where it's much easier? i suppose the functions affected by wasm64 usually take i64 instead of i32 and thus have different function types already. it isn't obvious to me why using different names can help implementations.

I am currently assisting in the integration of a 64-bit API into an existing project VM named WAVM. This VM automatically generates function signatures based on their definitions. Previously, I had to handle interfacing with LLVM, which was cumbersome. However, by simply adding "_i64" postfix APIs, I no longer need to deal with that complexity. https://github.com/trcrsired/WAVM/blob/c63f13d60ca33d6436360a223d6aefb0fdd02731/Lib/WASI/WASIFile.cpp#L238

generate signatures from which definitions? can you explain a bit for those of us who is not familiar with wavm? do you mean it has some troubles to handle two functions with the same name but with different signatures?

Also, most of the entire tooling systems are built based on assuming address and size being i32. By adding new API names to 64 bit only would not break any existing tools but reusing them. (Well, you just add new APIs) It just makes it much easier to implement.

well, this issue is about core wasm import names, right?

my question is, what's wrong with having the following two functions with the same name?

  • 32-bit version of fd_write: (param i32 i32 i32 i32) (result i32)
  • 64-bit version of fd_write: (param i32 i64 i32 i64) (result i32)

yeah. Two functions with the same name are much harder to implement than just duplicating APIs. For example, try to support 32 bit and 64 bit wasm at the same time is much harder to implement. Plus existing tools are all assume address are 32 bits, they all have to be fixed which is too much work. If we duplicate the APIs for 64 bit version, these tools will still work without changing, but by adding new APIs.

@dschuff dschuff transferred this issue from WebAssembly/meetings Dec 16, 2023
@yamt
Copy link
Contributor

yamt commented Dec 16, 2023

This will make things much easier to support for VM that needs to run for both 32 and 64.

can you give me an example where it's much easier? i suppose the functions affected by wasm64 usually take i64 instead of i32 and thus have different function types already. it isn't obvious to me why using different names can help implementations.

I am currently assisting in the integration of a 64-bit API into an existing project VM named WAVM. This VM automatically generates function signatures based on their definitions. Previously, I had to handle interfacing with LLVM, which was cumbersome. However, by simply adding "_i64" postfix APIs, I no longer need to deal with that complexity. https://github.com/trcrsired/WAVM/blob/c63f13d60ca33d6436360a223d6aefb0fdd02731/Lib/WASI/WASIFile.cpp#L238

generate signatures from which definitions? can you explain a bit for those of us who is not familiar with wavm? do you mean it has some troubles to handle two functions with the same name but with different signatures?

Also, most of the entire tooling systems are built based on assuming address and size being i32. By adding new API names to 64 bit only would not break any existing tools but reusing them. (Well, you just add new APIs) It just makes it much easier to implement.

well, this issue is about core wasm import names, right?
my question is, what's wrong with having the following two functions with the same name?

  • 32-bit version of fd_write: (param i32 i32 i32 i32) (result i32)
  • 64-bit version of fd_write: (param i32 i64 i32 i64) (result i32)

yeah. Two functions with the same name are much harder to implement than just duplicating APIs. For example, try to support 32 bit and 64 bit wasm at the same time is much harder to implement.

for some reasons specific to wavm, you mean?
it isn't difficult for runtimes i'm familiar with. (wamr, toywasm)

Plus existing tools are all assume address are 32 bits, they all have to be fixed which is too much work. If we duplicate the APIs for 64 bit version, these tools will still work without changing, but by adding new APIs.

what kind of tools are you talking about, for example?

@yamt
Copy link
Contributor

yamt commented Dec 16, 2023

also, i guess function name alone is not enough to introduce 64-bit variant of wasi.
eg. what should happen if the memory is 64 bit and you use 32-bit functions, or vice versa.
eg. do you introduce 64-bit variant only for functions which take pointers? or all functions? why?

sbc100 pushed a commit that referenced this issue Jun 12, 2024
Rename new traps.wast test -> traps0.wast
@sbc100
Copy link
Member

sbc100 commented Oct 22, 2024

This seems like an issue that should be continued in the WASI repo. Closing this here since I don't think it relates to the core memory64 spec.

@sbc100 sbc100 closed this as completed Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants