Skip to content

Commit 9922409

Browse files
Merge remote-tracking branch 'origin/next' into feat/c-api
2 parents 17aa112 + 05389cf commit 9922409

106 files changed

Lines changed: 3396 additions & 2034 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

β€Ž.cargo/config.tomlβ€Ž

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
[alias]
2-
version-dev="workspaces version --no-git-commit --force tinywasm*"
3-
test-wasm-1="test --package tinywasm --test test-wasm-1 --release"
4-
test-wasm-2="test --package tinywasm --test test-wasm-2 --release"
5-
test-wasm-3="test --package tinywasm --test test-wasm-3 --release"
6-
test-wast="test --package tinywasm --test test-wast"
7-
test-wasm-custom="test --package tinywasm --test test-wasm-custom --release"
8-
cli="run -p tinywasm-cli --bin tinywasm --release --"
9-
doom="run --manifest-path ./examples/doom/Cargo.toml --release --"
2+
bench-suite = "bench -p bench --bench suite --"
3+
cli = "run -p tinywasm-cli --bin tinywasm --release --"
4+
coremark = "run --release -p bench -- coremark"
5+
doom = "run --manifest-path ./examples/doom/Cargo.toml --release --"
6+
test-wasm-1 = "test --package tinywasm --test test-wasm-1 --release"
7+
test-wasm-2 = "test --package tinywasm --test test-wasm-2 --release"
8+
test-wasm-3 = "test --package tinywasm --test test-wasm-3 --release"
9+
test-wasm-custom = "test --package tinywasm --test test-wasm-custom --release"
10+
test-wast = "test --package tinywasm --test test-wast"
11+
version-dev = "workspaces version --no-git-commit --force tinywasm*"
1012

1113
[target.x86_64-unknown-linux-gnu]
12-
rustflags=["-C", "target-cpu=x86-64-v3"]
14+
rustflags = ["-C", "target-cpu=x86-64-v3"]

β€Ž.github/workflows/audit.yamlβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
security-events: write
3030
uses: google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@a345acffa64b0eaede81a3d9aae6141214d9c8fc # v2.6.0
3131
with:
32-
runs-on: ubuntu-24.04
32+
runs-on: ubuntu-26.04
3333
upload-sarif: false
3434
scan-args: --lockfile=./Cargo.lock
3535

@@ -41,6 +41,6 @@ jobs:
4141
security-events: write
4242
uses: google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@a345acffa64b0eaede81a3d9aae6141214d9c8fc # v2.6.0
4343
with:
44-
runs-on: ubuntu-24.04
44+
runs-on: ubuntu-26.04
4545
fail-on-vuln: false
4646
scan-args: --lockfile=./Cargo.lock

β€Ž.github/workflows/release.yamlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
if-no-files-found: error
7272

7373
publish:
74-
runs-on: ubuntu-latest
74+
runs-on: ubuntu-26.04
7575
environment: release
7676
permissions:
7777
id-token: write

β€Ž.github/workflows/test.yamlβ€Ž

Lines changed: 36 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -28,78 +28,55 @@ jobs:
2828
- run: make -C crates/c-api test
2929
- run: make -C crates/c-api test TINYWASM_C_API_PREFIX=test_ TARGET_DIR=../../target/c-api-prefixed
3030

31-
build-wasm:
32-
name: Build wasm
33-
runs-on: ubuntu-latest
34-
steps:
35-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
36-
with:
37-
submodules: true
38-
persist-credentials: false
39-
- name: Install Rust toolchain
40-
uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2.0.0
41-
with:
42-
toolchain: nightly
43-
components: rust-src
44-
rustflags: ""
45-
target: wasm32-unknown-unknown
46-
- name: Install Binaryen
47-
run: |
48-
BINARYEN_VERSION=version_129
49-
BINARYEN_DIR="binaryen-${BINARYEN_VERSION}"
50-
BINARYEN_ARCHIVE="${BINARYEN_DIR}-x86_64-linux.tar.gz"
51-
curl -L "https://github.com/WebAssembly/binaryen/releases/download/${BINARYEN_VERSION}/${BINARYEN_ARCHIVE}" -o "/tmp/${BINARYEN_ARCHIVE}"
52-
echo "50b9fa62b9abea752da92ec57e0c555fee578760cd237c40107957715d2976ba /tmp/${BINARYEN_ARCHIVE}" | sha256sum -c -
53-
tar -xzf "/tmp/${BINARYEN_ARCHIVE}" -C /tmp
54-
sudo install "/tmp/${BINARYEN_DIR}/bin/wasm-opt" /usr/local/bin/wasm-opt
55-
- name: Install WABT
56-
run: sudo apt-get install -y wabt
57-
- name: Build wasm
58-
run: ./examples/rust/build.sh
59-
- name: Save artifacts
60-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
61-
with:
62-
name: wasm
63-
path: examples/rust/out
64-
6531
run-tests:
66-
needs: build-wasm
6732
strategy:
6833
matrix:
6934
include:
70-
- os: ubuntu-latest
35+
- os: ubuntu-26.04
7136
rust: stable
7237
name: "Linux x86 (stable)"
73-
- os: ubuntu-latest
38+
target: x86_64-unknown-linux-gnu
39+
- os: ubuntu-26.04
7440
rust: nightly
7541
name: "Linux x86 (nightly)"
76-
- os: ubuntu-latest
42+
target: x86_64-unknown-linux-gnu
43+
- os: ubuntu-26.04
7744
rust: nightly
7845
name: "Linux x86 (nightly tail calls)"
46+
target: x86_64-unknown-linux-gnu
7947
args: "--features tinywasm/nightly-tail-calls"
80-
- os: ubuntu-latest
48+
- os: ubuntu-26.04
8149
rust: stable
8250
name: "Linux x86 (stable, no default features)"
51+
target: x86_64-unknown-linux-gnu
8352
args: "--no-default-features"
84-
- os: ubuntu-latest
53+
- os: ubuntu-26.04
8554
rust: nightly
8655
name: "Linux x86 (nightly, no default features)"
56+
target: x86_64-unknown-linux-gnu
8757
args: "--no-default-features"
88-
- os: ubuntu-latest
58+
- os: ubuntu-26.04
8959
rust: nightly
9060
name: "Linux x86 (nightly tail calls, no default features)"
61+
target: x86_64-unknown-linux-gnu
9162
args: "--no-default-features --features tinywasm/nightly-tail-calls"
92-
- os: macos-14
63+
- os: macos-26
9364
rust: stable
9465
name: "macOS arm64 (Apple M1)"
95-
- os: ubuntu-latest
66+
target: aarch64-apple-darwin
67+
- os: windows-2025
68+
rust: stable
69+
name: "Windows x86_64"
70+
target: x86_64-pc-windows-msvc
71+
- os: ubuntu-26.04-arm
9672
rust: stable
9773
name: "Linux arm64"
9874
target: aarch64-unknown-linux-gnu
99-
- os: ubuntu-latest
75+
- os: ubuntu-26.04-arm
10076
rust: stable
10177
name: "Linux armv7"
10278
target: armv7-unknown-linux-gnueabihf
79+
args: "--release"
10380

10481
name: Run tests on ${{ matrix.name }}
10582
runs-on: ${{ matrix.os }}
@@ -114,28 +91,25 @@ jobs:
11491
uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2.0.0
11592
with:
11693
toolchain: ${{ matrix.rust }}
94+
target: ${{ matrix.target }}
11795
rustflags: ""
96+
build-warnings: warn
11897
components: rustfmt, clippy
119-
if: matrix.target == ''
12098

121-
- name: Load wasm
122-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
123-
with:
124-
name: wasm
125-
path: examples/rust/out
99+
- name: Install armv7 tools
100+
run: sudo apt-get update && sudo apt-get install -y gcc-arm-linux-gnueabihf qemu-user
101+
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
126102

127103
- name: Run tests
128-
run: cargo test --workspace ${{ matrix.args }} && cargo test --workspace ${{ matrix.args }} --examples
129-
if: matrix.target == ''
104+
run: cargo test --workspace --target ${{ matrix.target }} ${{ matrix.args }}
105+
env:
106+
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
107+
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER: qemu-arm -L /usr/arm-linux-gnueabihf
130108

131-
- name: Run clippy
132-
run: cargo clippy --workspace ${{ matrix.args }}
133-
if: matrix.target == ''
109+
- name: Run examples
110+
run: cargo test --workspace --target ${{ matrix.target }} ${{ matrix.args }} --examples
111+
if: matrix.target != 'armv7-unknown-linux-gnueabihf'
134112

135-
- name: Run tests (${{ matrix.target }})
136-
uses: houseabsolute/actions-rust-cross@21b0f18dc621b25bfae556ff2791fca4173121e8 # v1.0.8
137-
with:
138-
command: test
139-
target: ${{ matrix.target }}
140-
toolchain: ${{ matrix.rust }}
141-
if: matrix.target != ''
113+
- name: Run clippy
114+
run: cargo clippy --workspace --target ${{ matrix.target }} ${{ matrix.args }}
115+
if: matrix.target != 'armv7-unknown-linux-gnueabihf'

β€Ž.gitignoreβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/target
2+
/crates/bench/guest/target
23
notes.md
34
examples/*/out/*
45
examples/*/target

β€ŽCHANGELOG.mdβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Added WebAssembly threads support, including atomic wait/notify and cross-store shared memory with `MemoryShared`.
1213
- Added new `Memory::data` and `Memory::data_mut` methods for direct access to linear memory.
1314
- Added several internal methods to support a future c-api crate
1415

β€ŽCONTRIBUTING.mdβ€Ž

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cargo fmt --all -- --check
2323
cargo clippy --workspace
2424
cargo test --workspace
2525
cargo run --example basic
26-
cargo bench --bench tinywasm
26+
cargo bench-suite
2727
```
2828

2929
WebAssembly test commands:
@@ -38,18 +38,11 @@ cargo test-wast crates/tinywasm/tests/wasm-custom/table-basics.wast
3838

3939
Set `RUST_LOG=debug` when running `cargo test-wast` to see executor debug logs.
4040

41-
The `rust` example requires the `wasm32-unknown-unknown` target, the `rust-src` component, [Binaryen](https://github.com/WebAssembly/binaryen), and [WABT](https://github.com/WebAssembly/wabt):
42-
43-
```bash
44-
./examples/rust/build.sh
45-
cargo run --example rust -- hello
46-
```
47-
4841
You can use [samply](https://github.com/mstange/samply/) for profiling:
4942

5043
```bash
5144
cargo install --locked samply
52-
samply record -- cargo run --profile samply --example rust -- tinywasm
45+
samply record -- cargo bench-suite execute/nested_tinywasm
5346
```
5447

5548
Keep changes focused and external dependencies to a minimum. Update public documentation, the README, and the unreleased changelog when applicable.

β€ŽCargo.lockβ€Ž

Lines changed: 20 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€ŽCargo.tomlβ€Ž

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,9 @@ unused_dependencies = "allow" # false-positive on libm
4545
[workspace.lints.rust]
4646
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(rust_analyzer)"] }
4747

48-
[[example]]
49-
name = "rust"
50-
test = false
51-
52-
[[bench]]
53-
harness = false
54-
name = "argon2id"
55-
56-
[[bench]]
57-
harness = false
58-
name = "fibonacci"
59-
60-
[[bench]]
61-
harness = false
62-
name = "tinywasm"
63-
64-
[[bench]]
65-
harness = false
66-
name = "tinywasm_modes"
67-
6848
[dev-dependencies]
6949
anyhow.workspace = true
70-
criterion.workspace = true
71-
pretty_env_logger.workspace = true
72-
tinywasm = { path = "crates/tinywasm", features = ["state"] }
73-
tinywasm-parser.workspace = true
50+
tinywasm = { path = "crates/tinywasm", features = ["send", "state"] }
7451
tinywasm-wasi.workspace = true
7552
wat.workspace = true
7653

β€ŽREADME.mdβ€Ž

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ See its [README](./crates/c-api/README.md) for installation and usage.
5858
## Cargo Features
5959

6060
- **`full`:** Enables `archive`, `debug`, `parallel-parser`, `parser`, `state`, and `validate`. Enabled by default.
61-
- **`std`:** Enables `std` and parsing from files and streams. Enabled by default.
61+
- **`std`:** Enables parsing from files and streams, shared memory handles, and blocking atomic wait/notify across stores. Enabled by default.
6262
- **`parser`:** Enables `tinywasm-parser` and top-level parse helpers. Enabled by default.
6363
- **`validate`:** Enables WebAssembly validation while parsing. Enabled by default and configurable through [`ParserOptions`](https://docs.rs/tinywasm/latest/tinywasm/parser/struct.ParserOptions.html).
6464
- **`parallel-parser`:** Parallelizes function parsing when `std` is enabled. Enabled by default.
@@ -116,14 +116,18 @@ TinyWasm generally implements non-JavaScript core proposals at [phase 4](https:/
116116
| [**Garbage Collection**](https://github.com/WebAssembly/gc) | 🟒 | 0.11.0 |
117117
| [**Exception Handling**](https://github.com/WebAssembly/exception-handling) | 🟒 | 0.11.0 |
118118
| [**Compact Import Section**](https://github.com/WebAssembly/compact-import-section) | 🟒 | 0.11.0 |
119+
| [**Threads**](https://github.com/WebAssembly/threads) | 🚧 | next |
119120
| [**Stack Switching**](https://github.com/WebAssembly/stack-switching) | πŸŒ‘ | - |
120-
| [**Threads**](https://github.com/WebAssembly/threads) | πŸŒ‘ | - |
121121

122122
**Legend**\
123123
πŸŒ‘ -- not available\
124124
🚧 -- in development/partially supported\
125125
🟒 -- fully supported
126126

127+
## Benchmarks
128+
129+
Tinywasm includes a small benchmark suite at [`crates/bench`](crates/bench) that runs a set of WebAssembly modules and measures execution time. For comparisons with other runtimes, check out the great [wasmi-benchmarks](https://github.com/wasmi-labs/wasmi-benchmarks) repository.
130+
127131
## See Also
128132

129133
If you're looking for a WebAssembly runtime with JIT compilation, better performance or other advanced features, check out these other runtimes:

0 commit comments

Comments
Β (0)