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

Implement RFC 11: Redesigning Wasmtime's APIs #2897

Merged
merged 100 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from 96 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
9e75ec1
wip
alexcrichton May 10, 2021
80b781b
Fix another example
alexcrichton May 10, 2021
d6f6ba4
Get the C API compiling again
alexcrichton May 10, 2021
8bfe58e
more c api
alexcrichton May 10, 2021
3ec6c6a
Lots of C API working now (hopefully)
alexcrichton May 10, 2021
c800ab9
Update the bench-api crate
alexcrichton May 10, 2021
1756c6d
Comment out wasi c api for now
alexcrichton May 10, 2021
c42c355
More test updates
alexcrichton May 10, 2021
2cfc396
Get more C API working
alexcrichton May 10, 2021
2a5b3d4
More misc test fixes
alexcrichton May 10, 2021
7f636b0
doctest fixes
alexcrichton May 10, 2021
49cd225
More C working
alexcrichton May 10, 2021
00ee228
Skip 4g test on ci
alexcrichton May 11, 2021
54dbd75
Hello, yes, this is dog
alexcrichton May 11, 2021
19292f5
More updates
alexcrichton May 11, 2021
072415f
Remove duplicate example
alexcrichton May 11, 2021
6f78902
Polish off the C API
alexcrichton May 11, 2021
8492a2b
Resolve some TODO
alexcrichton May 11, 2021
f013f59
The old backend is... old... right?
alexcrichton May 11, 2021
fdff3b9
Fix a uffd test
alexcrichton May 11, 2021
7d9a2b5
Remove unused import
alexcrichton May 11, 2021
b5d8c67
Update tarball creation
alexcrichton May 11, 2021
391d9b1
Update the book docs
alexcrichton May 11, 2021
3beb706
Try to get docs working
alexcrichton May 11, 2021
3860b2d
Checkout code for c api
alexcrichton May 11, 2021
d09f9aa
More c api bits
alexcrichton May 11, 2021
8e90d80
include wasi
alexcrichton May 11, 2021
8f907b3
Remove new-api branch changes
alexcrichton May 11, 2021
e9dc6a2
Don't redefine wasi_config_t
alexcrichton May 11, 2021
0dd02db
Prefix methods with wasmtime
alexcrichton May 11, 2021
1c705f1
Tweaks and additions to the C API
alexcrichton May 13, 2021
d9ce168
Merge remote-tracking branch 'origin/main' into new-api
alexcrichton May 13, 2021
a49e967
Fix build
alexcrichton May 13, 2021
9dda2fc
Remove duplicate finalizer in C API
alexcrichton May 13, 2021
734af27
Fix a test
alexcrichton May 13, 2021
2dbbdce
Assert Linker is Send/Sync regardless of `T`
alexcrichton May 13, 2021
6d347d3
Add TODO links to uncomment
alexcrichton May 13, 2021
b0a70b1
Various small updates found re-reviewing
alexcrichton May 13, 2021
9d0ecf0
Update wasmtime crate's documentation
alexcrichton May 18, 2021
7db8dad
Merge remote-tracking branch 'origin/main' into new-api
alexcrichton May 18, 2021
0b87eb0
Update instantiation benchmark
alexcrichton May 18, 2021
d5b959c
Comment why `Mutex` is used
alexcrichton May 18, 2021
7631646
Document the C API
alexcrichton May 18, 2021
e5074d0
Comments & build fixes
alexcrichton May 18, 2021
a5d94bd
Dox and build fixes
alexcrichton May 18, 2021
ed774d8
Update book build on CI
alexcrichton May 18, 2021
caf4c30
Add `Store::into_data`
alexcrichton May 19, 2021
f86f274
Build mdbook tests with `wat` support
alexcrichton May 19, 2021
8d526b8
Add aborting stubs for the rest of the C API
alexcrichton May 19, 2021
e88e1d5
Add a method to alias one item in a linker
alexcrichton May 19, 2021
860713c
wasmtime-wiggle: reduce to generating a single add_to_linker func
pchickey May 19, 2021
7387f4a
wasmtime-wiggle: eliminate ctx argument to macro
pchickey May 19, 2021
983a46c
wiggle: port in wiggle-wasmtimes AsyncConf
pchickey May 19, 2021
e1edf6c
all wasmtime-wiggle functionality is available through wiggle crate.
pchickey May 20, 2021
f05aef3
makesure non-default wiggle test features are enabled
pchickey May 20, 2021
39c97ac
various fixes to wasmtime integration in wiggle crate
pchickey May 20, 2021
6e11ad3
replace wasmtime-wiggle crate with normal wiggle. many fixes.
pchickey May 20, 2021
eb63bf5
Don't store `VMOffsets` in the pooling allocator
alexcrichton May 20, 2021
a903696
Tweak some comments on `HostFunc`
alexcrichton May 20, 2021
77bff4a
Shuffle around #[cfg] for async
alexcrichton May 20, 2021
624b0f5
More review comments
alexcrichton May 20, 2021
774d4c7
Add a FIXME
alexcrichton May 20, 2021
82ccab1
Fix a test
alexcrichton May 20, 2021
3006d75
wasmtime-wiggle: only generate one add_{module}_to_linker func
pchickey May 20, 2021
5531831
Merge pull request #27 from bytecodealliance/pch/wiggle_wasmtime_name…
alexcrichton May 20, 2021
516068f
Don't be clever with 64-bit types in the C API
alexcrichton May 20, 2021
40ccaeb
Remove unused import
alexcrichton May 20, 2021
176c785
Document new param in wasmtime_func_new
alexcrichton May 20, 2021
c208ebb
Fix fib-debug example
alexcrichton May 20, 2021
80eeff7
Install another package
alexcrichton May 20, 2021
5bb3c63
explicit type param to wasi_nn for now
pchickey May 20, 2021
2337591
Merge remote-tracking branch 'alexcrichton/new-api' into pch/collapse…
pchickey May 20, 2021
261b106
Tweak LLDB/LLVM on CI
alexcrichton May 20, 2021
11defc5
Merge pull request #28 from bytecodealliance/pch/collapse_wiggle
alexcrichton May 21, 2021
8d83b08
Try to fix CI
alexcrichton May 20, 2021
20f7593
Don't use `BorrowMut` for wiggle
alexcrichton May 21, 2021
e4f4b00
Re-add build of wasmtime
alexcrichton May 21, 2021
995f57f
more build tweak
alexcrichton May 21, 2021
7f4b340
Recognize WASMTIME_V128 as wasm_valkind_t
alexcrichton May 21, 2021
40806de
Fix build of async wasi
alexcrichton May 21, 2021
8a407d0
Fix some wiggle tests
alexcrichton May 21, 2021
7d2e95e
Move wiggle in publish script, now it depends on wasmtime
alexcrichton May 21, 2021
7054c2e
Fix a book example
alexcrichton May 21, 2021
688b6ab
Merge remote-tracking branch 'origin/main' into new-api
alexcrichton May 21, 2021
52cc369
Fix some tests
alexcrichton May 21, 2021
b832de4
Fix c-api build
alexcrichton May 21, 2021
57c4917
Fix benchmark
alexcrichton May 21, 2021
ceedfb2
Merge remote-tracking branch 'origin/main' into new-api
alexcrichton May 21, 2021
6ee0c54
Fix more tests
alexcrichton May 21, 2021
e771b91
docs: in new-api, trap handlers are installed at Engine creation
pchickey May 21, 2021
e5b8398
Merge pull request #30 from bytecodealliance/pch/fix_docs
alexcrichton May 21, 2021
181ed09
Fix doc examples
alexcrichton May 22, 2021
8515dc0
Try to fix tests
alexcrichton May 22, 2021
a8fd750
Fix signature of `wasmtime_table_new`
alexcrichton May 22, 2021
a6f1ab2
Merge remote-tracking branch 'origin/main' into new-api
alexcrichton May 28, 2021
c3ab4df
Refactor bench-api slightly
alexcrichton May 28, 2021
2fa715b
Update crates/wiggle/Cargo.toml
pchickey Jun 1, 2021
64ff9ec
Merge remote-tracking branch 'origin/main' into new-api
alexcrichton Jun 1, 2021
d4965d8
Remove async from wiggle's wasmtime dep
alexcrichton Jun 1, 2021
c99baa3
Don't generate wasmtime config in wasi-common
alexcrichton Jun 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ jobs:
toolchain: nightly-2021-04-11

# Build C API documentation
- run: sudo apt-get update && sudo apt-get install -y doxygen git
- run: sudo apt-get update -y && sudo apt-get install -y libclang1-9 libclang-cpp9
- run: curl -L https://doxygen.nl/files/doxygen-1.9.1.linux.bin.tar.gz | tar xzf -
- run: echo "`pwd`/doxygen-1.9.1/bin" >> $GITHUB_PATH
- run: cd crates/c-api && doxygen doxygen.conf

# install mdbook, build the docs, and test the docs
Expand All @@ -73,7 +75,7 @@ jobs:
echo "${{ runner.tool_cache }}/mdbook/bin" >> $GITHUB_PATH
cargo install --root ${{ runner.tool_cache }}/mdbook --version ${{ env.CARGO_MDBOOK_VERSION }} mdbook
- run: (cd docs && mdbook build)
- run: cargo build -p wasmtime
- run: cargo build -p wasmtime-wasi --features wasmtime/wat
- run: (cd docs && mdbook test -L ../target/debug/deps)

# Build Rust API documentation
Expand Down Expand Up @@ -295,7 +297,7 @@ jobs:
# Build and test all features except for lightbeam
- run: |
cargo test \
--features test-programs/test_programs \
--features "test-programs/test_programs wiggle/wasmtime_async wasmtime/wat" \
--workspace \
--exclude '*lightbeam*' \
--exclude 'wasmtime-wasi-*' \
Expand Down
37 changes: 2 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ members = [
"crates/wiggle",
"crates/wiggle/generate",
"crates/wiggle/macro",
"crates/wiggle/wasmtime",
"crates/wasi-common",
"crates/wasi-common/cap-std-sync",
"crates/wasi-common/tokio",
Expand Down
30 changes: 13 additions & 17 deletions benches/instantiation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,14 @@ use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use rayon::{prelude::*, ThreadPoolBuilder};
use std::{path::PathBuf, process::Command};
use wasmtime::*;
use wasmtime_wasi::{sync::WasiCtxBuilder, Wasi};
use wasmtime_wasi::{sync::WasiCtxBuilder, WasiCtx};

fn instantiate(module: &Module) -> Result<Instance> {
let store = Store::new(&module.engine());
fn instantiate(linker: &Linker<WasiCtx>, module: &Module) -> Result<()> {
let wasi = WasiCtxBuilder::new().build();
let mut store = Store::new(module.engine(), wasi);
let _instance = linker.instantiate(&mut store, module)?;

// As we don't actually invoke Wasm code in this benchmark, we still add
// the WASI context to the store as it is considered part of getting a
// module that depends on WASI "ready to run".
Wasi::set_context(&store, WasiCtxBuilder::new().build())
.map_err(|_| anyhow::anyhow!("wasi set_context failed"))?;

let linker = Linker::new(&store);
let instance = linker.instantiate(module)?;

Ok(instance)
Ok(())
}

fn benchmark_name<'a>(strategy: &InstanceAllocationStrategy) -> &'static str {
Expand Down Expand Up @@ -46,15 +39,16 @@ fn bench_sequential(c: &mut Criterion, modules: &[&str]) {
path.push(file_name);

let mut config = Config::default();
Wasi::add_to_config(&mut config);
config.allocation_strategy(strategy.clone());

let engine = Engine::new(&config).expect("failed to create engine");
let module = Module::from_file(&engine, &path)
.expect(&format!("failed to load benchmark `{}`", path.display()));
let mut linker = Linker::new(&engine);
wasmtime_wasi::add_to_linker(&mut linker, |cx| cx).unwrap();

group.bench_function(BenchmarkId::new(benchmark_name(strategy), file_name), |b| {
b.iter(|| instantiate(&module).expect("failed to instantiate module"));
b.iter(|| instantiate(&linker, &module).expect("failed to instantiate module"));
});
}
}
Expand All @@ -74,12 +68,13 @@ fn bench_parallel(c: &mut Criterion) {
InstanceAllocationStrategy::pooling(),
] {
let mut config = Config::default();
Wasi::add_to_config(&mut config);
config.allocation_strategy(strategy.clone());

let engine = Engine::new(&config).expect("failed to create engine");
let module = Module::from_file(&engine, "benches/instantiation/wasi.wasm")
.expect("failed to load WASI example module");
let mut linker = Linker::new(&engine);
wasmtime_wasi::add_to_linker(&mut linker, |cx| cx).unwrap();

for threads in 1..=num_cpus::get_physical() {
let pool = ThreadPoolBuilder::new()
Expand All @@ -101,7 +96,8 @@ fn bench_parallel(c: &mut Criterion) {
b.iter(|| {
pool.install(|| {
(0..PARALLEL_INSTANCES).into_par_iter().for_each(|_| {
instantiate(&module).expect("failed to instantiate module");
instantiate(&linker, &module)
.expect("failed to instantiate module");
})
})
});
Expand Down
9 changes: 8 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,17 @@ fn ignore(testsuite: &str, testname: &str, strategy: &str) -> bool {
_ => (),
},
"Cranelift" => match (testsuite, testname) {
// Skip all reference types tests on the old backend. The modern
// implementation of reference types uses atomic instructions
// for reference counts on `externref`, but the old backend does not
// implement atomic instructions.
("reference_types", _) if cfg!(feature = "old-x86-backend") => return true,
// Skip all SIMD tests on old backend, there are instructions not
// implemented there and support is generally not maintained.
("simd", _) if cfg!(feature = "old-x86-backend") => return true,
// No simd support yet for s390x.
("simd", _) if platform_is_s390x() => return true,

("simd", _) if cfg!(feature = "old-x86-backend") => return true, // skip all SIMD tests on old backend.
// These are new instructions that are not really implemented in any backend.
("simd", "simd_i8x16_arith2")
| ("simd", "simd_conversions")
Expand Down
2 changes: 1 addition & 1 deletion ci/build-tarballs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ mkdir tmp/$api_pkgname/include
mkdir tmp/$bin_pkgname
cp LICENSE README.md tmp/$api_pkgname
cp LICENSE README.md tmp/$bin_pkgname
cp -r crates/c-api/include tmp/$api_pkgname
cp crates/c-api/wasm-c-api/include/wasm.h tmp/$api_pkgname/include
cp crates/c-api/include/{wasmtime,wasi}.h tmp/$api_pkgname/include

fmt=tar
if [ "$platform" = "x86_64-windows" ]; then
Expand Down
5 changes: 3 additions & 2 deletions cranelift/interpreter/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ impl<'a> Interpreter<'a> {
self.call_by_index(index, arguments)
}

/// Call a function by its index in the [FunctionStore]; this is a proxy for [Interpreter::call].
/// Call a function by its index in the [FunctionStore]; this is a proxy for
/// `Interpreter::call`.
pub fn call_by_index(
&mut self,
index: FuncIndex,
Expand Down Expand Up @@ -287,7 +288,7 @@ mod tests {
v1 = iadd_imm v0, -1
return v1
}

function %parent(i32) -> i32 {
fn42 = %child(i32) -> i32
block0(v0: i32):
Expand Down
Loading