mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-23 05:31:32 +00:00
Merge branch 'master' into feature/update-capi-to-use-new-api
This commit is contained in:
@ -44,6 +44,7 @@ steps:
|
||||
rustup update --no-self-update $RUST_TOOLCHAIN
|
||||
rustup default $RUST_TOOLCHAIN
|
||||
rustup target add x86_64-unknown-linux-musl
|
||||
rustup target add wasm32-wasi
|
||||
|
||||
if [ -n "$ANDROID" ]; then
|
||||
rustup target add x86_64-linux-android --toolchain $RUST_TOOLCHAIN
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
## **[Unreleased]**
|
||||
|
||||
- [#1357](https://github.com/wasmerio/wasmer/pull/1357) Refactored bin commands into separate files
|
||||
- [#1331](https://github.com/wasmerio/wasmer/pull/1331) Implement the `record` type and instrutions for WIT
|
||||
- [#1345](https://github.com/wasmerio/wasmer/pull/1345) Adding ARM testing in Azure Pipelines
|
||||
- [#1335](https://github.com/wasmerio/wasmer/pull/1335) Change mutability of `memory` to `const` in `wasmer_memory_data_length` in the C API
|
||||
|
114
Cargo.lock
generated
114
Cargo.lock
generated
@ -30,14 +30,6 @@ version = "1.0.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7825f6833612eb2414095684fcf6c635becf3ce97fe48cf6421321e93bfbd53c"
|
||||
|
||||
[[package]]
|
||||
name = "api-tests"
|
||||
version = "0.16.2"
|
||||
dependencies = [
|
||||
"wabt",
|
||||
"wasmer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.6"
|
||||
@ -761,6 +753,22 @@ version = "0.3.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
|
||||
|
||||
[[package]]
|
||||
name = "generate-emscripten-tests"
|
||||
version = "0.16.2"
|
||||
dependencies = [
|
||||
"glob 0.3.0",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generate-wasi-tests"
|
||||
version = "0.16.2"
|
||||
dependencies = [
|
||||
"glob 0.3.0",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generational-arena"
|
||||
version = "0.2.7"
|
||||
@ -2727,6 +2735,7 @@ dependencies = [
|
||||
name = "wasmer"
|
||||
version = "0.16.2"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"wasmer-clif-backend",
|
||||
"wasmer-llvm-backend",
|
||||
"wasmer-runtime-core",
|
||||
@ -2739,9 +2748,13 @@ version = "0.16.2"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"byteorder",
|
||||
"criterion",
|
||||
"errno",
|
||||
"fern",
|
||||
"generate-emscripten-tests",
|
||||
"generate-wasi-tests",
|
||||
"glob 0.3.0",
|
||||
"libc",
|
||||
"log",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
@ -2750,19 +2763,15 @@ dependencies = [
|
||||
"wabt",
|
||||
"wasmer",
|
||||
"wasmer-clif-backend",
|
||||
"wasmer-dev-utils",
|
||||
"wasmer-emscripten",
|
||||
"wasmer-emscripten-tests",
|
||||
"wasmer-kernel-loader",
|
||||
"wasmer-llvm-backend",
|
||||
"wasmer-middleware-common",
|
||||
"wasmer-middleware-common-tests",
|
||||
"wasmer-runtime",
|
||||
"wasmer-runtime-core",
|
||||
"wasmer-singlepass-backend",
|
||||
"wasmer-wasi",
|
||||
"wasmer-wasi-experimental-io-devices",
|
||||
"wasmer-wasi-tests",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2816,13 +2825,6 @@ dependencies = [
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-dev-utils"
|
||||
version = "0.16.2"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-emscripten"
|
||||
version = "0.16.2"
|
||||
@ -2836,20 +2838,6 @@ dependencies = [
|
||||
"wasmer-runtime-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-emscripten-tests"
|
||||
version = "0.16.2"
|
||||
dependencies = [
|
||||
"glob 0.3.0",
|
||||
"wabt",
|
||||
"wasmer-clif-backend",
|
||||
"wasmer-dev-utils",
|
||||
"wasmer-emscripten",
|
||||
"wasmer-llvm-backend",
|
||||
"wasmer-runtime",
|
||||
"wasmer-singlepass-backend",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-interface-types"
|
||||
version = "0.16.2"
|
||||
@ -2888,16 +2876,6 @@ dependencies = [
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-llvm-backend-tests"
|
||||
version = "0.10.2"
|
||||
dependencies = [
|
||||
"wabt",
|
||||
"wasmer-llvm-backend",
|
||||
"wasmer-runtime",
|
||||
"wasmer-runtime-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-middleware-common"
|
||||
version = "0.16.2"
|
||||
@ -2905,19 +2883,6 @@ dependencies = [
|
||||
"wasmer-runtime-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-middleware-common-tests"
|
||||
version = "0.16.2"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"wabt",
|
||||
"wasmer-clif-backend",
|
||||
"wasmer-llvm-backend",
|
||||
"wasmer-middleware-common",
|
||||
"wasmer-runtime-core",
|
||||
"wasmer-singlepass-backend",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-runtime"
|
||||
version = "0.16.2"
|
||||
@ -2975,17 +2940,6 @@ dependencies = [
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-runtime-core-tests"
|
||||
version = "0.16.2"
|
||||
dependencies = [
|
||||
"wabt",
|
||||
"wasmer-clif-backend",
|
||||
"wasmer-llvm-backend",
|
||||
"wasmer-runtime-core",
|
||||
"wasmer-singlepass-backend",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-singlepass-backend"
|
||||
version = "0.16.2"
|
||||
@ -3003,18 +2957,6 @@ dependencies = [
|
||||
"wasmer-runtime-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-spectests"
|
||||
version = "0.16.2"
|
||||
dependencies = [
|
||||
"glob 0.3.0",
|
||||
"wabt",
|
||||
"wasmer-clif-backend",
|
||||
"wasmer-llvm-backend",
|
||||
"wasmer-runtime",
|
||||
"wasmer-singlepass-backend",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-wasi"
|
||||
version = "0.16.2"
|
||||
@ -3045,20 +2987,6 @@ dependencies = [
|
||||
"wasmer-wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-wasi-tests"
|
||||
version = "0.16.2"
|
||||
dependencies = [
|
||||
"glob 0.3.0",
|
||||
"tempfile",
|
||||
"wasmer-clif-backend",
|
||||
"wasmer-dev-utils",
|
||||
"wasmer-llvm-backend",
|
||||
"wasmer-runtime",
|
||||
"wasmer-singlepass-backend",
|
||||
"wasmer-wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-win-exception-handler"
|
||||
version = "0.16.2"
|
||||
|
29
Cargo.toml
29
Cargo.toml
@ -37,50 +37,46 @@ wasmer-emscripten = { path = "lib/emscripten" }
|
||||
wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true }
|
||||
wasmer-wasi = { path = "lib/wasi", optional = true }
|
||||
wasmer-kernel-loader = { path = "lib/kernel-loader", optional = true }
|
||||
wasmer-dev-utils = { path = "lib/dev-utils", optional = true }
|
||||
wasmer-wasi-tests = { path = "lib/wasi-tests", optional = true }
|
||||
wasmer-middleware-common-tests = { path = "lib/middleware-common-tests", optional = true }
|
||||
wasmer-emscripten-tests = { path = "lib/emscripten-tests", optional = true }
|
||||
wasmer-wasi-experimental-io-devices = { path = "lib/wasi-experimental-io-devices", optional = true }
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"lib/api",
|
||||
"lib/api-tests",
|
||||
"lib/clif-backend",
|
||||
"lib/singlepass-backend",
|
||||
"lib/runtime",
|
||||
"lib/runtime-core",
|
||||
"lib/runtime-core-tests",
|
||||
"lib/emscripten",
|
||||
"lib/spectests",
|
||||
"lib/win-exception-handler",
|
||||
"lib/runtime-c-api",
|
||||
"lib/llvm-backend",
|
||||
"lib/llvm-backend-tests",
|
||||
"lib/wasi",
|
||||
"lib/middleware-common",
|
||||
"lib/kernel-loader",
|
||||
"lib/kernel-net",
|
||||
"lib/dev-utils",
|
||||
"lib/wasi-experimental-io-devices",
|
||||
"lib/wasi-tests",
|
||||
"lib/emscripten-tests",
|
||||
"lib/middleware-common-tests",
|
||||
"lib/interface-types",
|
||||
"examples/parallel",
|
||||
"examples/plugin-for-example",
|
||||
"examples/parallel-guest",
|
||||
"tests/generate-wasi-tests",
|
||||
"tests/generate-emscripten-tests",
|
||||
]
|
||||
|
||||
[build-dependencies]
|
||||
wabt = "0.9.1"
|
||||
generate-emscripten-tests = { path = "tests/generate-emscripten-tests" }
|
||||
generate-wasi-tests = { path = "tests/generate-wasi-tests" }
|
||||
glob = "0.3"
|
||||
rustc_version = "0.2"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3"
|
||||
glob = "0.3"
|
||||
libc = "0.2.60" # for `tests/dev-utils`'s Stdout capturing
|
||||
serde = { version = "1", features = ["derive"] } # used by the plugin example
|
||||
typetag = "0.1" # used by the plugin example
|
||||
wabt = "0.9.1"
|
||||
|
||||
[features]
|
||||
default = ["fast-tests", "wasi", "backend-cranelift", "wabt"]
|
||||
@ -95,18 +91,18 @@ backend-cranelift = [
|
||||
"wasmer-clif-backend/generate-debug-information",
|
||||
"wasmer-runtime-core/generate-debug-information",
|
||||
"wasmer-runtime/cranelift",
|
||||
"wasmer-middleware-common-tests/clif",
|
||||
"wasmer/cranelift",
|
||||
]
|
||||
backend-llvm = [
|
||||
"wasmer-llvm-backend",
|
||||
"wasmer-runtime/llvm",
|
||||
"wasmer-middleware-common-tests/llvm",
|
||||
"wasmer-runtime-core/generate-debug-information-no-export-symbols"
|
||||
"wasmer-runtime-core/generate-debug-information-no-export-symbols",
|
||||
"wasmer/llvm",
|
||||
]
|
||||
backend-singlepass = [
|
||||
"wasmer-singlepass-backend",
|
||||
"wasmer-runtime/singlepass",
|
||||
"wasmer-middleware-common-tests/singlepass",
|
||||
"wasmer/singlepass",
|
||||
]
|
||||
wasi = ["wasmer-wasi"]
|
||||
experimental-io-devices = ["wasmer-wasi-experimental-io-devices"]
|
||||
@ -114,6 +110,7 @@ managed = ["backend-singlepass", "wasmer-runtime-core/managed"]
|
||||
|
||||
[[example]]
|
||||
name = "plugin"
|
||||
required-features = ["wasi"]
|
||||
crate-type = ["bin"]
|
||||
|
||||
[[example]]
|
||||
|
102
Makefile
102
Makefile
@ -1,122 +1,117 @@
|
||||
.PHONY: spectests emtests clean build install lint precommit docs examples
|
||||
|
||||
# Generate files
|
||||
generate-spectests:
|
||||
WASMER_RUNTIME_GENERATE_SPECTESTS=1 cargo build -p wasmer-runtime-core --release \
|
||||
&& echo "formatting" \
|
||||
&& cargo fmt
|
||||
|
||||
generate-emtests:
|
||||
WASM_EMSCRIPTEN_GENERATE_EMTESTS=1 cargo build -p wasmer-emscripten-tests --release \
|
||||
WASM_EMSCRIPTEN_GENERATE_EMTESTS=1 cargo build --release \
|
||||
&& echo "formatting" \
|
||||
&& cargo fmt
|
||||
|
||||
# To generate WASI tests you'll need to have the correct versions of the Rust nightly
|
||||
# toolchain installed, see `WasiVersion::get_compiler_toolchain` in
|
||||
# `lib/wasi-tests/build/wasi_version.rs`
|
||||
# `tests/generate-wasi-tests/src/wasi_version.rs`
|
||||
#
|
||||
# or run `make wasitests-setup-toolchain` or `make wasitests-setup-toolchain-all`
|
||||
generate-wasitests: wasitests-setup
|
||||
WASM_WASI_GENERATE_WASITESTS=1 cargo build -p wasmer-wasi-tests --release -vv \
|
||||
WASM_WASI_GENERATE_WASITESTS=1 cargo build --release -vv \
|
||||
&& echo "formatting" \
|
||||
&& cargo fmt
|
||||
|
||||
generate-wasitests-all: wasitests-setup
|
||||
WASI_TEST_GENERATE_ALL=1 WASM_WASI_GENERATE_WASITESTS=1 cargo build -p wasmer-wasi-tests --release -vv \
|
||||
WASI_TEST_GENERATE_ALL=1 WASM_WASI_GENERATE_WASITESTS=1 cargo build --release -vv \
|
||||
&& echo "formatting" \
|
||||
&& cargo fmt
|
||||
|
||||
spectests-generate: generate-spectests
|
||||
emtests-generate: generate-emtests
|
||||
wasitests-generate: generate-wasitests
|
||||
|
||||
wasitests-setup-toolchain: wasitests-setup
|
||||
WASITESTS_SET_UP_TOOLCHAIN=1 cargo build -p wasmer-wasi-tests --release -vv
|
||||
WASITESTS_SET_UP_TOOLCHAIN=1 cargo build --release -vv
|
||||
|
||||
wasitests-setup-toolchain-all: wasitests-setup
|
||||
WASI_TEST_GENERATE_ALL=1 WASITESTS_SET_UP_TOOLCHAIN=1 cargo build -p wasmer-wasi-tests --release -vv
|
||||
WASI_TEST_GENERATE_ALL=1 WASITESTS_SET_UP_TOOLCHAIN=1 cargo build --release -vv
|
||||
|
||||
generate: generate-spectests generate-emtests generate-wasitests
|
||||
generate: generate-emtests generate-wasitests
|
||||
|
||||
|
||||
# Spectests
|
||||
spectests-singlepass:
|
||||
cargo test --manifest-path lib/spectests/Cargo.toml --release --features singlepass -- --nocapture --test-threads 1
|
||||
WASMER_TEST_SINGLEPASS=1 cargo test test_run_spectests --release --no-default-features --features "wasi backend-singlepass" -- --nocapture --test-threads 1
|
||||
|
||||
spectests-cranelift:
|
||||
cargo test --manifest-path lib/spectests/Cargo.toml --release --features clif -- --nocapture
|
||||
WASMER_TEST_CRANELFIT=1 cargo test test_run_spectests --release --no-default-features --features "wasi backend-cranelift" -- --nocapture
|
||||
|
||||
spectests-llvm:
|
||||
cargo test --manifest-path lib/spectests/Cargo.toml --release --features llvm -- --nocapture
|
||||
WASMER_TEST_LLVM=1 cargo test test_run_spectests --release --no-default-features --features "wasi backend-llvm wasmer-llvm-backend/test" -- --nocapture
|
||||
|
||||
spectests-all:
|
||||
WASMER_TEST_CRANELIFT=1 WASMER_TEST_LLVM=1 WASMER_TEST_SINGLEPASS=1 \
|
||||
cargo test test_run_spectests --release --no-default-features --features "wasi backend-cranelift backend-singlepass backend-llvm wasmer-llvm-backend/test" -- --nocapture --test-threads 1
|
||||
|
||||
|
||||
spectests: spectests-singlepass spectests-cranelift spectests-llvm
|
||||
|
||||
|
||||
# Emscripten tests
|
||||
emtests-singlepass:
|
||||
cargo test --manifest-path lib/emscripten-tests/Cargo.toml --release --features singlepass -- --test-threads=1
|
||||
WASMER_TEST_SINGLEPASS=1 cargo test emtest --release --no-default-features --features "wasi backend-singlepass" -- --test-threads=1
|
||||
|
||||
emtests-cranelift:
|
||||
cargo test --manifest-path lib/emscripten-tests/Cargo.toml --release --features clif -- --test-threads=1
|
||||
WASMER_TEST_CRANELIFT=1 cargo test emtest --release --no-default-features --features "wasi backend-cranelift" -- --test-threads=1
|
||||
|
||||
emtests-llvm:
|
||||
cargo test --manifest-path lib/emscripten-tests/Cargo.toml --release --features llvm -- --test-threads=1
|
||||
WASMER_TEST_LLVM=1 cargo test emtest --release --no-default-features --features "wasi backend-llvm" -- --test-threads=1
|
||||
|
||||
emtests-unit:
|
||||
cargo test --manifest-path lib/emscripten/Cargo.toml --release
|
||||
cargo test emscripten --release
|
||||
|
||||
emtests: emtests-unit emtests-singlepass emtests-cranelift emtests-llvm
|
||||
|
||||
|
||||
# Middleware tests
|
||||
middleware-singlepass:
|
||||
cargo test --manifest-path lib/middleware-common-tests/Cargo.toml --release --features singlepass
|
||||
cargo test middleware --release --no-default-features --features "wasi backend-singlepass"
|
||||
|
||||
middleware-cranelift:
|
||||
cargo test --manifest-path lib/middleware-common-tests/Cargo.toml --release --features clif
|
||||
cargo test middleware --release --no-default-features --features "wasi backend-cranelift"
|
||||
|
||||
middleware-llvm:
|
||||
cargo test --manifest-path lib/middleware-common-tests/Cargo.toml --release --features llvm
|
||||
cargo test middleware --release --no-default-features --features "wasi backend-llvm"
|
||||
|
||||
middleware: middleware-singlepass middleware-cranelift middleware-llvm
|
||||
|
||||
|
||||
# Wasitests
|
||||
wasitests-setup:
|
||||
# force cargo to rerun the build.rs step
|
||||
touch lib/wasi-tests/build/mod.rs
|
||||
rm -rf lib/wasi-tests/wasitests/test_fs/temp
|
||||
mkdir -p lib/wasi-tests/wasitests/test_fs/temp
|
||||
rm -rf tests/wasi_test_resources/test_fs/temp
|
||||
mkdir -p tests/wasi_test_resources/test_fs/temp
|
||||
|
||||
wasitests-singlepass: wasitests-setup
|
||||
cargo test --manifest-path lib/wasi-tests/Cargo.toml --release --features singlepass -- --test-threads=1
|
||||
WASMER_TEST_SINGLEPASS=1 cargo test wasitest --release --no-default-features --features "wasi backend-singlepass" -- --test-threads=1
|
||||
|
||||
wasitests-cranelift: wasitests-setup
|
||||
cargo test --manifest-path lib/wasi-tests/Cargo.toml --release --features clif -- --test-threads=1 --nocapture
|
||||
WASMER_TEST_CRANELIFT=1 cargo test wasitest --release --no-default-features --features "wasi backend-cranelift" -- --test-threads=1 --nocapture
|
||||
|
||||
wasitests-llvm: wasitests-setup
|
||||
cargo test --manifest-path lib/wasi-tests/Cargo.toml --release --features llvm -- --test-threads=1
|
||||
WASMER_TEST_LLVM=1 cargo test wasitest --release --no-default-features --features "wasi backend-llvm" -- --test-threads=1
|
||||
|
||||
wasitests-unit: wasitests-setup
|
||||
cargo test --manifest-path lib/wasi-tests/Cargo.toml --release --features clif -- --test-threads=1 --nocapture
|
||||
cargo test --manifest-path lib/wasi/Cargo.toml --release
|
||||
|
||||
wasitests: wasitests-unit wasitests-singlepass wasitests-cranelift wasitests-llvm
|
||||
|
||||
|
||||
# Backends
|
||||
singlepass: spectests-singlepass emtests-singlepass middleware-singlepass wasitests-singlepass
|
||||
singlepass: wasitests-setup
|
||||
cargo test -p wasmer-singlepass-backend --release
|
||||
cargo test --manifest-path lib/runtime-core-tests/Cargo.toml --release --no-default-features --features backend-singlepass
|
||||
WASMER_TEST_SINGLEPASS=1 cargo test --release --no-default-features --features "wasi backend-singlepass" -- --test-threads=1
|
||||
|
||||
cranelift: spectests-cranelift emtests-cranelift middleware-cranelift wasitests-cranelift
|
||||
cranelift: wasitests-setup
|
||||
cargo test -p wasmer-clif-backend --release
|
||||
cargo test -p wasmer-runtime-core-tests --release
|
||||
WASMER_TEST_CRANELIFT=1 cargo test --release --no-default-features --features "wasi backend-cranelift" -- --test-threads=1
|
||||
|
||||
llvm: spectests-llvm emtests-llvm wasitests-llvm
|
||||
llvm: wasitests-setup
|
||||
cargo test -p wasmer-llvm-backend --release
|
||||
cargo test -p wasmer-llvm-backend-tests --release
|
||||
cargo test --manifest-path lib/runtime-core-tests/Cargo.toml --release --no-default-features --features backend-llvm
|
||||
WASMER_TEST_LLVM=1 cargo test --release --no-default-features --features "wasi backend-llvm" -- --test-threads=1
|
||||
|
||||
|
||||
# All tests
|
||||
@ -160,12 +155,9 @@ test-capi: test-capi-singlepass test-capi-cranelift test-capi-llvm test-capi-ems
|
||||
capi-test: test-capi
|
||||
|
||||
test-rest:
|
||||
cargo test --release -p api-tests
|
||||
cargo test --release -p wasmer-dev-utils
|
||||
cargo test --release -p wasmer-interface-types
|
||||
cargo test --release -p wasmer-kernel-loader
|
||||
cargo test --release -p kernel-net
|
||||
cargo test --release -p wasmer-llvm-backend-tests
|
||||
cargo test --release -p wasmer-runtime
|
||||
cargo test --release -p wasmer-runtime-core
|
||||
cargo test --release -p wasmer-wasi-experimental-io-devices
|
||||
@ -175,14 +167,14 @@ test: spectests emtests middleware wasitests test-rest examples
|
||||
|
||||
test-android:
|
||||
ci/run-docker.sh x86_64-linux-android --manifest-path=lib/singlepass-backend/Cargo.toml
|
||||
ci/run-docker.sh x86_64-linux-android --manifest-path=lib/runtime-core-tests/Cargo.toml
|
||||
ci/run-docker.sh x86_64-linux-android runtime_core
|
||||
|
||||
# Integration tests
|
||||
integration-tests: release-clif examples
|
||||
echo "Running Integration Tests"
|
||||
./integration_tests/lua/test.sh
|
||||
./integration_tests/nginx/test.sh
|
||||
./integration_tests/cowsay/test.sh
|
||||
./tests/integration_tests/lua/test.sh
|
||||
./tests/integration_tests/nginx/test.sh
|
||||
./tests/integration_tests/cowsay/test.sh
|
||||
|
||||
examples:
|
||||
cargo run --example plugin
|
||||
@ -207,17 +199,22 @@ check-bench-singlepass:
|
||||
--exclude wasmer-clif-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader
|
||||
check-bench-clif:
|
||||
cargo check --benches --all --no-default-features --features "backend-cranelift" \
|
||||
--exclude wasmer-singlepass-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader \
|
||||
--exclude wasmer-middleware-common-tests
|
||||
--exclude wasmer-singlepass-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader
|
||||
check-bench-llvm:
|
||||
cargo check --benches --all --no-default-features --features "backend-llvm" \
|
||||
--exclude wasmer-singlepass-backend --exclude wasmer-clif-backend --exclude wasmer-kernel-loader
|
||||
|
||||
check-bench: check-bench-singlepass check-bench-llvm
|
||||
|
||||
check-kernel-net:
|
||||
cargo check -p kernel-net --target=wasm32-wasi
|
||||
|
||||
# checks that require a nightly version of Rust
|
||||
check-nightly: check-kernel-net
|
||||
|
||||
# TODO: We wanted `--workspace --exclude wasmer-runtime`, but can't due
|
||||
# to https://github.com/rust-lang/cargo/issues/6745 .
|
||||
NOT_RUNTIME_CRATES = -p wasmer-clif-backend -p wasmer-singlepass-backend -p wasmer-middleware-common -p wasmer-runtime-core -p wasmer-emscripten -p wasmer-llvm-backend -p wasmer-wasi -p wasmer-kernel-loader -p wasmer-dev-utils -p wasmer-wasi-tests -p wasmer-middleware-common-tests -p wasmer-emscripten-tests -p wasmer-interface-types
|
||||
NOT_RUNTIME_CRATES = -p wasmer-clif-backend -p wasmer-singlepass-backend -p wasmer-middleware-common -p wasmer-runtime-core -p wasmer-emscripten -p wasmer-llvm-backend -p wasmer-wasi -p wasmer-kernel-loader -p wasmer-interface-types
|
||||
RUNTIME_CHECK = cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features
|
||||
check: check-bench
|
||||
cargo check $(NOT_RUNTIME_CRATES)
|
||||
@ -294,13 +291,14 @@ release-llvm:
|
||||
cargo build --release --features backend-llvm,experimental-io-devices
|
||||
|
||||
bench-singlepass:
|
||||
# NOTE this will run some benchmarks using clif; TODO: fix this
|
||||
cargo bench --all --no-default-features --features "backend-singlepass" \
|
||||
--exclude wasmer-clif-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader
|
||||
bench-clif:
|
||||
cargo bench --all --no-default-features --features "backend-cranelift" \
|
||||
--exclude wasmer-singlepass-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader \
|
||||
--exclude wasmer-middleware-common-tests
|
||||
--exclude wasmer-singlepass-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader
|
||||
bench-llvm:
|
||||
# NOTE this will run some benchmarks using clif; TODO: fix this
|
||||
cargo bench --all --no-default-features --features "backend-llvm" \
|
||||
--exclude wasmer-singlepass-backend --exclude wasmer-clif-backend --exclude wasmer-kernel-loader
|
||||
|
||||
@ -354,13 +352,13 @@ publish-release:
|
||||
# cargo install cargo-deps
|
||||
# must install graphviz for `dot`
|
||||
dep-graph:
|
||||
cargo deps --optional-deps --filter wasmer-wasi wasmer-wasi-tests wasmer-kernel-loader wasmer-dev-utils wasmer-llvm-backend wasmer-emscripten wasmer-emscripten-tests wasmer-runtime-core wasmer-runtime wasmer-middleware-common wasmer-middleware-common-tests wasmer-singlepass-backend wasmer-clif-backend wasmer --manifest-path Cargo.toml | dot -Tpng > wasmer_depgraph.png
|
||||
cargo deps --optional-deps --filter wasmer-wasi wasmer-kernel-loader wasmer-llvm-backend wasmer-emscripten wasmer-runtime-core wasmer-runtime wasmer-middleware-common wasmer-singlepass-backend wasmer-clif-backend wasmer --manifest-path Cargo.toml | dot -Tpng > wasmer_depgraph.png
|
||||
|
||||
docs-capi:
|
||||
cd lib/runtime-c-api/ && doxygen doxyfile
|
||||
|
||||
docs: docs-capi
|
||||
cargo doc --features=backend-singlepass,backend-cranelift,backend-llvm,docs,wasi,managed --workspace --document-private-items --no-deps
|
||||
cargo doc --release --features=backend-singlepass,backend-cranelift,backend-llvm,docs,wasi,managed --workspace --document-private-items --no-deps
|
||||
mkdir -p api-docs
|
||||
mkdir -p api-docs/c
|
||||
cp -R target/doc api-docs/crates
|
||||
|
@ -116,7 +116,9 @@ jobs:
|
||||
- template: .azure/install-llvm.yml
|
||||
- template: .azure/install-sccache.yml
|
||||
- template: .azure/install-cmake.yml
|
||||
- bash: make check
|
||||
- bash: |
|
||||
make check
|
||||
make check-nightly
|
||||
displayName: Check with Flags
|
||||
condition: and(succeeded(), not(eq(variables['Agent.OS'], 'Windows_NT')))
|
||||
|
||||
|
@ -133,7 +133,7 @@ static WAT_GAS: &'static str = r#"
|
||||
(elem (i32.const 0) $f2))
|
||||
"#;
|
||||
|
||||
#[cfg(feature = "llvm")]
|
||||
#[cfg(feature = "backend-llvm")]
|
||||
fn get_compiler(limit: u64, metering: bool) -> impl Compiler {
|
||||
use wasmer_llvm_backend::ModuleCodeGenerator;
|
||||
use wasmer_runtime_core::codegen::{MiddlewareChain, StreamingCompiler};
|
||||
@ -148,7 +148,7 @@ fn get_compiler(limit: u64, metering: bool) -> impl Compiler {
|
||||
c
|
||||
}
|
||||
|
||||
#[cfg(feature = "singlepass")]
|
||||
#[cfg(feature = "backend-singlepass")]
|
||||
fn get_compiler(limit: u64, metering: bool) -> impl Compiler {
|
||||
use wasmer_runtime_core::codegen::{MiddlewareChain, StreamingCompiler};
|
||||
use wasmer_singlepass_backend::ModuleCodeGenerator as SinglePassMCG;
|
||||
@ -162,12 +162,16 @@ fn get_compiler(limit: u64, metering: bool) -> impl Compiler {
|
||||
c
|
||||
}
|
||||
|
||||
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
|
||||
#[cfg(not(any(
|
||||
feature = "backend-llvm",
|
||||
feature = "backend-cranelift",
|
||||
feature = "backend-singlepass"
|
||||
)))]
|
||||
compile_error!("compiler not specified, activate a compiler via features");
|
||||
|
||||
#[cfg(feature = "clif")]
|
||||
#[cfg(feature = "backend-cranelift")]
|
||||
fn get_compiler(_limit: u64, metering: bool) -> impl Compiler {
|
||||
compile_error!("cranelift does not implement metering");
|
||||
unimplemented!("cranelift does not implement metering");
|
||||
use wasmer_clif_backend::CraneliftCompiler;
|
||||
CraneliftCompiler::new()
|
||||
}
|
||||
@ -222,5 +226,7 @@ fn bench_metering(c: &mut Criterion) {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "backend-cranelift"))]
|
||||
criterion_group!(benches, bench_metering);
|
||||
#[cfg(not(feature = "backend-cranelift"))]
|
||||
criterion_main!(benches);
|
11
build.rs
Normal file
11
build.rs
Normal file
@ -0,0 +1,11 @@
|
||||
//! A kind of meta-build.rs that can be configured to do different things.
|
||||
//!
|
||||
//! Please try to keep this file as clean as possible.
|
||||
|
||||
use generate_emscripten_tests;
|
||||
use generate_wasi_tests;
|
||||
|
||||
fn main() {
|
||||
generate_wasi_tests::build();
|
||||
generate_emscripten_tests::build();
|
||||
}
|
@ -5,6 +5,7 @@ RUN apt-get update && \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gcc \
|
||||
g++ \
|
||||
libc-dev \
|
||||
python \
|
||||
unzip \
|
||||
|
@ -1,6 +1,5 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wasmer_runtime::{compile, func, imports, Func};
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use wasmer_runtime::{compile, func, imports, Ctx, Func};
|
||||
use wasmer_wasi::{
|
||||
generate_import_object_for_version,
|
||||
state::{self, WasiFile, WasiFsError},
|
||||
|
@ -1,15 +0,0 @@
|
||||
[package]
|
||||
name = "api-tests"
|
||||
version = "0.16.2"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
publish = false
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
wasmer = { version = "0.16.2", path = "../api" }
|
||||
|
||||
[dev-dependencies]
|
||||
wabt = "0.9.1"
|
@ -1 +0,0 @@
|
||||
|
@ -10,6 +10,7 @@ license = "MIT"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
wasmer-runtime-core = { version = "0.16.2", path = "../runtime-core" }
|
||||
|
||||
[dependencies.wasmer-singlepass-backend]
|
||||
|
@ -22,10 +22,14 @@
|
||||
//!
|
||||
//! more info, what to do if you run into problems
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde;
|
||||
|
||||
pub use crate::module::*;
|
||||
pub use wasmer_runtime_core::instance::{DynFunc, Instance};
|
||||
pub use wasmer_runtime_core::memory::Memory;
|
||||
pub use wasmer_runtime_core::table::Table;
|
||||
pub use wasmer_runtime_core::typed_func::DynamicFunc;
|
||||
pub use wasmer_runtime_core::Func;
|
||||
pub use wasmer_runtime_core::{func, imports};
|
||||
|
||||
@ -58,15 +62,17 @@ pub mod memory {
|
||||
}
|
||||
|
||||
pub mod wasm {
|
||||
//! Various types exposed by the Wasmer Runtime.
|
||||
//! Various types exposed by the Wasmer Runtime relating to Wasm.
|
||||
//!
|
||||
//! TODO: Add index with links to sub sections
|
||||
//!
|
||||
//
|
||||
//! # Globals
|
||||
//!
|
||||
//! # Tables
|
||||
pub use wasmer_runtime_core::backend::Features;
|
||||
pub use wasmer_runtime_core::export::Export;
|
||||
pub use wasmer_runtime_core::global::Global;
|
||||
pub use wasmer_runtime_core::instance::Instance;
|
||||
pub use wasmer_runtime_core::instance::{DynFunc, Instance};
|
||||
pub use wasmer_runtime_core::memory::Memory;
|
||||
pub use wasmer_runtime_core::module::Module;
|
||||
pub use wasmer_runtime_core::table::Table;
|
||||
@ -74,12 +80,209 @@ pub mod wasm {
|
||||
pub use wasmer_runtime_core::types::{
|
||||
FuncSig, GlobalDescriptor, MemoryDescriptor, TableDescriptor, Type, Value,
|
||||
};
|
||||
pub use wasmer_runtime_core::Func;
|
||||
}
|
||||
|
||||
pub mod vm {
|
||||
//! Various types exposed by the Wasmer Runtime relating to the VM.
|
||||
pub use wasmer_runtime_core::vm::Ctx;
|
||||
}
|
||||
|
||||
pub mod compiler {
|
||||
//! Types and functions for compiling wasm;
|
||||
use crate::module::Module;
|
||||
pub use wasmer_runtime_core::backend::{
|
||||
BackendCompilerConfig, Compiler, CompilerConfig, Features,
|
||||
};
|
||||
pub use wasmer_runtime_core::compile_with;
|
||||
#[cfg(unix)]
|
||||
pub use wasmer_runtime_core::fault::{pop_code_version, push_code_version};
|
||||
pub use wasmer_runtime_core::state::CodeVersion;
|
||||
|
||||
/// Enum used to select which compiler should be used to generate code.
|
||||
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub enum Backend {
|
||||
#[cfg(feature = "singlepass")]
|
||||
/// Singlepass backend
|
||||
Singlepass,
|
||||
#[cfg(feature = "cranelift")]
|
||||
/// Cranelift backend
|
||||
Cranelift,
|
||||
#[cfg(feature = "llvm")]
|
||||
/// LLVM backend
|
||||
LLVM,
|
||||
/// Auto backend
|
||||
Auto,
|
||||
}
|
||||
|
||||
impl Backend {
|
||||
/// Get a list of the currently enabled (via feature flag) backends.
|
||||
pub fn variants() -> &'static [&'static str] {
|
||||
&[
|
||||
#[cfg(feature = "singlepass")]
|
||||
"singlepass",
|
||||
#[cfg(feature = "cranelift")]
|
||||
"cranelift",
|
||||
#[cfg(feature = "llvm")]
|
||||
"llvm",
|
||||
"auto",
|
||||
]
|
||||
}
|
||||
|
||||
/// Stable string representation of the backend.
|
||||
/// It can be used as part of a cache key, for example.
|
||||
pub fn to_string(&self) -> &'static str {
|
||||
match self {
|
||||
#[cfg(feature = "singlepass")]
|
||||
Backend::Singlepass => "singlepass",
|
||||
#[cfg(feature = "cranelift")]
|
||||
Backend::Cranelift => "cranelift",
|
||||
#[cfg(feature = "llvm")]
|
||||
Backend::LLVM => "llvm",
|
||||
Backend::Auto => "auto",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Backend {
|
||||
fn default() -> Self {
|
||||
#[cfg(all(feature = "default-backend-singlepass", not(feature = "docs")))]
|
||||
return Backend::Singlepass;
|
||||
|
||||
#[cfg(any(feature = "default-backend-cranelift", feature = "docs"))]
|
||||
return Backend::Cranelift;
|
||||
|
||||
#[cfg(all(feature = "default-backend-llvm", not(feature = "docs")))]
|
||||
return Backend::LLVM;
|
||||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for Backend {
|
||||
type Err = String;
|
||||
fn from_str(s: &str) -> Result<Backend, String> {
|
||||
match s.to_lowercase().as_str() {
|
||||
#[cfg(feature = "singlepass")]
|
||||
"singlepass" => Ok(Backend::Singlepass),
|
||||
#[cfg(feature = "cranelift")]
|
||||
"cranelift" => Ok(Backend::Cranelift),
|
||||
#[cfg(feature = "llvm")]
|
||||
"llvm" => Ok(Backend::LLVM),
|
||||
"auto" => Ok(Backend::Auto),
|
||||
_ => Err(format!("The backend {} doesn't exist", s)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Compile WebAssembly binary code into a [`Module`].
|
||||
/// This function is useful if it is necessary to
|
||||
/// compile a module before it can be instantiated
|
||||
/// (otherwise, the [`instantiate`] function should be used).
|
||||
///
|
||||
/// [`Module`]: struct.Module.html
|
||||
/// [`instantiate`]: fn.instantiate.html
|
||||
///
|
||||
/// # Params:
|
||||
/// * `wasm`: A `&[u8]` containing the
|
||||
/// binary code of the wasm module you want to compile.
|
||||
/// # Errors:
|
||||
/// If the operation fails, the function returns `Err(error::CompileError::...)`.
|
||||
pub fn compile(wasm: &[u8]) -> crate::error::CompileResult<Module> {
|
||||
wasmer_runtime_core::compile_with(&wasm[..], &default_compiler())
|
||||
}
|
||||
|
||||
/// The same as `compile` but takes a `CompilerConfig` for the purpose of
|
||||
/// changing the compiler's behavior
|
||||
pub fn compile_with_config(
|
||||
wasm: &[u8],
|
||||
compiler_config: CompilerConfig,
|
||||
) -> crate::error::CompileResult<Module> {
|
||||
wasmer_runtime_core::compile_with_config(&wasm[..], &default_compiler(), compiler_config)
|
||||
}
|
||||
|
||||
/// The same as `compile_with_config` but takes a `Compiler` for the purpose of
|
||||
/// changing the backend.
|
||||
pub fn compile_with_config_with(
|
||||
wasm: &[u8],
|
||||
compiler_config: CompilerConfig,
|
||||
compiler: &dyn Compiler,
|
||||
) -> crate::error::CompileResult<Module> {
|
||||
wasmer_runtime_core::compile_with_config(&wasm[..], compiler, compiler_config)
|
||||
}
|
||||
|
||||
/// Copied from runtime core; TODO: figure out what we want to do here
|
||||
pub fn default_compiler() -> impl Compiler {
|
||||
#[cfg(any(
|
||||
all(
|
||||
feature = "default-backend-llvm",
|
||||
not(feature = "docs"),
|
||||
any(
|
||||
feature = "default-backend-cranelift",
|
||||
feature = "default-backend-singlepass"
|
||||
)
|
||||
),
|
||||
all(
|
||||
not(feature = "docs"),
|
||||
feature = "default-backend-cranelift",
|
||||
feature = "default-backend-singlepass"
|
||||
)
|
||||
))]
|
||||
compile_error!(
|
||||
"The `default-backend-X` features are mutually exclusive. Please choose just one"
|
||||
);
|
||||
|
||||
#[cfg(all(feature = "default-backend-llvm", not(feature = "docs")))]
|
||||
use wasmer_llvm_backend::LLVMCompiler as DefaultCompiler;
|
||||
|
||||
#[cfg(all(feature = "default-backend-singlepass", not(feature = "docs")))]
|
||||
use wasmer_singlepass_backend::SinglePassCompiler as DefaultCompiler;
|
||||
|
||||
#[cfg(any(feature = "default-backend-cranelift", feature = "docs"))]
|
||||
use wasmer_clif_backend::CraneliftCompiler as DefaultCompiler;
|
||||
|
||||
DefaultCompiler::new()
|
||||
}
|
||||
|
||||
/// Get the `Compiler` as a trait object for the given `Backend`.
|
||||
/// Returns `Option` because support for the requested `Compiler` may
|
||||
/// not be enabled by feature flags.
|
||||
///
|
||||
/// To get a list of the enabled backends as strings, call `Backend::variants()`.
|
||||
pub fn compiler_for_backend(backend: Backend) -> Option<Box<dyn Compiler>> {
|
||||
match backend {
|
||||
#[cfg(feature = "cranelift")]
|
||||
Backend::Cranelift => Some(Box::new(wasmer_clif_backend::CraneliftCompiler::new())),
|
||||
|
||||
#[cfg(any(feature = "singlepass"))]
|
||||
Backend::Singlepass => Some(Box::new(
|
||||
wasmer_singlepass_backend::SinglePassCompiler::new(),
|
||||
)),
|
||||
|
||||
#[cfg(feature = "llvm")]
|
||||
Backend::LLVM => Some(Box::new(wasmer_llvm_backend::LLVMCompiler::new())),
|
||||
|
||||
Backend::Auto => {
|
||||
#[cfg(feature = "default-backend-singlepass")]
|
||||
return Some(Box::new(
|
||||
wasmer_singlepass_backend::SinglePassCompiler::new(),
|
||||
));
|
||||
#[cfg(feature = "default-backend-cranelift")]
|
||||
return Some(Box::new(wasmer_clif_backend::CraneliftCompiler::new()));
|
||||
#[cfg(feature = "default-backend-llvm")]
|
||||
return Some(Box::new(wasmer_llvm_backend::LLVMCompiler::new()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod codegen {
|
||||
//! Types and functions for generating native code.
|
||||
pub use wasmer_runtime_core::codegen::ModuleCodeGenerator;
|
||||
}
|
||||
|
||||
// TODO: `import` or `imports`?
|
||||
pub mod import {
|
||||
//! Types and functions for Wasm imports.
|
||||
pub use wasmer_runtime_core::import::{ImportObject, ImportObjectIterator, Namespace};
|
||||
pub use wasmer_runtime_core::import::{ImportObject, ImportObjectIterator, LikeNamespace, Namespace};
|
||||
pub use wasmer_runtime_core::types::{ExternDescriptor, ImportDescriptor};
|
||||
pub use wasmer_runtime_core::{func, imports};
|
||||
}
|
||||
@ -104,7 +307,11 @@ pub mod types {
|
||||
|
||||
pub mod error {
|
||||
//! Various error types returned by Wasmer APIs.
|
||||
pub use wasmer_runtime_core::error::{CompileError, CompileResult};
|
||||
pub use wasmer_runtime_core::backend::ExceptionCode;
|
||||
pub use wasmer_runtime_core::error::{
|
||||
CallError, CompileError, CompileResult, CreationError, Error, LinkError, ResolveError,
|
||||
RuntimeError,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum CompileFromFileError {
|
||||
@ -152,51 +359,16 @@ pub trait CompiledModule {
|
||||
fn validate(bytes: impl AsRef<[u8]>) -> error::CompileResult<()>;
|
||||
}
|
||||
|
||||
use wasmer_runtime_core::backend::Compiler;
|
||||
|
||||
/// Copied from runtime core; TODO: figure out what we want to do here
|
||||
pub fn default_compiler() -> impl Compiler {
|
||||
#[cfg(any(
|
||||
all(
|
||||
feature = "default-backend-llvm",
|
||||
not(feature = "docs"),
|
||||
any(
|
||||
feature = "default-backend-cranelift",
|
||||
feature = "default-backend-singlepass"
|
||||
)
|
||||
),
|
||||
all(
|
||||
not(feature = "docs"),
|
||||
feature = "default-backend-cranelift",
|
||||
feature = "default-backend-singlepass"
|
||||
)
|
||||
))]
|
||||
compile_error!(
|
||||
"The `default-backend-X` features are mutually exclusive. Please choose just one"
|
||||
);
|
||||
|
||||
#[cfg(all(feature = "default-backend-llvm", not(feature = "docs")))]
|
||||
use wasmer_llvm_backend::LLVMCompiler as DefaultCompiler;
|
||||
|
||||
#[cfg(all(feature = "default-backend-singlepass", not(feature = "docs")))]
|
||||
use wasmer_singlepass_backend::SinglePassCompiler as DefaultCompiler;
|
||||
|
||||
#[cfg(any(feature = "default-backend-cranelift", feature = "docs"))]
|
||||
use wasmer_clif_backend::CraneliftCompiler as DefaultCompiler;
|
||||
|
||||
DefaultCompiler::new()
|
||||
}
|
||||
|
||||
// this implementation should be moved
|
||||
impl CompiledModule for Module {
|
||||
fn new(bytes: impl AsRef<[u8]>) -> error::CompileResult<Module> {
|
||||
let bytes = bytes.as_ref();
|
||||
wasmer_runtime_core::compile_with(bytes, &default_compiler())
|
||||
wasmer_runtime_core::compile_with(bytes, &compiler::default_compiler())
|
||||
}
|
||||
|
||||
fn from_binary(bytes: impl AsRef<[u8]>) -> error::CompileResult<Module> {
|
||||
let bytes = bytes.as_ref();
|
||||
wasmer_runtime_core::compile_with(bytes, &default_compiler())
|
||||
wasmer_runtime_core::compile_with(bytes, &compiler::default_compiler())
|
||||
}
|
||||
|
||||
fn from_binary_unchecked(bytes: impl AsRef<[u8]>) -> error::CompileResult<Module> {
|
||||
|
@ -1,3 +0,0 @@
|
||||
# Dev Utils
|
||||
|
||||
This is shared code between the modules for testing and development only. Code in this crate will not be shipped.
|
@ -1,5 +0,0 @@
|
||||
#![doc(html_favicon_url = "https://wasmer.io/static/icons/favicon.ico")]
|
||||
#![doc(html_logo_url = "https://avatars3.githubusercontent.com/u/44205449?s=200&v=4")]
|
||||
|
||||
pub mod file_descriptor;
|
||||
pub mod stdio;
|
@ -1,28 +0,0 @@
|
||||
[package]
|
||||
name = "wasmer-emscripten-tests"
|
||||
version = "0.16.2"
|
||||
description = "Tests for our Emscripten implementation"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
edition = "2018"
|
||||
publish = false
|
||||
build = "build/mod.rs"
|
||||
|
||||
[dependencies]
|
||||
wasmer-emscripten = { path = "../emscripten", version = "0.16.2" }
|
||||
wasmer-runtime = { path = "../runtime", version = "0.16.2", default-features = false }
|
||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.16.2", optional = true}
|
||||
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.16.2", optional = true, features = ["test"] }
|
||||
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.16.2", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
wabt = "0.9.1"
|
||||
wasmer-dev-utils = { path = "../dev-utils", version = "0.16.2"}
|
||||
|
||||
[build-dependencies]
|
||||
glob = "0.3"
|
||||
|
||||
[features]
|
||||
clif = ["wasmer-clif-backend", "wasmer-runtime/default-backend-cranelift"]
|
||||
singlepass = ["wasmer-singlepass-backend", "wasmer-runtime/default-backend-singlepass"]
|
||||
llvm = ["wasmer-llvm-backend", "wasmer-runtime/default-backend-llvm"]
|
@ -1 +0,0 @@
|
||||
mod emtests;
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_clock_gettime() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/clock_gettime.wasm",
|
||||
"clock_gettime",
|
||||
vec![],
|
||||
"../../emtests/clock_gettime.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_env() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/env.wasm",
|
||||
"env",
|
||||
vec![],
|
||||
"../../emtests/env.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_localtime() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/localtime.wasm",
|
||||
"localtime",
|
||||
vec![],
|
||||
"../../emtests/localtime.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_printf() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/printf.wasm",
|
||||
"printf",
|
||||
vec![],
|
||||
"../../emtests/printf.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_puts() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/puts.wasm",
|
||||
"puts",
|
||||
vec![],
|
||||
"../../emtests/puts.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_addr_of_stacked() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_addr_of_stacked.wasm",
|
||||
"test_addr_of_stacked",
|
||||
vec![],
|
||||
"../../emtests/test_addr_of_stacked.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_alloca() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_alloca.wasm",
|
||||
"test_alloca",
|
||||
vec![],
|
||||
"../../emtests/test_alloca.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_alloca_stack() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_alloca_stack.wasm",
|
||||
"test_alloca_stack",
|
||||
vec![],
|
||||
"../../emtests/test_alloca_stack.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_array2() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_array2.wasm",
|
||||
"test_array2",
|
||||
vec![],
|
||||
"../../emtests/test_array2.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_array2b() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_array2b.wasm",
|
||||
"test_array2b",
|
||||
vec![],
|
||||
"../../emtests/test_array2b.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_atomic() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_atomic.wasm",
|
||||
"test_atomic",
|
||||
vec![],
|
||||
"../../emtests/test_atomic.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_atox() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_atoX.wasm",
|
||||
"test_atox",
|
||||
vec![],
|
||||
"../../emtests/test_atoX.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_bsearch() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_bsearch.wasm",
|
||||
"test_bsearch",
|
||||
vec![],
|
||||
"../../emtests/test_bsearch.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_complex() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_complex.wasm",
|
||||
"test_complex",
|
||||
vec![],
|
||||
"../../emtests/test_complex.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_double_varargs() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_double_varargs.wasm",
|
||||
"test_double_varargs",
|
||||
vec![],
|
||||
"../../emtests/test_double_varargs.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_erf() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_erf.wasm",
|
||||
"test_erf",
|
||||
vec![],
|
||||
"../../emtests/test_erf.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_errar() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_errar.wasm",
|
||||
"test_errar",
|
||||
vec![],
|
||||
"../../emtests/test_errar.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_flexarray_struct() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_flexarray_struct.wasm",
|
||||
"test_flexarray_struct",
|
||||
vec![],
|
||||
"../../emtests/test_flexarray_struct.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_float32_precise() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_float32_precise.wasm",
|
||||
"test_float32_precise",
|
||||
vec![],
|
||||
"../../emtests/test_float32_precise.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_frexp() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_frexp.wasm",
|
||||
"test_frexp",
|
||||
vec![],
|
||||
"../../emtests/test_frexp.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_funcptr() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_funcptr.wasm",
|
||||
"test_funcptr",
|
||||
vec![],
|
||||
"../../emtests/test_funcptr.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_funcptr_namecollide() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_funcptr_namecollide.wasm",
|
||||
"test_funcptr_namecollide",
|
||||
vec![],
|
||||
"../../emtests/test_funcptr_namecollide.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_funcptrfunc() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_funcptrfunc.wasm",
|
||||
"test_funcptrfunc",
|
||||
vec![],
|
||||
"../../emtests/test_funcptrfunc.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_funcs() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_funcs.wasm",
|
||||
"test_funcs",
|
||||
vec![],
|
||||
"../../emtests/test_funcs.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_functionpointer_libfunc_varargs() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_functionpointer_libfunc_varargs.wasm",
|
||||
"test_functionpointer_libfunc_varargs",
|
||||
vec![],
|
||||
"../../emtests/test_functionpointer_libfunc_varargs.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_fwrite_0() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_fwrite_0.wasm",
|
||||
"test_fwrite_0",
|
||||
vec![],
|
||||
"../../emtests/test_fwrite_0.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_getcwd() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_getcwd.wasm",
|
||||
"test_getcwd",
|
||||
vec![],
|
||||
"../../emtests/test_getcwd.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_getgep() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_getgep.wasm",
|
||||
"test_getgep",
|
||||
vec![],
|
||||
"../../emtests/test_getgep.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_globaldoubles() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_globaldoubles.wasm",
|
||||
"test_globaldoubles",
|
||||
vec![],
|
||||
"../../emtests/test_globaldoubles.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_globals() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_globals.wasm",
|
||||
"test_globals",
|
||||
vec![],
|
||||
"../../emtests/test_globals.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_hello_world() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_hello_world.wasm",
|
||||
"test_hello_world",
|
||||
vec![],
|
||||
"../../emtests/test_hello_world.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_i32_mul_precise() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_i32_mul_precise.wasm",
|
||||
"test_i32_mul_precise",
|
||||
vec![],
|
||||
"../../emtests/test_i32_mul_precise.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_i64_4() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_i64_4.wasm",
|
||||
"test_i64_4",
|
||||
vec![],
|
||||
"../../emtests/test_i64_4.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_i64_cmp2() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_i64_cmp2.wasm",
|
||||
"test_i64_cmp2",
|
||||
vec![],
|
||||
"../../emtests/test_i64_cmp2.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_i64_i16() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_i64_i16.wasm",
|
||||
"test_i64_i16",
|
||||
vec![],
|
||||
"../../emtests/test_i64_i16.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_i64_llabs() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_i64_llabs.wasm",
|
||||
"test_i64_llabs",
|
||||
vec![],
|
||||
"../../emtests/test_i64_llabs.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_i64_precise() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_i64_precise.wasm",
|
||||
"test_i64_precise",
|
||||
vec![],
|
||||
"../../emtests/test_i64_precise.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_i64_precise_needed() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_i64_precise_needed.wasm",
|
||||
"test_i64_precise_needed",
|
||||
vec![],
|
||||
"../../emtests/test_i64_precise_needed.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_i64_precise_unneeded() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_i64_precise_unneeded.wasm",
|
||||
"test_i64_precise_unneeded",
|
||||
vec![],
|
||||
"../../emtests/test_i64_precise_unneeded.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_i64_qdouble() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_i64_qdouble.wasm",
|
||||
"test_i64_qdouble",
|
||||
vec![],
|
||||
"../../emtests/test_i64_qdouble.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_i64_umul() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_i64_umul.wasm",
|
||||
"test_i64_umul",
|
||||
vec![],
|
||||
"../../emtests/test_i64_umul.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_i64_zextneg() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_i64_zextneg.wasm",
|
||||
"test_i64_zextneg",
|
||||
vec![],
|
||||
"../../emtests/test_i64_zextneg.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_if() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_if.wasm",
|
||||
"test_if",
|
||||
vec![],
|
||||
"../../emtests/test_if.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_if_else() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_if_else.wasm",
|
||||
"test_if_else",
|
||||
vec![],
|
||||
"../../emtests/test_if_else.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_indirectbr() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_indirectbr.wasm",
|
||||
"test_indirectbr",
|
||||
vec![],
|
||||
"../../emtests/test_indirectbr.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_isnan() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_isnan.wasm",
|
||||
"test_isnan",
|
||||
vec![],
|
||||
"../../emtests/test_isnan.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_libcextra() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_libcextra.wasm",
|
||||
"test_libcextra",
|
||||
vec![],
|
||||
"../../emtests/test_libcextra.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_libgen() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_libgen.wasm",
|
||||
"test_libgen",
|
||||
vec![],
|
||||
"../../emtests/test_libgen.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_literal_negative_zero() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_literal_negative_zero.wasm",
|
||||
"test_literal_negative_zero",
|
||||
vec![],
|
||||
"../../emtests/test_literal_negative_zero.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_llrint() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_llrint.wasm",
|
||||
"test_llrint",
|
||||
vec![],
|
||||
"../../emtests/test_llrint.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_llvm_fabs() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_llvm_fabs.wasm",
|
||||
"test_llvm_fabs",
|
||||
vec![],
|
||||
"../../emtests/test_llvm_fabs.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_llvmswitch() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_llvmswitch.wasm",
|
||||
"test_llvmswitch",
|
||||
vec![],
|
||||
"../../emtests/test_llvmswitch.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_longjmp() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_longjmp.wasm",
|
||||
"test_longjmp",
|
||||
vec![],
|
||||
"../../emtests/test_longjmp.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_longjmp2() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_longjmp2.wasm",
|
||||
"test_longjmp2",
|
||||
vec![],
|
||||
"../../emtests/test_longjmp2.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_longjmp3() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_longjmp3.wasm",
|
||||
"test_longjmp3",
|
||||
vec![],
|
||||
"../../emtests/test_longjmp3.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_longjmp4() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_longjmp4.wasm",
|
||||
"test_longjmp4",
|
||||
vec![],
|
||||
"../../emtests/test_longjmp4.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_longjmp_funcptr() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_longjmp_funcptr.wasm",
|
||||
"test_longjmp_funcptr",
|
||||
vec![],
|
||||
"../../emtests/test_longjmp_funcptr.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_longjmp_repeat() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_longjmp_repeat.wasm",
|
||||
"test_longjmp_repeat",
|
||||
vec![],
|
||||
"../../emtests/test_longjmp_repeat.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_longjmp_stacked() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_longjmp_stacked.wasm",
|
||||
"test_longjmp_stacked",
|
||||
vec![],
|
||||
"../../emtests/test_longjmp_stacked.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_longjmp_throw() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_longjmp_throw.wasm",
|
||||
"test_longjmp_throw",
|
||||
vec![],
|
||||
"../../emtests/test_longjmp_throw.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_longjmp_unwind() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_longjmp_unwind.wasm",
|
||||
"test_longjmp_unwind",
|
||||
vec![],
|
||||
"../../emtests/test_longjmp_unwind.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_loop() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_loop.wasm",
|
||||
"test_loop",
|
||||
vec![],
|
||||
"../../emtests/test_loop.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_memcpy2() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_memcpy2.wasm",
|
||||
"test_memcpy2",
|
||||
vec![],
|
||||
"../../emtests/test_memcpy2.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_memcpy3() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_memcpy3.wasm",
|
||||
"test_memcpy3",
|
||||
vec![],
|
||||
"../../emtests/test_memcpy3.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_memmove() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_memmove.wasm",
|
||||
"test_memmove",
|
||||
vec![],
|
||||
"../../emtests/test_memmove.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_memmove2() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_memmove2.wasm",
|
||||
"test_memmove2",
|
||||
vec![],
|
||||
"../../emtests/test_memmove2.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_memmove3() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_memmove3.wasm",
|
||||
"test_memmove3",
|
||||
vec![],
|
||||
"../../emtests/test_memmove3.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_memset() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_memset.wasm",
|
||||
"test_memset",
|
||||
vec![],
|
||||
"../../emtests/test_memset.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_negative_zero() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_negative_zero.wasm",
|
||||
"test_negative_zero",
|
||||
vec![],
|
||||
"../../emtests/test_negative_zero.out"
|
||||
);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#[test]
|
||||
fn test_test_nested_struct_varargs() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/test_nested_struct_varargs.wasm",
|
||||
"test_nested_struct_varargs",
|
||||
vec![],
|
||||
"../../emtests/test_nested_struct_varargs.out"
|
||||
);
|
||||
}
|
@ -140,10 +140,12 @@ extern "C" {
|
||||
pub fn lstat(path: *const libc::c_char, buf: *mut stat) -> c_int;
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "freebsd", target_os = "macos", target_os = "android")))]
|
||||
use libc::fallocate;
|
||||
#[cfg(target_os = "freebsd")]
|
||||
use libc::madvise;
|
||||
#[cfg(not(any(target_os = "freebsd", target_os = "macos")))]
|
||||
use libc::{fallocate, fdatasync, ftruncate64, lstat, madvise, wait4};
|
||||
use libc::{fdatasync, ftruncate64, lstat, madvise, wait4};
|
||||
|
||||
// Another conditional constant for name resolution: Macos et iOS use
|
||||
// SO_NOSIGPIPE as a setsockopt flag to disable SIGPIPE emission on socket.
|
||||
@ -1131,11 +1133,11 @@ pub fn ___syscall324(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
let _mode: c_int = varargs.get(ctx);
|
||||
let _offset: off_t = varargs.get(ctx);
|
||||
let _len: off_t = varargs.get(ctx);
|
||||
#[cfg(not(any(target_os = "freebsd", target_os = "macos")))]
|
||||
#[cfg(not(any(target_os = "freebsd", target_os = "macos", target_os = "android")))]
|
||||
unsafe {
|
||||
fallocate(_fd, _mode, _offset, _len)
|
||||
}
|
||||
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "android"))]
|
||||
{
|
||||
unimplemented!("emscripten::___syscall324 (fallocate) {}", _which)
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ use time;
|
||||
use super::env;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
use libc::{CLOCK_MONOTONIC, CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME};
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
|
@ -88,5 +88,7 @@ Here is the instructions that are implemented by this crate:
|
||||
| `string.lift_memory` | ✅ | ✅ | ✅ | `#memidx` is not supported; `#encoding` is not supported but UTF-8 is assumed |
|
||||
| `string.lower_memory` | ✅ | ✅ | ✅ | `#memidx` is not supported; `#encoding` is not supported but UTF-8 is assumed |
|
||||
| `string.size` | ✅ | ✅ | ✅ | `#encoding` is not supported but UTF-8 is assumed |
|
||||
| `record.lift` | ✅ | ✅ | ✅ | |
|
||||
| `record.lower` | ✅ | ✅ | ✅ | |
|
||||
| `call-adapter` | ❌ | ❌ | ❌ | |
|
||||
| `defer-call-core` | ❌ | ❌ | ❌ | |
|
||||
|
@ -232,16 +232,7 @@ fn instruction<'input, E: ParseError<&'input [u8]>>(
|
||||
0x21 => (input, Instruction::I64FromU64),
|
||||
|
||||
0x22 => (input, Instruction::StringLiftMemory),
|
||||
0x23 => {
|
||||
consume!((input, argument_0) = uleb(input)?);
|
||||
|
||||
(
|
||||
input,
|
||||
Instruction::StringLowerMemory {
|
||||
allocator_index: argument_0 as u32,
|
||||
},
|
||||
)
|
||||
}
|
||||
0x23 => (input, Instruction::StringLowerMemory),
|
||||
0x24 => (input, Instruction::StringSize),
|
||||
|
||||
0x25 => {
|
||||
@ -764,7 +755,7 @@ mod tests {
|
||||
0x20, // I64FromU32
|
||||
0x21, // I64FromU64
|
||||
0x22, // StringLiftMemory
|
||||
0x23, 0x01, // StringLowerMemory { allocator_index: 1 }
|
||||
0x23, // StringLowerMemory
|
||||
0x24, // StringSize
|
||||
0x25, 0x01, // RecordLift { type_index: 1 },
|
||||
0x26, 0x01, // RecordLower { type_index: 1 },
|
||||
@ -808,7 +799,7 @@ mod tests {
|
||||
Instruction::I64FromU32,
|
||||
Instruction::I64FromU64,
|
||||
Instruction::StringLiftMemory,
|
||||
Instruction::StringLowerMemory { allocator_index: 1 },
|
||||
Instruction::StringLowerMemory,
|
||||
Instruction::StringSize,
|
||||
Instruction::RecordLift { type_index: 1 },
|
||||
Instruction::RecordLower { type_index: 1 },
|
||||
|
@ -309,9 +309,7 @@ impl<'a> Parse<'a> for Instruction {
|
||||
} else if lookahead.peek::<keyword::string_lower_memory>() {
|
||||
parser.parse::<keyword::string_lower_memory>()?;
|
||||
|
||||
Ok(Instruction::StringLowerMemory {
|
||||
allocator_index: parser.parse()?,
|
||||
})
|
||||
Ok(Instruction::StringLowerMemory)
|
||||
} else if lookahead.peek::<keyword::string_size>() {
|
||||
parser.parse::<keyword::string_size>()?;
|
||||
|
||||
@ -770,7 +768,7 @@ mod tests {
|
||||
"i64.from_u32",
|
||||
"i64.from_u64",
|
||||
"string.lift_memory",
|
||||
"string.lower_memory 42",
|
||||
"string.lower_memory",
|
||||
"string.size",
|
||||
"record.lift 42",
|
||||
"record.lower 42",
|
||||
@ -811,9 +809,7 @@ mod tests {
|
||||
Instruction::I64FromU32,
|
||||
Instruction::I64FromU64,
|
||||
Instruction::StringLiftMemory,
|
||||
Instruction::StringLowerMemory {
|
||||
allocator_index: 42,
|
||||
},
|
||||
Instruction::StringLowerMemory,
|
||||
Instruction::StringSize,
|
||||
Instruction::RecordLift { type_index: 42 },
|
||||
Instruction::RecordLower { type_index: 42 },
|
||||
|
@ -170,9 +170,9 @@ where
|
||||
outputs.to_bytes(writer)?;
|
||||
}
|
||||
|
||||
Type::Record(RecordType { fields }) => {
|
||||
Type::Record(record_type) => {
|
||||
TypeKind::Record.to_bytes(writer)?;
|
||||
fields.to_bytes(writer)?;
|
||||
record_type.to_bytes(writer)?;
|
||||
}
|
||||
}
|
||||
|
||||
@ -331,10 +331,7 @@ where
|
||||
Instruction::I64FromU64 => 0x21_u8.to_bytes(writer)?,
|
||||
|
||||
Instruction::StringLiftMemory => 0x22_u8.to_bytes(writer)?,
|
||||
Instruction::StringLowerMemory { allocator_index } => {
|
||||
0x23_u8.to_bytes(writer)?;
|
||||
(*allocator_index as u64).to_bytes(writer)?;
|
||||
}
|
||||
Instruction::StringLowerMemory => 0x23_u8.to_bytes(writer)?,
|
||||
Instruction::StringSize => 0x24_u8.to_bytes(writer)?,
|
||||
|
||||
Instruction::RecordLift { type_index } => {
|
||||
@ -688,7 +685,7 @@ mod tests {
|
||||
Instruction::I64FromU32,
|
||||
Instruction::I64FromU64,
|
||||
Instruction::StringLiftMemory,
|
||||
Instruction::StringLowerMemory { allocator_index: 1 },
|
||||
Instruction::StringLowerMemory,
|
||||
Instruction::StringSize,
|
||||
Instruction::RecordLift { type_index: 1 },
|
||||
Instruction::RecordLower { type_index: 1 },
|
||||
@ -730,7 +727,7 @@ mod tests {
|
||||
0x20, // I64FromU32
|
||||
0x21, // I64FromU64
|
||||
0x22, // StringLiftMemory
|
||||
0x23, 0x01, // StringLowerMemory { allocator_index: 1 }
|
||||
0x23, // StringLowerMemory
|
||||
0x24, // StringSize
|
||||
0x025, 0x01, // RecordLift { type_index: 1 }
|
||||
0x026, 0x01, // RecordLower { type_index: 1 }
|
||||
|
@ -135,9 +135,7 @@ impl ToString for &Instruction {
|
||||
Instruction::I64FromU32 => "i64.from_u32".into(),
|
||||
Instruction::I64FromU64 => "i64.from_u64".into(),
|
||||
Instruction::StringLiftMemory => "string.lift_memory".into(),
|
||||
Instruction::StringLowerMemory { allocator_index } => {
|
||||
format!("string.lower_memory {}", allocator_index)
|
||||
}
|
||||
Instruction::StringLowerMemory => "string.lower_memory".into(),
|
||||
Instruction::StringSize => "string.size".into(),
|
||||
Instruction::RecordLift { type_index } => format!("record.lift {}", type_index),
|
||||
Instruction::RecordLower { type_index } => format!("record.lower {}", type_index),
|
||||
@ -462,10 +460,7 @@ mod tests {
|
||||
(&Instruction::I64FromU32).to_string(),
|
||||
(&Instruction::I64FromU64).to_string(),
|
||||
(&Instruction::StringLiftMemory).to_string(),
|
||||
(&Instruction::StringLowerMemory {
|
||||
allocator_index: 42,
|
||||
})
|
||||
.to_string(),
|
||||
(&Instruction::StringLowerMemory).to_string(),
|
||||
(&Instruction::StringSize).to_string(),
|
||||
(&Instruction::RecordLift { type_index: 42 }).to_string(),
|
||||
(&Instruction::RecordLower { type_index: 42 }).to_string(),
|
||||
@ -506,7 +501,7 @@ mod tests {
|
||||
"i64.from_u32",
|
||||
"i64.from_u64",
|
||||
"string.lift_memory",
|
||||
"string.lower_memory 42",
|
||||
"string.lower_memory",
|
||||
"string.size",
|
||||
"record.lift 42",
|
||||
"record.lower 42",
|
||||
|
@ -130,10 +130,7 @@ pub enum Instruction {
|
||||
StringLiftMemory,
|
||||
|
||||
/// The `string.lower_memory` instruction.
|
||||
StringLowerMemory {
|
||||
/// The allocator function index.
|
||||
allocator_index: u32,
|
||||
},
|
||||
StringLowerMemory,
|
||||
|
||||
/// The `string.size` instruction.
|
||||
StringSize,
|
||||
|
@ -2,13 +2,7 @@ use super::to_native;
|
||||
use crate::{
|
||||
ast::InterfaceType,
|
||||
errors::{InstructionError, InstructionErrorKind},
|
||||
interpreter::{
|
||||
wasm::{
|
||||
structures::{FunctionIndex, TypedIndex},
|
||||
values::InterfaceValue,
|
||||
},
|
||||
Instruction,
|
||||
},
|
||||
interpreter::{wasm::values::InterfaceValue, Instruction},
|
||||
};
|
||||
use std::{cell::Cell, convert::TryInto};
|
||||
|
||||
@ -75,37 +69,20 @@ executable_instruction!(
|
||||
);
|
||||
|
||||
executable_instruction!(
|
||||
string_lower_memory(allocator_index: u32, instruction: Instruction) -> _ {
|
||||
string_lower_memory(instruction: Instruction) -> _ {
|
||||
move |runtime| -> _ {
|
||||
let instance = &mut runtime.wasm_instance;
|
||||
let index = FunctionIndex::new(allocator_index as usize);
|
||||
|
||||
let allocator = instance.local_or_import(index).ok_or_else(|| {
|
||||
let inputs = runtime.stack.pop(2).ok_or_else(|| {
|
||||
InstructionError::new(
|
||||
instruction,
|
||||
InstructionErrorKind::LocalOrImportIsMissing { function_index: allocator_index },
|
||||
InstructionErrorKind::StackIsTooSmall { needed: 2 },
|
||||
)
|
||||
})?;
|
||||
|
||||
if allocator.inputs() != [InterfaceType::I32] || allocator.outputs() != [InterfaceType::I32] {
|
||||
return Err(InstructionError::new(
|
||||
instruction,
|
||||
InstructionErrorKind::LocalOrImportSignatureMismatch {
|
||||
function_index: allocator_index,
|
||||
expected: (vec![InterfaceType::I32], vec![InterfaceType::I32]),
|
||||
received: (allocator.inputs().to_vec(), allocator.outputs().to_vec()),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
let string = runtime.stack.pop1().ok_or_else(|| {
|
||||
InstructionError::new(
|
||||
instruction,
|
||||
InstructionErrorKind::StackIsTooSmall { needed: 1 },
|
||||
)
|
||||
})?;
|
||||
|
||||
let string: String = to_native(&string, instruction)?;
|
||||
let string_pointer: usize = to_native::<i32>(&inputs[0], instruction)?
|
||||
.try_into()
|
||||
.map_err(|e| (e, "pointer").into())
|
||||
.map_err(|k| InstructionError::new(instruction, k))?;
|
||||
let string: String = to_native(&inputs[1], instruction)?;
|
||||
let string_bytes = string.as_bytes();
|
||||
let string_length: i32 = string_bytes.len().try_into().map_err(|_| {
|
||||
InstructionError::new(
|
||||
@ -114,19 +91,7 @@ executable_instruction!(
|
||||
)
|
||||
})?;
|
||||
|
||||
let outputs = allocator.call(&[InterfaceValue::I32(string_length)]).map_err(|_| {
|
||||
InstructionError::new(
|
||||
instruction,
|
||||
InstructionErrorKind::LocalOrImportCall { function_index: allocator_index },
|
||||
)
|
||||
})?;
|
||||
let string_pointer: u32 = to_native::<i32>(&outputs[0], instruction)?.try_into().map_err(|_| {
|
||||
InstructionError::new(
|
||||
instruction,
|
||||
InstructionErrorKind::NegativeValue { subject: "string_pointer" },
|
||||
)
|
||||
})?;
|
||||
|
||||
let instance = &mut runtime.wasm_instance;
|
||||
let memory_index: u32 = 0;
|
||||
let memory_view = instance
|
||||
.memory(memory_index as usize)
|
||||
@ -153,7 +118,7 @@ executable_instruction!(
|
||||
executable_instruction!(
|
||||
string_size(instruction: Instruction) -> _ {
|
||||
move |runtime| -> _ {
|
||||
match runtime.stack.peek1() {
|
||||
match runtime.stack.pop1() {
|
||||
Some(InterfaceValue::String(string)) => {
|
||||
let length = string.len() as i32;
|
||||
runtime.stack.push(InterfaceValue::I32(length));
|
||||
@ -165,7 +130,7 @@ executable_instruction!(
|
||||
instruction,
|
||||
InstructionErrorKind::InvalidValueOnTheStack {
|
||||
expected_type: InterfaceType::String,
|
||||
received_type: value.into(),
|
||||
received_type: (&value).into(),
|
||||
},
|
||||
)),
|
||||
|
||||
@ -313,7 +278,11 @@ mod tests {
|
||||
test_string_lower_memory =
|
||||
instructions: [
|
||||
Instruction::ArgumentGet { index: 0 },
|
||||
Instruction::StringLowerMemory { allocator_index: 43 },
|
||||
Instruction::StringSize,
|
||||
Instruction::CallCore { function_index: 43 },
|
||||
Instruction::ArgumentGet { index: 0 },
|
||||
Instruction::StringLowerMemory,
|
||||
|
||||
],
|
||||
invocation_inputs: [InterfaceValue::String("Hello, World!".into())],
|
||||
instance: Instance::new(),
|
||||
@ -329,7 +298,10 @@ mod tests {
|
||||
test_string__roundtrip =
|
||||
instructions: [
|
||||
Instruction::ArgumentGet { index: 0 },
|
||||
Instruction::StringLowerMemory { allocator_index: 43 },
|
||||
Instruction::StringSize,
|
||||
Instruction::CallCore { function_index: 43 },
|
||||
Instruction::ArgumentGet { index: 0 },
|
||||
Instruction::StringLowerMemory,
|
||||
Instruction::StringLiftMemory,
|
||||
],
|
||||
invocation_inputs: [InterfaceValue::String("Hello, World!".into())],
|
||||
@ -337,70 +309,14 @@ mod tests {
|
||||
stack: [InterfaceValue::String("Hello, World!".into())],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_string_lower_memory__allocator_does_not_exist =
|
||||
instructions: [Instruction::StringLowerMemory { allocator_index: 43 }],
|
||||
invocation_inputs: [],
|
||||
instance: Instance { ..Default::default() },
|
||||
error: r#"`string.lower_memory 43` the local or import function `43` doesn't exist"#,
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_string_lower_memory__stack_is_too_small =
|
||||
instructions: [
|
||||
Instruction::StringLowerMemory { allocator_index: 43 }
|
||||
// ^^ `43` expects 1 value on the stack, none is present
|
||||
Instruction::StringLowerMemory,
|
||||
],
|
||||
invocation_inputs: [InterfaceValue::String("Hello, World!".into())],
|
||||
invocation_inputs: [],
|
||||
instance: Instance::new(),
|
||||
error: r#"`string.lower_memory 43` needed to read `1` value(s) from the stack, but it doesn't contain enough data"#,
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_string_lower_memory__failure_when_calling_the_allocator =
|
||||
instructions: [
|
||||
Instruction::ArgumentGet { index: 0 },
|
||||
Instruction::StringLowerMemory { allocator_index: 153 }
|
||||
],
|
||||
invocation_inputs: [InterfaceValue::String("Hello, World!".into())],
|
||||
instance: {
|
||||
let mut instance = Instance::new();
|
||||
instance.locals_or_imports.insert(
|
||||
153,
|
||||
LocalImport {
|
||||
inputs: vec![InterfaceType::I32],
|
||||
outputs: vec![InterfaceType::I32],
|
||||
function: |_| Err(()),
|
||||
// ^^^^^^^ function fails
|
||||
},
|
||||
);
|
||||
|
||||
instance
|
||||
},
|
||||
error: r#"`string.lower_memory 153` failed while calling the local or import function `153`"#,
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_string_lower_memory__invalid_allocator_signature =
|
||||
instructions: [
|
||||
Instruction::ArgumentGet { index: 0 },
|
||||
Instruction::StringLowerMemory { allocator_index: 153 }
|
||||
],
|
||||
invocation_inputs: [InterfaceValue::String("Hello, World!".into())],
|
||||
instance: {
|
||||
let mut instance = Instance::new();
|
||||
instance.locals_or_imports.insert(
|
||||
153,
|
||||
LocalImport {
|
||||
inputs: vec![InterfaceType::I32, InterfaceType::I32],
|
||||
outputs: vec![],
|
||||
function: |_| Err(()),
|
||||
},
|
||||
);
|
||||
|
||||
instance
|
||||
},
|
||||
error: r#"`string.lower_memory 153` the local or import function `153` has the signature `[I32] -> [I32]` but it received values of kind `[I32, I32] -> []`"#,
|
||||
error: r#"`string.lower_memory` needed to read `2` value(s) from the stack, but it doesn't contain enough data"#,
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
@ -411,7 +327,7 @@ mod tests {
|
||||
],
|
||||
invocation_inputs: [InterfaceValue::String("Hello, World!".into())],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::String("Hello, World!".into()), InterfaceValue::I32(13)],
|
||||
stack: [InterfaceValue::I32(13)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user