Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: swiftwasm/WasmKit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: swiftwasm/WasmKit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: maxd/wasi-subscription
Choose a head ref
  • 18 commits
  • 7 files changed
  • 2 contributors

Commits on Jul 21, 2025

  1. Add Clock subscription type to WASIAbi

    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
    MaxDesiatov committed Jul 21, 2025
    Configuration menu
    Copy the full SHA
    af360f6 View commit details
    Browse the repository at this point in the history
  2. Add Subscription type to WASIAbi

    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.
    MaxDesiatov committed Jul 21, 2025
    Configuration menu
    Copy the full SHA
    04a14b4 View commit details
    Browse the repository at this point in the history
  3. Add Event type to WASIAbi

    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.
    MaxDesiatov committed Jul 21, 2025
    Configuration menu
    Copy the full SHA
    b5e0a7e View commit details
    Browse the repository at this point in the history
  4. Add poll_oneoff stub with new ABI types

    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.
    MaxDesiatov committed Jul 21, 2025
    Configuration menu
    Copy the full SHA
    5834118 View commit details
    Browse the repository at this point in the history
  5. Add Equatable and GuestPointee conformances

    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.
    MaxDesiatov committed Jul 21, 2025
    Configuration menu
    Copy the full SHA
    2b9f0a8 View commit details
    Browse the repository at this point in the history
  6. 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.
    MaxDesiatov committed Jul 21, 2025
    Configuration menu
    Copy the full SHA
    5f11678 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    0a1bb92 View commit details
    Browse the repository at this point in the history
  8. Add Poll.swift

    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.
    MaxDesiatov committed Jul 21, 2025
    Configuration menu
    Copy the full SHA
    df29b59 View commit details
    Browse the repository at this point in the history
  9. Add a test for poll_oneoff

    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.
    MaxDesiatov committed Jul 21, 2025
    Configuration menu
    Copy the full SHA
    5a5dce7 View commit details
    Browse the repository at this point in the history
  10. Fix formatting

    MaxDesiatov committed Jul 21, 2025
    Configuration menu
    Copy the full SHA
    eaff0f1 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    3cde639 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    fbbabb4 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    5c288db View commit details
    Browse the repository at this point in the history
  14. 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.
    MaxDesiatov committed Jul 21, 2025
    Configuration menu
    Copy the full SHA
    acda030 View commit details
    Browse the repository at this point in the history
  15. Fix errno to use UInt16 per the WASI p1 spec

    Per 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.
    MaxDesiatov committed Jul 21, 2025
    Configuration menu
    Copy the full SHA
    95a0d1b View commit details
    Browse the repository at this point in the history
  16. Fix errno backed by UInt16

    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.
    MaxDesiatov committed Jul 21, 2025
    Configuration menu
    Copy the full SHA
    b1c8211 View commit details
    Browse the repository at this point in the history
  17. 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.
    MaxDesiatov committed Jul 21, 2025
    Configuration menu
    Copy the full SHA
    a0594e6 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    b4ebe76 View commit details
    Browse the repository at this point in the history
Loading