Merge branch 'master' into parallel-compilation

# Conflicts:
#	src/webassembly/instance.rs
This commit is contained in:
Syrus Akbary
2018-11-20 16:30:25 -08:00
17 changed files with 690 additions and 436 deletions

View File

@ -7,6 +7,12 @@ jobs:
steps: steps:
- checkout - checkout
- run:
name: Pull submodules
command: |
# git pull --recurse-submodules
git submodule sync --recursive
git submodule update --recursive --init
- restore_cache: - restore_cache:
keys: keys:
- v4-test-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }} - v4-test-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }}

4
.gitmodules vendored Normal file
View File

@ -0,0 +1,4 @@
[submodule "cranelift"]
path = cranelift
url = git@github.com:WAFoundation/cranelift.git
fetchrecursesubmodules = true

153
Cargo.lock generated
View File

@ -14,6 +14,14 @@ dependencies = [
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "arrayvec"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "atty" name = "atty"
version = "0.2.11" version = "0.2.11"
@ -85,19 +93,17 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-bforest" name = "cranelift-bforest"
version = "0.23.0" version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cranelift-entity 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-entity 0.23.0",
] ]
[[package]] [[package]]
name = "cranelift-codegen" name = "cranelift-codegen"
version = "0.23.0" version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cranelift-bforest 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.23.0",
"cranelift-codegen-meta 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-codegen-meta 0.23.0",
"cranelift-entity 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-entity 0.23.0",
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -107,22 +113,19 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-codegen-meta" name = "cranelift-codegen-meta"
version = "0.23.0" version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cranelift-entity 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-entity 0.23.0",
] ]
[[package]] [[package]]
name = "cranelift-entity" name = "cranelift-entity"
version = "0.23.0" version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "cranelift-frontend" name = "cranelift-frontend"
version = "0.23.0" version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cranelift-codegen 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-codegen 0.23.0",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -130,9 +133,8 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-native" name = "cranelift-native"
version = "0.23.0" version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cranelift-codegen 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-codegen 0.23.0",
"raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -140,29 +142,64 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-wasm" name = "cranelift-wasm"
version = "0.23.0" version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cranelift-codegen 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-codegen 0.23.0",
"cranelift-entity 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-entity 0.23.0",
"cranelift-frontend 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-frontend 0.23.0",
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmparser 0.21.10 (registry+https://github.com/rust-lang/crates.io-index)", "wasmparser 0.21.10 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "crossbeam-deque"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "crossbeam-epoch"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
"scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "crossbeam-utils"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "docopt" name = "docopt"
version = "1.0.1" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "either"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "errno" name = "errno"
version = "0.2.4" version = "0.2.4"
@ -236,11 +273,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.1.0" version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "libc" name = "libc"
@ -287,6 +321,11 @@ dependencies = [
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "memoffset"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.11.0" version = "0.11.0"
@ -299,6 +338,19 @@ dependencies = [
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "nodrop"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "num_cpus"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "0.4.20" version = "0.4.20"
@ -335,6 +387,27 @@ dependencies = [
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "rayon"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rayon-core"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.1.40" version = "0.1.40"
@ -407,6 +480,11 @@ name = "ryu"
version = "0.2.6" version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "scopeguard"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "semver" name = "semver"
version = "0.9.0" version = "0.9.0"
@ -532,7 +610,7 @@ name = "thread_local"
version = "0.3.6" version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -594,16 +672,17 @@ dependencies = [
name = "wasmer" name = "wasmer"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cranelift-codegen 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-codegen 0.23.0",
"cranelift-entity 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-entity 0.23.0",
"cranelift-native 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-native 0.23.0",
"cranelift-wasm 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-wasm 0.23.0",
"docopt 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (git+https://github.com/rust-lang/libc)", "libc 0.2.43 (git+https://github.com/rust-lang/libc)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
@ -646,6 +725,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata] [metadata]
"checksum aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "68f56c7353e5a9547cbd76ed90f7bb5ffc3ba09d4ea9bd1d8c06c8b1142eeb5a" "checksum aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "68f56c7353e5a9547cbd76ed90f7bb5ffc3ba09d4ea9bd1d8c06c8b1142eeb5a"
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a"
"checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" "checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0"
@ -654,14 +734,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" "checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3"
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
"checksum cmake 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "6ec65ee4f9c9d16f335091d23693457ed4928657ba4982289d7fafee03bc614a" "checksum cmake 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "6ec65ee4f9c9d16f335091d23693457ed4928657ba4982289d7fafee03bc614a"
"checksum cranelift-bforest 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8c5f8e1ab4f73b59a98531a8013d8ed3ca7edb4e36984cb301d9c06f6892787b" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3"
"checksum cranelift-codegen 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4437ec8212686e6cdacfea75aaedb4ab8b013869be1e8693a4cb97a60f135035" "checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150"
"checksum cranelift-codegen-meta 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4eac16097b96e9f609df735555f2d1658531750fbc3805bca1daca7671aef9eb" "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9"
"checksum cranelift-entity 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9be3f82369346201c2e0cff720522e6eb55459e51c916b2199f25cff2058ca96"
"checksum cranelift-frontend 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d5d18ab2bc89a09b4275442a9559dc0f947b9a8ad9ae9ee89452a057df54ced"
"checksum cranelift-native 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d8d3b5951eefd89778dc59b0e33b556573a870538bc21982019bd4c4003b0a2d"
"checksum cranelift-wasm 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e5906a111814d43d84002ef974eb0c023804fd4d1866b34f43c1bb588a759ad8"
"checksum docopt 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d60c92df70dfaaabecc14b409fd79f55ba0f247780529db1d73bfa601e1d3ac0" "checksum docopt 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d60c92df70dfaaabecc14b409fd79f55ba0f247780529db1d73bfa601e1d3ac0"
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
"checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e"
"checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067"
"checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02"
@ -671,18 +748,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
"checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"
"checksum libc 0.2.43 (git+https://github.com/rust-lang/libc)" = "<none>" "checksum libc 0.2.43 (git+https://github.com/rust-lang/libc)" = "<none>"
"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
"checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" "checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f"
"checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" "checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9"
"checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b" "checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b"
"checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff" "checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff"
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
"checksum nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d37e713a259ff641624b6cb20e3b12b2952313ba36b6823c0f16e6cfd9e5de17" "checksum nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d37e713a259ff641624b6cb20e3b12b2952313ba36b6823c0f16e6cfd9e5de17"
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30"
"checksum proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "3d7b7eaaa90b4a90a932a9ea6666c95a389e424eff347f0f793979289429feee" "checksum proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "3d7b7eaaa90b4a90a932a9ea6666c95a389e424eff347f0f793979289429feee"
"checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5" "checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5"
"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" "checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd"
"checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d"
"checksum rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "373814f27745b2686b350dd261bfd24576a6fb0e2c5919b3a2b6005f820b0473"
"checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356"
"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1"
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341" "checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341"
@ -692,6 +774,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7" "checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "84257ccd054dc351472528c8587b4de2dbf0dc0fe2e634030c1a90bfdacebaa9" "checksum serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "84257ccd054dc351472528c8587b4de2dbf0dc0fe2e634030c1a90bfdacebaa9"

View File

@ -20,14 +20,14 @@ include = [
] ]
[dependencies] [dependencies]
cranelift-native = "0.23.0" # cranelift-native = "0.23.0"
# cranelift-native = { path = "cranelift/lib/native" } cranelift-native = { path = "cranelift/lib/native" }
cranelift-codegen = "0.23.0" # cranelift-codegen = "0.23.0"
# cranelift-codegen = { path = "cranelift/lib/codegen" } cranelift-codegen = { path = "cranelift/lib/codegen" }
cranelift-entity = "0.23.0" # cranelift-entity = "0.23.0"
# cranelift-entity = { path = "cranelift/lib/entity" } cranelift-entity = { path = "cranelift/lib/entity" }
cranelift-wasm = "0.23.0" # cranelift-wasm = "0.23.0"
# cranelift-wasm = { path = "cranelift/lib/wasm" } cranelift-wasm = { path = "cranelift/lib/wasm" }
docopt = "1.0.0" docopt = "1.0.0"
serde = "1.0.55" serde = "1.0.55"
serde_derive = "1.0.55" serde_derive = "1.0.55"
@ -44,6 +44,7 @@ target-lexicon = "0.2.0"
# libc = "0.2" # libc = "0.2"
libc = { git = "https://github.com/rust-lang/libc" } libc = { git = "https://github.com/rust-lang/libc" }
nix = "0.11" nix = "0.11"
rayon = "1.0.3"
[build-dependencies] [build-dependencies]
wabt = "0.7.1" wabt = "0.7.1"

View File

@ -26,7 +26,7 @@ To build this project you will need Rust and Cargo.
```sh ```sh
# checkout code and associated submodules # checkout code and associated submodules
git clone https://github.com/wafoundation/wasmer.git git clone --recursive https://github.com/wafoundation/wasmer.git
cd wasmer cd wasmer
# install tools # install tools

1
cranelift Submodule

Submodule cranelift added at cb62a1ead2

View File

@ -146,7 +146,3 @@ Currently cranelift_wasm::ModuleEnvironment does not provide `declare_table_impo
``` ```
- `elem.wast` - `elem.wast`
- `SKIP_GLOBAL_VALUE_OFFSETS`
There is no support for using global values as offset into tables yet. I believe this is an issue from cranelift side as well, so we will have to wait for it to be supported.
- `elem.wast`

View File

@ -50,21 +50,19 @@
(elem (i32.const 5) $f) (elem (i32.const 5) $f)
) )
;; SKIP_GLOBAL_VALUE_OFFSETS (module
;; (module (global (import "spectest" "global_i32") i32)
;; (global (import "spectest" "global_i32") i32) (table 1000 anyfunc)
;; (table 1000 anyfunc) (func $f)
;; (func $f) (elem (i32.const 0) $f)
;; (elem (get_global 0) $f) )
;; )
;; SKIP_GLOBAL_VALUE_OFFSETS (module
;; (module (global $g (import "spectest" "global_i32") i32)
;; (global $g (import "spectest" "global_i32") i32) (table 1000 anyfunc)
;; (table 1000 anyfunc) (func $f)
;; (func $f) (elem (get_global $g) $f)
;; (elem (get_global $g) $f) )
;; )
(module (module
(type $out-i32 (func (result i32))) (type $out-i32 (func (result i32)))
@ -352,33 +350,34 @@
(register "module1" $module1) (register "module1" $module1)
;; SKIP_SHARED_TABLE (assert_trap (invoke $module1 "call-7") "uninitialized element 7")
;; (assert_trap (invoke $module1 "call-7") "uninitialized element 7") (assert_return (invoke $module1 "call-8") (i32.const 65))
;; (assert_return (invoke $module1 "call-8") (i32.const 65)) (assert_return (invoke $module1 "call-9") (i32.const 66))
;; (assert_return (invoke $module1 "call-9") (i32.const 66))
(module $module2 ;; SKIP_SHARED_TABLE
(type $out-i32 (func (result i32))) ;; (module $module2
(import "module1" "shared-table" (table 10 anyfunc)) ;; (type $out-i32 (func (result i32)))
(elem (i32.const 7) $const-i32-c) ;; (import "module1" "shared-table" (table 10 anyfunc))
(elem (i32.const 8) $const-i32-d) ;; (elem (i32.const 7) $const-i32-c)
(func $const-i32-c (type $out-i32) (i32.const 67)) ;; (elem (i32.const 8) $const-i32-d)
(func $const-i32-d (type $out-i32) (i32.const 68)) ;; (func $const-i32-c (type $out-i32) (i32.const 67))
) ;; (func $const-i32-d (type $out-i32) (i32.const 68))
;; )
;; SKIP_SHARED_TABLE ;; SKIP_SHARED_TABLE
;; (assert_return (invoke $module1 "call-7") (i32.const 67)) ;; (assert_return (invoke $module1 "call-7") (i32.const 67))
;; (assert_return (invoke $module1 "call-8") (i32.const 68)) ;; (assert_return (invoke $module1 "call-8") (i32.const 68))
;; (assert_return (invoke $module1 "call-9") (i32.const 66)) ;; (assert_return (invoke $module1 "call-9") (i32.const 66))
(module $module3 ;; SKIP_SHARED_TABLE
(type $out-i32 (func (result i32))) ;; (module $module3
(import "module1" "shared-table" (table 10 anyfunc)) ;; (type $out-i32 (func (result i32)))
(elem (i32.const 8) $const-i32-e) ;; (import "module1" "shared-table" (table 10 anyfunc))
(elem (i32.const 9) $const-i32-f) ;; (elem (i32.const 8) $const-i32-e)
(func $const-i32-e (type $out-i32) (i32.const 69)) ;; (elem (i32.const 9) $const-i32-f)
(func $const-i32-f (type $out-i32) (i32.const 70)) ;; (func $const-i32-e (type $out-i32) (i32.const 69))
) ;; (func $const-i32-f (type $out-i32) (i32.const 70))
;; )
;; SKIP_SHARED_TABLE ;; SKIP_SHARED_TABLE
;; (assert_return (invoke $module1 "call-7") (i32.const 67)) ;; (assert_return (invoke $module1 "call-7") (i32.const 67))

View File

@ -287,6 +287,12 @@
"type mismatch" "type mismatch"
) )
(assert_invalid
(module (global i32 (i32.const 0)) (global i64 (get_global 1)))
"unknown global"
)
(assert_invalid (assert_invalid
(module (global i32 (;empty instruction sequence;))) (module (global i32 (;empty instruction sequence;)))
"type mismatch" "type mismatch"
@ -302,10 +308,15 @@
"unknown global" "unknown global"
) )
;; SKIP_MUTABLE_GLOBALS (module
;; (module (import "spectest" "global_i32" (global i32))
;; (import "spectest" "global_i32" (global i32)) (global i32 (get_global 0))
;; ) (func (export "get-0") (result i32) (get_global 0))
(func (export "get-0-ref") (result i32) (get_global 1))
)
(assert_return (invoke "get-0") (i32.const 666))
(assert_return (invoke "get-0-ref") (i32.const 666))
(assert_malformed (assert_malformed
(module binary (module binary

View File

@ -77,11 +77,11 @@ fn execute_wasm(wasm_path: PathBuf) -> Result<(), String> {
webassembly::instantiate(wasm_binary, import_object) webassembly::instantiate(wasm_binary, import_object)
.map_err(|err| format!("Can't instantiate the WebAssembly module: {}", err))?; .map_err(|err| format!("Can't instantiate the WebAssembly module: {}", err))?;
webassembly::utils::print_instance_offsets(&instance); // webassembly::utils::print_instance_offsets(&instance);
let func_index = instance let func_index = instance
.start_func .start_func
.unwrap_or_else(|| match module.info.exports.get("main") { .unwrap_or_else(|| match module.info.exports.get("main").or(module.info.exports.get("_main")) {
Some(&webassembly::Export::Function(index)) => index, Some(&webassembly::Export::Function(index)) => index,
_ => panic!("Main function not found"), _ => panic!("Main function not found"),
}); });

View File

@ -12,7 +12,7 @@ pub fn spectest_importobject<'a, 'b>() -> ImportObject<&'a str, &'b str> {
let mut import_object = ImportObject::new(); let mut import_object = ImportObject::new();
import_object.set("spectest", "print_i32", ImportValue::Func(print_i32 as *const u8)); import_object.set("spectest", "print_i32", ImportValue::Func(print_i32 as *const u8));
import_object.set("spectest", "print", ImportValue::Func(print as *const u8)); import_object.set("spectest", "print", ImportValue::Func(print as *const u8));
import_object.set("spectest", "global_i32", ImportValue::Func(GLOBAL_I32 as *const u8)); import_object.set("spectest", "global_i32", ImportValue::Global(GLOBAL_I32 as _));
import_object.set("spectest", "table", ImportValue::Table(vec![0; 30])); import_object.set("spectest", "table", ImportValue::Table(vec![0; 30]));
return import_object; return import_object;
} }

View File

@ -142,7 +142,7 @@ fn start_module_5(result_object: &ResultObject) {
result_object.instance.start(); result_object.instance.start();
} }
// Line 69 // Line 53
#[test] #[test]
fn test_module_5() { fn test_module_5() {
@ -151,6 +151,54 @@ fn test_module_5() {
start_module_5(&result_object); start_module_5(&result_object);
} }
fn create_module_6() -> ResultObject { fn create_module_6() -> ResultObject {
let module_str = "(module
(type (;0;) (func))
(import \"spectest\" \"global_i32\" (global (;0;) i32))
(func (;0;) (type 0))
(table (;0;) 1000 anyfunc)
(elem (;0;) (i32.const 0) 0))
";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
}
fn start_module_6(result_object: &ResultObject) {
result_object.instance.start();
}
// Line 60
#[test]
fn test_module_6() {
let result_object = create_module_6();
// We group the calls together
start_module_6(&result_object);
}
fn create_module_7() -> ResultObject {
let module_str = "(module
(type (;0;) (func))
(import \"spectest\" \"global_i32\" (global (;0;) i32))
(func (;0;) (type 0))
(table (;0;) 1000 anyfunc)
(elem (;0;) (get_global 0) 0))
";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
}
fn start_module_7(result_object: &ResultObject) {
result_object.instance.start();
}
// Line 67
#[test]
fn test_module_7() {
let result_object = create_module_7();
// We group the calls together
start_module_7(&result_object);
}
fn create_module_8() -> ResultObject {
let module_str = "(module let module_str = "(module
(type (;0;) (func (result i32))) (type (;0;) (func (result i32)))
(func (;0;) (type 0) (result i32) (func (;0;) (type 0) (result i32)
@ -173,13 +221,13 @@ fn create_module_6() -> ResultObject {
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
} }
fn start_module_6(result_object: &ResultObject) { fn start_module_8(result_object: &ResultObject) {
result_object.instance.start(); result_object.instance.start();
} }
// Line 83 // Line 81
fn c6_l83_action_invoke(result_object: &ResultObject) { fn c8_l81_action_invoke(result_object: &ResultObject) {
println!("Executing function {}", "c6_l83_action_invoke"); println!("Executing function {}", "c8_l81_action_invoke");
let func_index = match result_object.module.info.exports.get("call-7") { let func_index = match result_object.module.info.exports.get("call-7") {
Some(&Export::Function(index)) => index, Some(&Export::Function(index)) => index,
_ => panic!("Function not found"), _ => panic!("Function not found"),
@ -189,9 +237,9 @@ fn c6_l83_action_invoke(result_object: &ResultObject) {
assert_eq!(result, 65 as i32); assert_eq!(result, 65 as i32);
} }
// Line 84 // Line 82
fn c7_l84_action_invoke(result_object: &ResultObject) { fn c9_l82_action_invoke(result_object: &ResultObject) {
println!("Executing function {}", "c7_l84_action_invoke"); println!("Executing function {}", "c9_l82_action_invoke");
let func_index = match result_object.module.info.exports.get("call-9") { let func_index = match result_object.module.info.exports.get("call-9") {
Some(&Export::Function(index)) => index, Some(&Export::Function(index)) => index,
_ => panic!("Function not found"), _ => panic!("Function not found"),
@ -201,17 +249,17 @@ fn c7_l84_action_invoke(result_object: &ResultObject) {
assert_eq!(result, 66 as i32); assert_eq!(result, 66 as i32);
} }
// Line 88 // Line 86
#[test] #[test]
fn test_module_6() { fn test_module_8() {
let result_object = create_module_6(); let result_object = create_module_8();
// We group the calls together // We group the calls together
start_module_6(&result_object); start_module_8(&result_object);
c6_l83_action_invoke(&result_object); c8_l81_action_invoke(&result_object);
c7_l84_action_invoke(&result_object); c9_l82_action_invoke(&result_object);
} }
fn create_module_7() -> ResultObject { fn create_module_9() -> ResultObject {
let module_str = "(module let module_str = "(module
(type (;0;) (func)) (type (;0;) (func))
(func (;0;) (type 0)) (func (;0;) (type 0))
@ -222,19 +270,19 @@ fn create_module_7() -> ResultObject {
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
} }
fn start_module_7(result_object: &ResultObject) { fn start_module_9(result_object: &ResultObject) {
result_object.instance.start(); result_object.instance.start();
} }
// Line 93 // Line 91
#[test] #[test]
fn test_module_7() { fn test_module_9() {
let result_object = create_module_7(); let result_object = create_module_9();
// We group the calls together // We group the calls together
start_module_7(&result_object); start_module_9(&result_object);
} }
fn create_module_8() -> ResultObject { fn create_module_10() -> ResultObject {
let module_str = "(module let module_str = "(module
(type (;0;) (func)) (type (;0;) (func))
(import \"spectest\" \"table\" (table (;0;) 10 anyfunc)) (import \"spectest\" \"table\" (table (;0;) 10 anyfunc))
@ -245,53 +293,11 @@ fn create_module_8() -> ResultObject {
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
} }
fn start_module_8(result_object: &ResultObject) {
result_object.instance.start();
}
// Line 99
#[test]
fn test_module_8() {
let result_object = create_module_8();
// We group the calls together
start_module_8(&result_object);
}
fn create_module_9() -> ResultObject {
let module_str = "(module
(table (;0;) 0 anyfunc)
(elem (;0;) (i32.const 0)))
";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
}
fn start_module_9(result_object: &ResultObject) {
result_object.instance.start();
}
// Line 103
#[test]
fn test_module_9() {
let result_object = create_module_9();
// We group the calls together
start_module_9(&result_object);
}
fn create_module_10() -> ResultObject {
let module_str = "(module
(import \"spectest\" \"table\" (table (;0;) 0 anyfunc))
(elem (;0;) (i32.const 0)))
";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
}
fn start_module_10(result_object: &ResultObject) { fn start_module_10(result_object: &ResultObject) {
result_object.instance.start(); result_object.instance.start();
} }
// Line 108 // Line 97
#[test] #[test]
fn test_module_10() { fn test_module_10() {
@ -301,7 +307,7 @@ fn test_module_10() {
} }
fn create_module_11() -> ResultObject { fn create_module_11() -> ResultObject {
let module_str = "(module let module_str = "(module
(table (;0;) 0 0 anyfunc) (table (;0;) 0 anyfunc)
(elem (;0;) (i32.const 0))) (elem (;0;) (i32.const 0)))
"; ";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
@ -312,7 +318,7 @@ fn start_module_11(result_object: &ResultObject) {
result_object.instance.start(); result_object.instance.start();
} }
// Line 113 // Line 101
#[test] #[test]
fn test_module_11() { fn test_module_11() {
@ -322,8 +328,8 @@ fn test_module_11() {
} }
fn create_module_12() -> ResultObject { fn create_module_12() -> ResultObject {
let module_str = "(module let module_str = "(module
(table (;0;) 20 anyfunc) (import \"spectest\" \"table\" (table (;0;) 0 anyfunc))
(elem (;0;) (i32.const 20))) (elem (;0;) (i32.const 0)))
"; ";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
@ -333,7 +339,7 @@ fn start_module_12(result_object: &ResultObject) {
result_object.instance.start(); result_object.instance.start();
} }
// Line 118 // Line 106
#[test] #[test]
fn test_module_12() { fn test_module_12() {
@ -343,10 +349,8 @@ fn test_module_12() {
} }
fn create_module_13() -> ResultObject { fn create_module_13() -> ResultObject {
let module_str = "(module let module_str = "(module
(type (;0;) (func)) (table (;0;) 0 0 anyfunc)
(import \"spectest\" \"table\" (table (;0;) 0 anyfunc)) (elem (;0;) (i32.const 0)))
(func (;0;) (type 0))
(elem (;0;) (i32.const 0) 0))
"; ";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
@ -356,7 +360,7 @@ fn start_module_13(result_object: &ResultObject) {
result_object.instance.start(); result_object.instance.start();
} }
// Line 124 // Line 111
#[test] #[test]
fn test_module_13() { fn test_module_13() {
@ -366,10 +370,8 @@ fn test_module_13() {
} }
fn create_module_14() -> ResultObject { fn create_module_14() -> ResultObject {
let module_str = "(module let module_str = "(module
(type (;0;) (func)) (table (;0;) 20 anyfunc)
(import \"spectest\" \"table\" (table (;0;) 0 100 anyfunc)) (elem (;0;) (i32.const 20)))
(func (;0;) (type 0))
(elem (;0;) (i32.const 0) 0))
"; ";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
@ -379,7 +381,7 @@ fn start_module_14(result_object: &ResultObject) {
result_object.instance.start(); result_object.instance.start();
} }
// Line 130 // Line 116
#[test] #[test]
fn test_module_14() { fn test_module_14() {
@ -392,7 +394,7 @@ fn create_module_15() -> ResultObject {
(type (;0;) (func)) (type (;0;) (func))
(import \"spectest\" \"table\" (table (;0;) 0 anyfunc)) (import \"spectest\" \"table\" (table (;0;) 0 anyfunc))
(func (;0;) (type 0)) (func (;0;) (type 0))
(elem (;0;) (i32.const 1) 0)) (elem (;0;) (i32.const 0) 0))
"; ";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
@ -402,7 +404,7 @@ fn start_module_15(result_object: &ResultObject) {
result_object.instance.start(); result_object.instance.start();
} }
// Line 136 // Line 122
#[test] #[test]
fn test_module_15() { fn test_module_15() {
@ -413,9 +415,9 @@ fn test_module_15() {
fn create_module_16() -> ResultObject { fn create_module_16() -> ResultObject {
let module_str = "(module let module_str = "(module
(type (;0;) (func)) (type (;0;) (func))
(import \"spectest\" \"table\" (table (;0;) 0 30 anyfunc)) (import \"spectest\" \"table\" (table (;0;) 0 100 anyfunc))
(func (;0;) (type 0)) (func (;0;) (type 0))
(elem (;0;) (i32.const 1) 0)) (elem (;0;) (i32.const 0) 0))
"; ";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
@ -425,79 +427,7 @@ fn start_module_16(result_object: &ResultObject) {
result_object.instance.start(); result_object.instance.start();
} }
// Line 145 // Line 128
// Line 154
// Line 163
// Line 172
// Line 180
// Line 188
// Line 197
// Line 205
// Line 214
// Line 222
// Line 231
// Line 239
// Line 250
#[test]
fn c30_l250_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 9, 7, 1, 0, 65, 0, 11, 1, 0, 10, 4, 1, 2, 0, 11];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid");
}
// Line 260
#[test]
fn c31_l260_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 6, 1, 0, 66, 0, 11, 0];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid");
}
// Line 268
#[test]
fn c32_l268_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 7, 1, 0, 65, 0, 104, 11, 0];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid");
}
// Line 276
#[test]
fn c33_l276_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 5, 1, 0, 1, 11, 0];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid");
}
// Line 284
#[test]
fn c34_l284_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 7, 1, 0, 1, 65, 0, 11, 0];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid");
}
// Line 292
#[test]
fn c35_l292_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 7, 1, 0, 65, 0, 1, 11, 0];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid");
}
// Line 307
#[test] #[test]
fn test_module_16() { fn test_module_16() {
@ -506,6 +436,124 @@ fn test_module_16() {
start_module_16(&result_object); start_module_16(&result_object);
} }
fn create_module_17() -> ResultObject { fn create_module_17() -> ResultObject {
let module_str = "(module
(type (;0;) (func))
(import \"spectest\" \"table\" (table (;0;) 0 anyfunc))
(func (;0;) (type 0))
(elem (;0;) (i32.const 1) 0))
";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
}
fn start_module_17(result_object: &ResultObject) {
result_object.instance.start();
}
// Line 134
#[test]
fn test_module_17() {
let result_object = create_module_17();
// We group the calls together
start_module_17(&result_object);
}
fn create_module_18() -> ResultObject {
let module_str = "(module
(type (;0;) (func))
(import \"spectest\" \"table\" (table (;0;) 0 30 anyfunc))
(func (;0;) (type 0))
(elem (;0;) (i32.const 1) 0))
";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
}
fn start_module_18(result_object: &ResultObject) {
result_object.instance.start();
}
// Line 143
// Line 152
// Line 161
// Line 170
// Line 178
// Line 186
// Line 195
// Line 203
// Line 212
// Line 220
// Line 229
// Line 237
// Line 248
#[test]
fn c32_l248_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 9, 7, 1, 0, 65, 0, 11, 1, 0, 10, 4, 1, 2, 0, 11];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid");
}
// Line 258
#[test]
fn c33_l258_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 6, 1, 0, 66, 0, 11, 0];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid");
}
// Line 266
#[test]
fn c34_l266_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 7, 1, 0, 65, 0, 104, 11, 0];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid");
}
// Line 274
#[test]
fn c35_l274_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 5, 1, 0, 1, 11, 0];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid");
}
// Line 282
#[test]
fn c36_l282_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 7, 1, 0, 1, 65, 0, 11, 0];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid");
}
// Line 290
#[test]
fn c37_l290_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 7, 1, 0, 65, 0, 1, 11, 0];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid");
}
// Line 305
#[test]
fn test_module_18() {
let result_object = create_module_18();
// We group the calls together
start_module_18(&result_object);
}
fn create_module_19() -> ResultObject {
let module_str = "(module let module_str = "(module
(type (;0;) (func (result i32))) (type (;0;) (func (result i32)))
(func (;0;) (type 0) (result i32) (func (;0;) (type 0) (result i32)
@ -524,13 +572,13 @@ fn create_module_17() -> ResultObject {
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
} }
fn start_module_17(result_object: &ResultObject) { fn start_module_19(result_object: &ResultObject) {
result_object.instance.start(); result_object.instance.start();
} }
// Line 318 // Line 316
fn c37_l318_action_invoke(result_object: &ResultObject) { fn c39_l316_action_invoke(result_object: &ResultObject) {
println!("Executing function {}", "c37_l318_action_invoke"); println!("Executing function {}", "c39_l316_action_invoke");
let func_index = match result_object.module.info.exports.get("call-overwritten") { let func_index = match result_object.module.info.exports.get("call-overwritten") {
Some(&Export::Function(index)) => index, Some(&Export::Function(index)) => index,
_ => panic!("Function not found"), _ => panic!("Function not found"),
@ -540,16 +588,16 @@ fn c37_l318_action_invoke(result_object: &ResultObject) {
assert_eq!(result, 66 as i32); assert_eq!(result, 66 as i32);
} }
// Line 320 // Line 318
#[test] #[test]
fn test_module_17() { fn test_module_19() {
let result_object = create_module_17(); let result_object = create_module_19();
// We group the calls together // We group the calls together
start_module_17(&result_object); start_module_19(&result_object);
c37_l318_action_invoke(&result_object); c39_l316_action_invoke(&result_object);
} }
fn create_module_18() -> ResultObject { fn create_module_20() -> ResultObject {
let module_str = "(module let module_str = "(module
(type (;0;) (func (result i32))) (type (;0;) (func (result i32)))
(import \"spectest\" \"table\" (table (;0;) 10 anyfunc)) (import \"spectest\" \"table\" (table (;0;) 10 anyfunc))
@ -568,13 +616,13 @@ fn create_module_18() -> ResultObject {
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
} }
fn start_module_18(result_object: &ResultObject) { fn start_module_20(result_object: &ResultObject) {
result_object.instance.start(); result_object.instance.start();
} }
// Line 331 // Line 329
fn c39_l331_action_invoke(result_object: &ResultObject) { fn c41_l329_action_invoke(result_object: &ResultObject) {
println!("Executing function {}", "c39_l331_action_invoke"); println!("Executing function {}", "c41_l329_action_invoke");
let func_index = match result_object.module.info.exports.get("call-overwritten-element") { let func_index = match result_object.module.info.exports.get("call-overwritten-element") {
Some(&Export::Function(index)) => index, Some(&Export::Function(index)) => index,
_ => panic!("Function not found"), _ => panic!("Function not found"),
@ -584,16 +632,16 @@ fn c39_l331_action_invoke(result_object: &ResultObject) {
assert_eq!(result, 66 as i32); assert_eq!(result, 66 as i32);
} }
// Line 335 // Line 333
#[test] #[test]
fn test_module_18() { fn test_module_20() {
let result_object = create_module_18(); let result_object = create_module_20();
// We group the calls together // We group the calls together
start_module_18(&result_object); start_module_20(&result_object);
c39_l331_action_invoke(&result_object); c41_l329_action_invoke(&result_object);
} }
fn create_module_19() -> ResultObject { fn create_module_21() -> ResultObject {
let module_str = "(module let module_str = "(module
(type (;0;) (func (result i32))) (type (;0;) (func (result i32)))
(func (;0;) (type 0) (result i32) (func (;0;) (type 0) (result i32)
@ -621,69 +669,62 @@ fn create_module_19() -> ResultObject {
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
} }
fn start_module_19(result_object: &ResultObject) {
result_object.instance.start();
}
// Line 353
// Line 360
#[test]
fn test_module_19() {
let result_object = create_module_19();
// We group the calls together
start_module_19(&result_object);
}
fn create_module_20() -> ResultObject {
let module_str = "(module
(type (;0;) (func (result i32)))
(import \"module1\" \"shared-table\" (table (;0;) 10 anyfunc))
(func (;0;) (type 0) (result i32)
i32.const 67)
(func (;1;) (type 0) (result i32)
i32.const 68)
(elem (;0;) (i32.const 7) 0)
(elem (;1;) (i32.const 8) 1))
";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
}
fn start_module_20(result_object: &ResultObject) {
result_object.instance.start();
}
// Line 374
#[test]
fn test_module_20() {
let result_object = create_module_20();
// We group the calls together
start_module_20(&result_object);
}
fn create_module_21() -> ResultObject {
let module_str = "(module
(type (;0;) (func (result i32)))
(import \"module1\" \"shared-table\" (table (;0;) 10 anyfunc))
(func (;0;) (type 0) (result i32)
i32.const 69)
(func (;1;) (type 0) (result i32)
i32.const 70)
(elem (;0;) (i32.const 8) 0)
(elem (;1;) (i32.const 9) 1))
";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
}
fn start_module_21(result_object: &ResultObject) { fn start_module_21(result_object: &ResultObject) {
result_object.instance.start(); result_object.instance.start();
} }
// Line 351
// Line 353
fn c44_l353_action_invoke(result_object: &ResultObject) {
println!("Executing function {}", "c44_l353_action_invoke");
let func_index = match result_object.module.info.exports.get("call-7") {
Some(&Export::Function(index)) => index,
_ => panic!("Function not found"),
};
let invoke_fn: fn(&Instance) = get_instance_function!(result_object.instance, func_index);
let result = invoke_fn(&result_object.instance);
}
#[test]
fn c44_l353_assert_trap() {
let result_object = create_module_21();
let result = panic::catch_unwind(|| {
c44_l353_action_invoke(&result_object);
});
assert!(result.is_err());
}
// Line 354
fn c45_l354_action_invoke(result_object: &ResultObject) {
println!("Executing function {}", "c45_l354_action_invoke");
let func_index = match result_object.module.info.exports.get("call-8") {
Some(&Export::Function(index)) => index,
_ => panic!("Function not found"),
};
let invoke_fn: fn(&Instance) -> i32 = get_instance_function!(result_object.instance, func_index);
let result = invoke_fn(&result_object.instance);
assert_eq!(result, 65 as i32);
}
// Line 355
fn c46_l355_action_invoke(result_object: &ResultObject) {
println!("Executing function {}", "c46_l355_action_invoke");
let func_index = match result_object.module.info.exports.get("call-9") {
Some(&Export::Function(index)) => index,
_ => panic!("Function not found"),
};
let invoke_fn: fn(&Instance) -> i32 = get_instance_function!(result_object.instance, func_index);
let result = invoke_fn(&result_object.instance);
assert_eq!(result, 66 as i32);
}
#[test] #[test]
fn test_module_21() { fn test_module_21() {
let result_object = create_module_21(); let result_object = create_module_21();
// We group the calls together // We group the calls together
start_module_21(&result_object); start_module_21(&result_object);
c45_l354_action_invoke(&result_object);
c46_l355_action_invoke(&result_object);
} }

View File

@ -907,44 +907,36 @@ fn c54_l286_assert_invalid() {
// Line 291 // Line 291
#[test] #[test]
fn c55_l291_assert_invalid() { fn c55_l291_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 6, 11, 2, 127, 0, 65, 0, 11, 126, 0, 35, 1, 11];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid");
}
// Line 297
#[test]
fn c56_l297_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 6, 4, 1, 127, 0, 11]; let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 6, 4, 1, 127, 0, 11];
let compilation = compile(wasm_binary.to_vec()); let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid"); assert!(compilation.is_err(), "WASM should not compile as is invalid");
} }
// Line 296 // Line 302
#[test] #[test]
fn c56_l296_assert_invalid() { fn c57_l302_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 6, 6, 1, 127, 0, 35, 0, 11]; let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 6, 6, 1, 127, 0, 35, 0, 11];
let compilation = compile(wasm_binary.to_vec()); let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid"); assert!(compilation.is_err(), "WASM should not compile as is invalid");
} }
// Line 301 // Line 307
#[test] #[test]
fn c57_l301_assert_invalid() { fn c58_l307_assert_invalid() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 6, 11, 2, 127, 0, 35, 1, 11, 127, 0, 65, 0, 11]; let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 6, 11, 2, 127, 0, 35, 1, 11, 127, 0, 65, 0, 11];
let compilation = compile(wasm_binary.to_vec()); let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is invalid"); assert!(compilation.is_err(), "WASM should not compile as is invalid");
} }
// Line 311 // Line 311
#[test]
fn c58_l311_assert_malformed() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 2, 148, 128, 128, 128, 0, 1, 8, 115, 112, 101, 99, 116, 101, 115, 116, 10, 103, 108, 111, 98, 97, 108, 95, 105, 51, 50, 3, 127, 2];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is malformed");
}
// Line 324
#[test]
fn c59_l324_assert_malformed() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 2, 148, 128, 128, 128, 0, 1, 8, 115, 112, 101, 99, 116, 101, 115, 116, 10, 103, 108, 111, 98, 97, 108, 95, 105, 51, 50, 3, 127, 255];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is malformed");
}
// Line 337
#[test] #[test]
fn test_module_1() { fn test_module_1() {
@ -999,7 +991,15 @@ fn test_module_1() {
} }
fn create_module_2() -> ResultObject { fn create_module_2() -> ResultObject {
let module_str = "(module let module_str = "(module
(global (;0;) i32 (i32.const 0))) (type (;0;) (func (result i32)))
(import \"spectest\" \"global_i32\" (global (;0;) i32))
(func (;0;) (type 0) (result i32)
get_global 0)
(func (;1;) (type 0) (result i32)
get_global 1)
(global (;1;) i32 (get_global 0))
(export \"get-0\" (func 0))
(export \"get-0-ref\" (func 1)))
"; ";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
@ -1009,25 +1009,87 @@ fn start_module_2(result_object: &ResultObject) {
result_object.instance.start(); result_object.instance.start();
} }
// Line 341 // Line 318
fn c60_l318_action_invoke(result_object: &ResultObject) {
println!("Executing function {}", "c60_l318_action_invoke");
let func_index = match result_object.module.info.exports.get("get-0") {
Some(&Export::Function(index)) => index,
_ => panic!("Function not found"),
};
let invoke_fn: fn(&Instance) -> i32 = get_instance_function!(result_object.instance, func_index);
let result = invoke_fn(&result_object.instance);
assert_eq!(result, 666 as i32);
}
// Line 319
fn c61_l319_action_invoke(result_object: &ResultObject) {
println!("Executing function {}", "c61_l319_action_invoke");
let func_index = match result_object.module.info.exports.get("get-0-ref") {
Some(&Export::Function(index)) => index,
_ => panic!("Function not found"),
};
let invoke_fn: fn(&Instance) -> i32 = get_instance_function!(result_object.instance, func_index);
let result = invoke_fn(&result_object.instance);
assert_eq!(result, 666 as i32);
}
// Line 322
#[test] #[test]
fn c61_l341_assert_malformed() { fn c62_l322_assert_malformed() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 6, 134, 128, 128, 128, 0, 1, 127, 2, 65, 0, 11]; let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 2, 148, 128, 128, 128, 0, 1, 8, 115, 112, 101, 99, 116, 101, 115, 116, 10, 103, 108, 111, 98, 97, 108, 95, 105, 51, 50, 3, 127, 2];
let compilation = compile(wasm_binary.to_vec()); let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is malformed"); assert!(compilation.is_err(), "WASM should not compile as is malformed");
} }
// Line 353 // Line 335
#[test] #[test]
fn c62_l353_assert_malformed() { fn c63_l335_assert_malformed() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 6, 134, 128, 128, 128, 0, 1, 127, 255, 65, 0, 11]; let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 2, 148, 128, 128, 128, 0, 1, 8, 115, 112, 101, 99, 116, 101, 115, 116, 10, 103, 108, 111, 98, 97, 108, 95, 105, 51, 50, 3, 127, 255];
let compilation = compile(wasm_binary.to_vec()); let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is malformed"); assert!(compilation.is_err(), "WASM should not compile as is malformed");
} }
// Line 348
#[test] #[test]
fn test_module_2() { fn test_module_2() {
let result_object = create_module_2(); let result_object = create_module_2();
// We group the calls together // We group the calls together
start_module_2(&result_object); start_module_2(&result_object);
c60_l318_action_invoke(&result_object);
c61_l319_action_invoke(&result_object);
}
fn create_module_3() -> ResultObject {
let module_str = "(module
(global (;0;) i32 (i32.const 0)))
";
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
}
fn start_module_3(result_object: &ResultObject) {
result_object.instance.start();
}
// Line 352
#[test]
fn c65_l352_assert_malformed() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 6, 134, 128, 128, 128, 0, 1, 127, 2, 65, 0, 11];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is malformed");
}
// Line 364
#[test]
fn c66_l364_assert_malformed() {
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 6, 134, 128, 128, 128, 0, 1, 127, 255, 65, 0, 11];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is malformed");
}
#[test]
fn test_module_3() {
let result_object = create_module_3();
// We group the calls together
start_module_3(&result_object);
} }

View File

@ -112,7 +112,7 @@ where
#[derive(PartialEq, Debug)] #[derive(PartialEq, Debug)]
pub enum ImportValue { pub enum ImportValue {
Func(*const u8), Func(*const u8),
Global(u8), Global(i64),
Table(Vec<usize>), Table(Vec<usize>),
Memory(LinearMemory), Memory(LinearMemory),
} }

View File

@ -25,8 +25,7 @@ use super::super::common::slice::{BoundedSlice, UncheckedSlice};
use super::errors::ErrorKind; use super::errors::ErrorKind;
use super::import_object::{ImportObject, ImportValue}; use super::import_object::{ImportObject, ImportValue};
use super::memory::LinearMemory; use super::memory::LinearMemory;
use super::module::Export; use super::module::{Export, ImportableExportable, Module};
use super::module::Module;
use super::relocation::{Reloc, RelocSink, RelocationType}; use super::relocation::{Reloc, RelocSink, RelocationType};
use super::math_intrinsics; use super::math_intrinsics;
@ -121,6 +120,8 @@ pub struct DataPointers {
pub struct InstanceOptions { pub struct InstanceOptions {
// Shall we mock automatically the imported functions if they don't exist? // Shall we mock automatically the imported functions if they don't exist?
pub mock_missing_imports: bool, pub mock_missing_imports: bool,
pub mock_missing_globals: bool,
pub mock_missing_tables: bool,
pub isa: Box<TargetIsa>, pub isa: Box<TargetIsa>,
} }
@ -175,9 +176,6 @@ impl Instance {
let mut functions: Vec<Vec<u8>> = Vec::new(); let mut functions: Vec<Vec<u8>> = Vec::new();
let mut import_functions: Vec<*const u8> = Vec::new(); let mut import_functions: Vec<*const u8> = Vec::new();
let mut imported_memories: Vec<LinearMemory> = Vec::new();
let mut imported_tables: Vec<Vec<usize>> = Vec::new();
debug!("Instance - Instantiating functions"); debug!("Instance - Instantiating functions");
// Instantiate functions // Instantiate functions
{ {
@ -310,45 +308,104 @@ impl Instance {
} }
} }
// Looping through and getting the imported objects debug!("Instance - Instantiating globals");
for (_key, value) in import_object.map { // Instantiate Globals
match value { let globals_data = {
ImportValue::Memory(value) => let globals_count = module.info.globals.len();
imported_memories.push(value), // Allocate the underlying memory and initialize it to zeros
ImportValue::Table(value) => let globals_data_size = globals_count * 8;
imported_tables.push(value), globals.resize(globals_data_size, 0);
_ => (),
// cast the globals slice to a slice of i64.
let globals_data = unsafe {
slice::from_raw_parts_mut(globals.as_mut_ptr() as *mut i64, globals_count)
};
for (i, global) in module.info.globals.iter().enumerate() {
let ImportableExportable {entity, import_name, ..} = global;
let value: i64 = match entity.initializer {
GlobalInit::I32Const(n) => n as _,
GlobalInit::I64Const(n) => n,
GlobalInit::F32Const(f) => f as _, // unsafe { mem::transmute(f as f64) },
GlobalInit::F64Const(f) => f as _, // unsafe { mem::transmute(f) },
GlobalInit::GlobalRef(global_index) => {
globals_data[global_index.index()]
}
GlobalInit::Import() => {
let (module_name, field_name) = import_name.as_ref().expect("Expected a import name for the global import");
let imported = import_object.get(&module_name.as_str(), &field_name.as_str());
match imported {
Some(ImportValue::Global(value)) => {
*value
},
None => {
if options.mock_missing_globals {
0
}
else {
panic!("Imported global value was not provided ({}.{})", module_name, field_name)
}
},
_ => {
panic!("Expected global import, but received {:?} ({}.{})", imported, module_name, field_name)
} }
} }
}
};
globals_data[i] = value;
}
globals_data
};
debug!("Instance - Instantiating tables"); debug!("Instance - Instantiating tables");
// Instantiate tables // Instantiate tables
{ {
// Reserve space for tables // Reserve space for tables
tables.reserve_exact(imported_tables.len() + module.info.tables.len()); tables.reserve_exact(module.info.tables.len());
// Get imported tables
for table in imported_tables {
tables.push(table);
}
// Get tables in module // Get tables in module
for table in &module.info.tables { for table in &module.info.tables {
let table: Vec<usize> = match table.import_name.as_ref() {
Some((module_name, field_name)) => {
let imported = import_object.get(&module_name.as_str(), &field_name.as_str());
match imported {
Some(ImportValue::Table(t)) => {
t.to_vec()
},
None => {
if options.mock_missing_tables {
let len = table.entity.size; let len = table.entity.size;
let mut v = Vec::with_capacity(len); let mut v = Vec::with_capacity(len);
v.resize(len, 0); v.resize(len, 0);
tables.push(v); v
}
else {
panic!("Imported table value was not provided ({}.{})", module_name, field_name)
}
},
_ => {
panic!("Expected global table, but received {:?} ({}.{})", imported, module_name, field_name)
}
}
},
None => {
let len = table.entity.size;
let mut v = Vec::with_capacity(len);
v.resize(len, 0);
v
}
};
tables.push(table);
} }
// instantiate tables // instantiate tables
for table_element in &module.info.table_elements { for table_element in &module.info.table_elements {
// TODO: We shouldn't assert here since we are returning a Result<Instance, ErrorKind> let base = match table_element.base {
assert!( Some(global_index) => {
table_element.base.is_none(), globals_data[global_index.index()] as usize
"globalvalue base not supported yet." },
); None => 0
};
let base = 0;
let table = &mut tables[table_element.table_index.index()]; let table = &mut tables[table_element.table_index.index()];
for (i, func_index) in table_element.elements.iter().enumerate() { for (i, func_index) in table_element.elements.iter().enumerate() {
@ -358,6 +415,7 @@ impl Instance {
// let func_index = *elem_index - module.info.imported_funcs.len() as u32; // let func_index = *elem_index - module.info.imported_funcs.len() as u32;
// let func_addr = functions[func_index.index()].as_ptr(); // let func_addr = functions[func_index.index()].as_ptr();
println!("TABLE LENGTH: {}", table.len());
let func_addr = get_function_addr(&func_index, &import_functions, &functions); let func_addr = get_function_addr(&func_index, &import_functions, &functions);
table[base + table_element.offset + i] = func_addr as _; table[base + table_element.offset + i] = func_addr as _;
} }
@ -368,12 +426,7 @@ impl Instance {
// Instantiate memories // Instantiate memories
{ {
// Reserve space for memories // Reserve space for memories
memories.reserve_exact(imported_memories.len() + module.info.memories.len()); memories.reserve_exact(module.info.memories.len());
// Get imported memories
for memory in imported_memories {
memories.push(memory);
}
// Get memories in module // Get memories in module
for memory in &module.info.memories { for memory in &module.info.memories {
@ -394,41 +447,6 @@ impl Instance {
} }
} }
debug!("Instance - Instantiating globals");
// TODO: Fix globals import
// Instantiate Globals
{
let globals_count = module.info.globals.len();
// Allocate the underlying memory and initialize it to zeros
let globals_data_size = globals_count * 8;
globals.resize(globals_data_size, 0);
// cast the globals slice to a slice of i64.
let globals_data = unsafe {
slice::from_raw_parts_mut(globals.as_mut_ptr() as *mut i64, globals_count)
};
for (i, global) in module.info.globals.iter().enumerate() {
let value: i64 = match global.entity.initializer {
GlobalInit::I32Const(n) => n as _,
GlobalInit::I64Const(n) => n,
GlobalInit::F32Const(f) => f as _, // unsafe { mem::transmute(f as f64) },
GlobalInit::F64Const(f) => f as _, // unsafe { mem::transmute(f) },
GlobalInit::GlobalRef(_global_index) => {
unimplemented!("GlobalInit::GlobalRef is not yet supported")
}
GlobalInit::Import() => {
// Right now (because there is no module/field fields on the Import
// https://github.com/CraneStation/cranelift/blob/5cabce9b58ff960534d4017fad11f2e78c72ceab/lib/wasm/src/sections_translator.rs#L90-L99 )
// It's impossible to know where to take the global from.
// This should be fixed in Cranelift itself.
unimplemented!("GlobalInit::Import is not yet supported")
}
};
globals_data[i] = value;
}
}
let start_func: Option<FuncIndex> = let start_func: Option<FuncIndex> =
module module
.info .info

View File

@ -58,6 +58,8 @@ pub fn instantiate(
import_object, import_object,
InstanceOptions { InstanceOptions {
mock_missing_imports: true, mock_missing_imports: true,
mock_missing_globals: true,
mock_missing_tables: true,
isa: isa isa: isa
}, },
)?; )?;

View File

@ -71,21 +71,25 @@ fn get_func_name(func_index: FuncIndex) -> ir::ExternalName {
ir::ExternalName::user(0, func_index.index() as u32) ir::ExternalName::user(0, func_index.index() as u32)
} }
/// A collection of names under which a given entity is exported. /// A collection of names under which a given entity is imported/exported.
#[derive(Debug)] #[derive(Debug)]
pub struct Exportable<T> { pub struct ImportableExportable<T> {
/// An entity. /// An entity.
pub entity: T, pub entity: T,
/// Names under which the entity is exported. /// Names under which the entity is exported.
pub export_names: Vec<String>, pub export_names: Vec<String>,
/// Names under which the entity is imported.
pub import_name: Option<(String, String)>,
} }
impl<T> Exportable<T> { impl<T> ImportableExportable<T> {
pub fn new(entity: T) -> Self { pub fn new(entity: T, import_name: Option<(String, String)>) -> Self {
Self { Self {
entity, entity,
export_names: Vec::new(), export_names: Vec::new(),
import_name: import_name
} }
} }
} }
@ -120,7 +124,7 @@ pub struct ModuleInfo {
pub signatures: Vec<ir::Signature>, pub signatures: Vec<ir::Signature>,
/// Functions, imported and local. /// Functions, imported and local.
pub functions: PrimaryMap<FuncIndex, Exportable<SignatureIndex>>, pub functions: PrimaryMap<FuncIndex, ImportableExportable<SignatureIndex>>,
/// Function bodies. /// Function bodies.
pub function_bodies: PrimaryMap<DefinedFuncIndex, ir::Function>, pub function_bodies: PrimaryMap<DefinedFuncIndex, ir::Function>,
@ -129,7 +133,7 @@ pub struct ModuleInfo {
pub imported_funcs: Vec<(String, String)>, pub imported_funcs: Vec<(String, String)>,
/// Tables as provided by `declare_table`. /// Tables as provided by `declare_table`.
pub tables: Vec<Exportable<Table>>, pub tables: Vec<ImportableExportable<Table>>,
/// WebAssembly table initializers. /// WebAssembly table initializers.
pub table_elements: Vec<TableElements>, pub table_elements: Vec<TableElements>,
@ -138,13 +142,13 @@ pub struct ModuleInfo {
pub tables_base: Option<ir::GlobalValue>, pub tables_base: Option<ir::GlobalValue>,
/// Memories as provided by `declare_memory`. /// Memories as provided by `declare_memory`.
pub memories: Vec<Exportable<Memory>>, pub memories: Vec<ImportableExportable<Memory>>,
/// The Cranelift global holding the base address of the globals vector. /// The Cranelift global holding the base address of the globals vector.
pub globals_base: Option<ir::GlobalValue>, pub globals_base: Option<ir::GlobalValue>,
/// Globals as provided by `declare_global`. /// Globals as provided by `declare_global`.
pub globals: Vec<Exportable<Global>>, pub globals: Vec<ImportableExportable<Global>>,
/// The start function. /// The start function.
pub start_func: Option<FuncIndex>, pub start_func: Option<FuncIndex>,
@ -154,7 +158,7 @@ pub struct ModuleInfo {
/// Exported entities /// Exported entities
/// We use this in order to have a O(1) allocation of the exports /// We use this in order to have a O(1) allocation of the exports
/// rather than iterating through the Exportable elements. /// rather than iterating through the ImportableExportable elements.
pub exports: HashMap<String, Export>, pub exports: HashMap<String, Export>,
/// The external function declaration for implementing wasm's `current_memory`. /// The external function declaration for implementing wasm's `current_memory`.
@ -708,7 +712,7 @@ impl<'data> ModuleEnvironment<'data> for Module {
self.info.imported_funcs.len(), self.info.imported_funcs.len(),
"Imported functions must be declared first" "Imported functions must be declared first"
); );
self.info.functions.push(Exportable::new(sig_index)); self.info.functions.push(ImportableExportable::new(sig_index, None));
self.info self.info
.imported_funcs .imported_funcs
.push((String::from(module), String::from(field))); .push((String::from(module), String::from(field)));
@ -719,7 +723,7 @@ impl<'data> ModuleEnvironment<'data> for Module {
} }
fn declare_func_type(&mut self, sig_index: SignatureIndex) { fn declare_func_type(&mut self, sig_index: SignatureIndex) {
self.info.functions.push(Exportable::new(sig_index)); self.info.functions.push(ImportableExportable::new(sig_index, None));
} }
fn get_func_type(&self, func_index: FuncIndex) -> SignatureIndex { fn get_func_type(&self, func_index: FuncIndex) -> SignatureIndex {
@ -727,7 +731,16 @@ impl<'data> ModuleEnvironment<'data> for Module {
} }
fn declare_global(&mut self, global: Global) { fn declare_global(&mut self, global: Global) {
self.info.globals.push(Exportable::new(global)); self.info.globals.push(ImportableExportable::new(global, None));
}
fn declare_global_import(
&mut self,
global: Global,
module: &'data str,
field: &'data str,
) {
self.info.globals.push(ImportableExportable::new(global, Some((String::from(module), String::from(field)))));
} }
fn get_global(&self, global_index: GlobalIndex) -> &Global { fn get_global(&self, global_index: GlobalIndex) -> &Global {
@ -735,7 +748,16 @@ impl<'data> ModuleEnvironment<'data> for Module {
} }
fn declare_table(&mut self, table: Table) { fn declare_table(&mut self, table: Table) {
self.info.tables.push(Exportable::new(table)); self.info.tables.push(ImportableExportable::new(table, None));
}
fn declare_table_import(
&mut self,
table: Table,
module: &'data str,
field: &'data str,
) {
self.info.tables.push(ImportableExportable::new(table, Some((String::from(module), String::from(field)))));
} }
fn declare_table_elements( fn declare_table_elements(
@ -745,7 +767,6 @@ impl<'data> ModuleEnvironment<'data> for Module {
offset: usize, offset: usize,
elements: Vec<FuncIndex>, elements: Vec<FuncIndex>,
) { ) {
debug_assert!(base.is_none(), "global-value offsets not supported yet");
self.info.table_elements.push(TableElements { self.info.table_elements.push(TableElements {
table_index, table_index,
base, base,
@ -755,7 +776,16 @@ impl<'data> ModuleEnvironment<'data> for Module {
} }
fn declare_memory(&mut self, memory: Memory) { fn declare_memory(&mut self, memory: Memory) {
self.info.memories.push(Exportable::new(memory)); self.info.memories.push(ImportableExportable::new(memory, None));
}
fn declare_memory_import(
&mut self,
memory: Memory,
module: &'data str,
field: &'data str,
) {
self.info.memories.push(ImportableExportable::new(memory, Some((String::from(module), String::from(field)))));
} }
fn declare_data_initialization( fn declare_data_initialization(