-
Notifications
You must be signed in to change notification settings - Fork 17
Comparing changes
Open a pull request
base repository: swiftwasm/WasmKit
base: main
head repository: swiftwasm/WasmKit
compare: maxd/wasi-subscription
- 18 commits
- 7 files changed
- 2 contributors
Commits on Jul 21, 2025
-
Add
Clock
subscription type toWASIAbi
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
Configuration menu - View commit details
-
Copy full SHA for af360f6 - Browse repository at this point
Copy the full SHA af360f6View commit details -
Add
Subscription
type toWASIAbi
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.
Configuration menu - View commit details
-
Copy full SHA for 04a14b4 - Browse repository at this point
Copy the full SHA 04a14b4View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for b5e0a7e - Browse repository at this point
Copy the full SHA b5e0a7eView commit details -
Add
poll_oneoff
stub with new ABI typesTesting 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.
Configuration menu - View commit details
-
Copy full SHA for 5834118 - Browse repository at this point
Copy the full SHA 5834118View commit details -
Add
Equatable
andGuestPointee
conformancesTo 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.
Configuration menu - View commit details
-
Copy full SHA for 2b9f0a8 - Browse repository at this point
Copy the full SHA 2b9f0a8View commit details -
Add tests for new ABI types memory layout
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.
Configuration menu - View commit details
-
Copy full SHA for 5f11678 - Browse repository at this point
Copy the full SHA 5f11678View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0a1bb92 - Browse repository at this point
Copy the full SHA 0a1bb92View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for df29b59 - Browse repository at this point
Copy the full SHA df29b59View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for 5a5dce7 - Browse repository at this point
Copy the full SHA 5a5dce7View commit details -
Configuration menu - View commit details
-
Copy full SHA for eaff0f1 - Browse repository at this point
Copy the full SHA eaff0f1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3cde639 - Browse repository at this point
Copy the full SHA 3cde639View commit details -
Configuration menu - View commit details
-
Copy full SHA for fbbabb4 - Browse repository at this point
Copy the full SHA fbbabb4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5c288db - Browse repository at this point
Copy the full SHA 5c288dbView commit details -
Fix incorrect subscript offset in
UnsafeGuestBufferPointer
A testsuite-conforming implementation of `poll_oneff` from WebAssembly System Interface (WASI) standard specification (https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#poll_oneoff) should write to the provided buffer of events that occurred before a given clock timeout. WasmKit in its current implementation had an issue with writing to such buffer, since offset for each element was calculated incorrectly in the `WasmTypes/GuestMemory.swift` source file. Implementation of `poll` function in `WASI/Poll.swift` now takes this buffer as an argument, accumulates user data of file descriptor polling subscriptions in `fdUserData`, while storing clock timer user data in `clockUserData`, which allows later writes to the events buffer for conformances with the test suite. Errors thrown by the host system implementation of `poll` are converted to corresponding WASI errors.
Configuration menu - View commit details
-
Copy full SHA for acda030 - Browse repository at this point
Copy the full SHA acda030View commit details -
Fix
errno
to useUInt16
per the WASI p1 specPer the WebAssembly System Interface (WASI) standard specification, size of `errno` variant is 2 bytes, which is equivalent to `UInt16` in Swift. In WasmKit it's currently specified incorrectly to `UInt32`, which leads to bugs when reading and writing `errno` values in guest memory. Corresponding uses of `WASIAbi.Errno` zero-extend value of 2 bytes to 4 bytes when returning 32-bit integers, since WebAssembly doesn't have a separate 16-bit integer type and zero-extension of narrower integers is the expected behavior. Additionally `ClockId` type specifies a fixed number of cases, disallowing unknown raw values, which could be specified in the future. This edge case is exercised in the WASI specification test suite. The change relaxes this restriction, making the implementation compliant with the test.
Configuration menu - View commit details
-
Copy full SHA for 95a0d1b - Browse repository at this point
Copy the full SHA 95a0d1bView commit details -
With `WASIAbi.Errno` type set to 16-bit (2 bytes) width in WasmKit per WebAssembly System Interface specification (https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#errno), corresponding uses need to be updated to zero-extend result value to 32-bit, which is the standard behavior in absence of a built-in 16-bit integer type in WebAssembly.
Configuration menu - View commit details
-
Copy full SHA for b1c8211 - Browse repository at this point
Copy the full SHA b1c8211View commit details -
Return number of events in
poll_oneoff
With `WASIAbi.Errno` type set to 16-bit (2 bytes) width in WasmKit per WebAssembly System Interface specification (https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#errno), corresponding uses need to be updated to zero-extend result value to 32-bit, which is the standard behavior in absence of a built-in 16-bit integer type in WebAssembly. Additionally for wasi-testsuite compatibility, WasmKit should return the number of events occurred in the span of `poll_oneoff` call, not the number of subscription that were passed to it.
Configuration menu - View commit details
-
Copy full SHA for a0594e6 - Browse repository at this point
Copy the full SHA a0594e6View commit details -
Configuration menu - View commit details
-
Copy full SHA for b4ebe76 - Browse repository at this point
Copy the full SHA b4ebe76View commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff main...maxd/wasi-subscription