-
Notifications
You must be signed in to change notification settings - Fork 16
Add poll_oneoff
for POSIX hosts to WASI.swift
#187
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: main
Are you sure you want to change the base?
Conversation
The change declares a clock subscription type in according with the WebAssembly System Interface standard ABI, which is required for testing clocks and timers in Embedded Swift for WebAssembly. The ABI for this type is specified publicly in corresponding ABI documentation: https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#subscription_clock rdar://149935761
Testing Swift Concurrency with WebAssembly System Interface requires a missing `subscription` record per the corresponding standard specification: https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#-subscription-record This change adds a subscription union type, with the ABI described in this standard document.
To test Swift Concurrency with WebAssembly System Interface, an Event API is missing from WasmKit runtime, as specified in the standard specification https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#-event-record This change adds Event with the ABI as prescribed in the standard, allowing Swift Concurrency tests to utilize timer events.
Testing Swift Concurrency for WebAssembly requires presence of `epoll_oneoff`, which is absent in WasmKit. This change provides a stub according to the ABI specified in WebAssembly System Interface standard https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#poll_oneoff The stub has no concrete implementation, but provides placeholders that map to clock and file descriptor value that can be polled as specified in the standard.
To support Swift Concurrency tested in WebAssembly System Interface environment, `Clock` and `Subscription` types should conform to `GuestPointee` types, which provides size and alignment for correct ABI implementation. This fixes current build issues, where these types didn't have correct size and alignment specified.
Types like Clock, Subscription, and Event that cover WebAssembly System Interface should have their size, alignment, and load/store functionality tested for conformance with the ABI specified in the standard https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#-subscription_clock-record This change adds corresponding tests that cover this.
Implementation of `poll_oneoff` in WebAssembly System Interface standard (https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#poll_oneoff) can be approximated in operating systems implementing POSIX standard with `poll` (https://www.unix.com/man_page/posix/2/ppoll). This change adds such approximation, converting clock subscriptions using nanoseconds to milliseconds, while mapping file descriptor read and write subscriptions to `POLLIN` and `POLLOUT` events in POSIX.
Implementation for POSIX platforms of `poll_oneoff` syscall from WebAssembly System Interface standard should have corresponding tests in WasmKit. This change wires it up via `WASIBridgeToHost` for testability, which then allows exercising clock subscription events in a simple test. Hardcoded test constants for pointer offsets are also generalized to make the test more readable.
poll_oneoff
ABI types to WASI.swift
poll_oneoff
for POSIX to WASI.swift
poll_oneoff
for POSIX to WASI.swift
poll_oneoff
for POSIX hosts to WASI.swift
Did we bump up the minimum supposed macOS version in the Swift OSS toolchain? |
For macOS it's now the same as in SwiftPM https://github.com/swiftlang/swift-package-manager/blob/d8bc782bbb84012f3cdff97a4a2afed9029cda25/Package.swift#L133 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update wasi-testsuite and ensure that https://github.com/WebAssembly/wasi-testsuite/blob/main/tests/rust/src/bin/poll_oneoff_stdio.rs integration test passes. I think we need to write back events buffer and also check error after poll
library call.
Testing Swift Concurrency for WebAssembly requires presence of
poll_oneoff
, which is absent in WasmKit. This change provides an implementation for POSIX hosts according to the ABI specified in WebAssembly System Interface standard https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#poll_oneoffrdar://149935761