Browse Source

Update to cranelift 0.58.0 and enable (but ignore) reference types and bulk memory tests (#926)

* Update cranelift to 0.58.0

* Update `wasmprinter` dep to require 0.2.1

We already had it in the lock file, but this ensures we won't ever go back down.

* Ensure that our error messages match `assert_invalid`'s

The bulk of this work was done in
https://github.com/bytecodealliance/wasmparser/pull/186 but now we can test it
at the `wasmtime` level as well.

Fixes #492

* Stop feeling guilty about not matching `assert_malformed` messages

Remove the "TODO" and stop printing warning messages. These would just be busy
work to implement, and getting all the messages the exact same relies on using
the same structure as the spec interpreter's parser, which means that where you
have a helper function and they don't, then things go wrong, and vice versa. Not
worth it.

Fixes #492

* Enable (but ignore) the reference-types proposal tests

* Match test suite directly, instead of roundabout starts/endswith

* Enable (but ignore) bulk memory operations proposal test suite
pull/934/head
Nick Fitzgerald 5 years ago
committed by GitHub
parent
commit
2af544de8b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 123
      Cargo.lock
  2. 24
      build.rs
  3. 12
      crates/api/src/trampoline/func.rs
  4. 8
      crates/environ/Cargo.toml
  5. 1
      crates/environ/src/cache/tests.rs
  6. 14
      crates/environ/src/cranelift.rs
  7. 75
      crates/environ/src/func_environ.rs
  8. 2
      crates/fuzzing/Cargo.toml
  9. 10
      crates/jit/Cargo.toml
  10. 12
      crates/jit/src/compiler.rs
  11. 6
      crates/jit/src/trampoline.rs
  12. 2
      crates/lightbeam/Cargo.toml
  13. 2
      crates/lightbeam/src/translate_sections.rs
  14. 2
      crates/runtime/src/instance.rs
  15. 29
      crates/wast/src/wast.rs
  16. 10
      tests/wast_testsuites.rs

123
Cargo.lock

@ -2,9 +2,9 @@
# It is not intended for manual editing. # It is not intended for manual editing.
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "0.7.6" version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" checksum = "5f56c476256dc249def911d6f7580b5fc7e875895b5d7ee88f5d602208035744"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@ -85,9 +85,9 @@ checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]] [[package]]
name = "backtrace" name = "backtrace"
version = "0.3.42" version = "0.3.43"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4b1549d804b6c73f4817df2ba073709e96e426f12987127c48e6745568c350b" checksum = "7f80256bc78f67e7df7e36d77366f636ed976895d91fe2ab9efa3973e8fe8c4f"
dependencies = [ dependencies = [
"backtrace-sys", "backtrace-sys",
"cfg-if", "cfg-if",
@ -332,25 +332,25 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-bforest" name = "cranelift-bforest"
version = "0.56.0" version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1dfb4890b4075d5c39a581c0cf6354b43c8f8273d232cbc2a5e6c7e0f1027edc" checksum = "fd0f53d59dc9ab1c8ab68c991d8406b52b7a0aab0b15b05a3a6895579c4e5dd9"
dependencies = [ dependencies = [
"cranelift-entity", "cranelift-entity",
] ]
[[package]] [[package]]
name = "cranelift-codegen" name = "cranelift-codegen"
version = "0.56.0" version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7600b2e36e28ecb0872e803d794b05c7a000273af8f7ac7d7cc32362e082e647" checksum = "0381a794836fb994c47006465d46d46be072483b667f36013d993b9895117fee"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"cranelift-bforest", "cranelift-bforest",
"cranelift-codegen-meta", "cranelift-codegen-meta",
"cranelift-codegen-shared", "cranelift-codegen-shared",
"cranelift-entity", "cranelift-entity",
"gimli", "gimli 0.20.0",
"log", "log",
"serde", "serde",
"smallvec", "smallvec",
@ -360,9 +360,9 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-codegen-meta" name = "cranelift-codegen-meta"
version = "0.56.0" version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65e50e5d5ffd37ec65b347cfbc653d64d0593b0ef7ff1eaf159f9fe1e1947207" checksum = "208c3c8d82bfef32a534c5020c6cfc3bc92f41388f1246b7bb98cf543331abaa"
dependencies = [ dependencies = [
"cranelift-codegen-shared", "cranelift-codegen-shared",
"cranelift-entity", "cranelift-entity",
@ -370,24 +370,24 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-codegen-shared" name = "cranelift-codegen-shared"
version = "0.56.0" version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc3de82e8bbd74f58dd8791c09cea215ba775f0bed780cbe4269ba3138848a51" checksum = "ea048c456a517e56fd6df8f0e3947922897e6e6f61fbc5eb557a36c7b8ff6394"
[[package]] [[package]]
name = "cranelift-entity" name = "cranelift-entity"
version = "0.56.0" version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35fd5d8705013678bdcd21d607b6fe70d6d5a8f8a954820cf16a19275331478c" checksum = "0c8c7ed50812194c9e9de1fa39c77b39fc9ab48173d5e7ee88b25b6a8953e9b8"
dependencies = [ dependencies = [
"serde", "serde",
] ]
[[package]] [[package]]
name = "cranelift-frontend" name = "cranelift-frontend"
version = "0.56.0" version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c948841f008f5f147e9a7527e144e1014b979f77e4190ade8080070436dd208" checksum = "21ceb931d9f919731df1b1ecdc716b5c66384b413a7f95909d1f45441ab9bef5"
dependencies = [ dependencies = [
"cranelift-codegen", "cranelift-codegen",
"log", "log",
@ -397,9 +397,9 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-native" name = "cranelift-native"
version = "0.56.0" version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f9da354ffc3b9dd1c244eb23cc49048a7117bf685bc2a8fb5b3d4a3f6661d80" checksum = "564ee82268bc25b914fcf331edfc2452f2d9ca34f976b187b4ca668beba250c8"
dependencies = [ dependencies = [
"cranelift-codegen", "cranelift-codegen",
"raw-cpuid", "raw-cpuid",
@ -408,9 +408,9 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-wasm" name = "cranelift-wasm"
version = "0.56.0" version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f48052598a13f46fa6fe1490e460bd6c9c61e81823b2e527165566f8d76755a" checksum = "de63e2271b374be5b07f359184e2126a08fb24d24a740cbc178b7e0107ddafa5"
dependencies = [ dependencies = [
"cranelift-codegen", "cranelift-codegen",
"cranelift-entity", "cranelift-entity",
@ -418,7 +418,7 @@ dependencies = [
"log", "log",
"serde", "serde",
"thiserror", "thiserror",
"wasmparser 0.47.0", "wasmparser 0.48.2",
] ]
[[package]] [[package]]
@ -705,6 +705,16 @@ dependencies = [
"stable_deref_trait", "stable_deref_trait",
] ]
[[package]]
name = "gimli"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633"
dependencies = [
"byteorder",
"indexmap",
]
[[package]] [[package]]
name = "glob" name = "glob"
version = "0.3.0" version = "0.3.0"
@ -826,9 +836,9 @@ checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e"
[[package]] [[package]]
name = "jobserver" name = "jobserver"
version = "0.1.19" version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67b06c1b455f1cf4269a8cfc320ab930a810e2375a42af5075eb8a8b36405ce0" checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -1123,9 +1133,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro-error" name = "proc-macro-error"
version = "0.4.5" version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b79a464461615532fcc8a6ed8296fa66cc12350c18460ab3f4594a6cee0fcb6" checksum = "875077759af22fa20b610ad4471d8155b321c89c3f2785526c9839b099be4e0a"
dependencies = [ dependencies = [
"proc-macro-error-attr", "proc-macro-error-attr",
"proc-macro2", "proc-macro2",
@ -1136,9 +1146,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro-error-attr" name = "proc-macro-error-attr"
version = "0.4.5" version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23832e5eae6bac56bbac190500eef1aaede63776b5cd131eaa4ee7fe120cd892" checksum = "c5717d9fa2664351a01ed73ba5ef6df09c01a521cb42cb65a061432a826f3c7a"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1343,9 +1353,9 @@ dependencies = [
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.3.3" version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5508c1941e4e7cb19965abef075d35a9a8b5cdf0846f30b4050e9b55dc55e87" checksum = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
@ -1355,9 +1365,9 @@ dependencies = [
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.6.13" version = "0.6.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e734e891f5b408a29efbf8309e656876276f49ab6a6ac208600b4419bd893d90" checksum = "b28dfe3fe9badec5dbf0a79a9cccad2cfc2ab5484bdb3e44cbd1ae8b3ba2be06"
[[package]] [[package]]
name = "region" name = "region"
@ -1496,9 +1506,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.45" version = "1.0.46"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eab8f15f15d6c41a154c1b128a22f2dfabe350ef53c40953d84e36155c91192b" checksum = "21b01d7f0288608a01dca632cf1df859df6fd6ffa885300fc275ce2ba6221953"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
@ -1525,9 +1535,9 @@ checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
[[package]] [[package]]
name = "smallvec" name = "smallvec"
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"
checksum = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc"
[[package]] [[package]]
name = "spin" name = "spin"
@ -1558,9 +1568,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]] [[package]]
name = "structopt" name = "structopt"
version = "0.3.8" version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df136b42d76b1fbea72e2ab3057343977b04b4a2e00836c3c7c0673829572713" checksum = "a1bcbed7d48956fcbb5d80c6b95aedb553513de0a1b451ea92679d999c010e98"
dependencies = [ dependencies = [
"clap", "clap",
"lazy_static", "lazy_static",
@ -1569,9 +1579,9 @@ dependencies = [
[[package]] [[package]]
name = "structopt-derive" name = "structopt-derive"
version = "0.4.1" version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd50a87d2f7b8958055f3e73a963d78feaccca3836767a9069844e34b5b03c0a" checksum = "095064aa1f5b94d14e635d0a5684cf140c43ae40a0fd990708d38f5d669e5f64"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error", "proc-macro-error",
@ -1593,9 +1603,9 @@ dependencies = [
[[package]] [[package]]
name = "syn-mid" name = "syn-mid"
version = "0.4.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fd3937748a7eccff61ba5b90af1a20dbf610858923a9192ea0ecb0cb77db1d0" checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1670,18 +1680,18 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.9" version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f357d1814b33bc2dc221243f8424104bfe72dbe911d5b71b3816a2dff1c977e" checksum = "205684fd018ca14432b12cce6ea3d46763311a571c3d294e71ba3f01adcf1aad"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.9" version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb2e25d25307eb8436894f727aba8f65d07adf02e5b35a13cebed48bd282bfef" checksum = "57e4d2e50ca050ed44fb58309bdce3efa79948f84f9993ad1978de5eebdce5a7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1861,9 +1871,9 @@ checksum = "c702914acda5feeeffbc29e4d953e5b9ce79d8b98da4dbf18a77086e116c5470"
[[package]] [[package]]
name = "wasmparser" name = "wasmparser"
version = "0.47.0" version = "0.48.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1add8db5a53a2f64f13418b241982c4ab533d7a9e1e8a5dcadccce633d8d393b" checksum = "073da89bf1c84db000dd68ce660c1b4a08e3a2d28fd1e3394ab9e7abdde4a0f8"
[[package]] [[package]]
name = "wasmparser" name = "wasmparser"
@ -1947,7 +1957,7 @@ version = "0.9.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"faerie", "faerie",
"gimli", "gimli 0.19.0",
"more-asserts", "more-asserts",
"target-lexicon", "target-lexicon",
"thiserror", "thiserror",
@ -2142,6 +2152,15 @@ dependencies = [
"leb128", "leb128",
] ]
[[package]]
name = "wast"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed3db7029d1d31a15c10126e78b58e51781faefafbc8afb20fb01291b779984"
dependencies = [
"leb128",
]
[[package]] [[package]]
name = "wast" name = "wast"
version = "7.0.0" version = "7.0.0"
@ -2153,11 +2172,11 @@ dependencies = [
[[package]] [[package]]
name = "wat" name = "wat"
version = "1.0.8" version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5795e34a4b39893653dec97e644fac85c31398e0ce1abecc48967aac83d9e8ce" checksum = "9d59ba5b224f5507d55e4f89d0b18cc6452d84640ab11b4c9086d61a3ee62d03"
dependencies = [ dependencies = [
"wast 7.0.0", "wast 6.0.0",
] ]
[[package]] [[package]]

24
build.rs

@ -40,6 +40,20 @@ fn main() -> anyhow::Result<()> {
strategy, strategy,
) )
.expect("generating tests"); .expect("generating tests");
test_directory(
&mut out,
"tests/spec_testsuite/proposals/reference-types",
strategy,
)
.expect("generating tests");
test_directory(
&mut out,
"tests/spec_testsuite/proposals/bulk-memory-operations",
strategy,
)
.expect("generating tests");
} else { } else {
println!( println!(
"cargo:warning=The spec testsuite is disabled. To enable, run `git submodule \ "cargo:warning=The spec testsuite is disabled. To enable, run `git submodule \
@ -145,8 +159,10 @@ fn ignore(testsuite: &str, testname: &str, strategy: &str) -> bool {
match strategy { match strategy {
#[cfg(feature = "lightbeam")] #[cfg(feature = "lightbeam")]
"Lightbeam" => match (testsuite, testname) { "Lightbeam" => match (testsuite, testname) {
(_, _) if testname.starts_with("simd") => return true, ("simd", _) => return true,
(_, _) if testsuite.ends_with("multi_value") => return true, ("multi_value", _) => return true,
("reference_types", _) => return true,
("bulk_memory_operations", _) => return true,
// Lightbeam doesn't support float arguments on the stack. // Lightbeam doesn't support float arguments on the stack.
("spec_testsuite", "call") => return true, ("spec_testsuite", "call") => return true,
_ => (), _ => (),
@ -163,6 +179,10 @@ fn ignore(testsuite: &str, testname: &str, strategy: &str) -> bool {
("simd", "simd_load_extend") => return true, // FIXME Unsupported feature: proposed SIMD operator I16x8Load8x8S { memarg: MemoryImmediate { flags: 0, offset: 0 } } ("simd", "simd_load_extend") => return true, // FIXME Unsupported feature: proposed SIMD operator I16x8Load8x8S { memarg: MemoryImmediate { flags: 0, offset: 0 } }
("simd", "simd_load_splat") => return true, // FIXME Unsupported feature: proposed SIMD operator V8x16LoadSplat { memarg: MemoryImmediate { flags: 0, offset: 0 } } ("simd", "simd_load_splat") => return true, // FIXME Unsupported feature: proposed SIMD operator V8x16LoadSplat { memarg: MemoryImmediate { flags: 0, offset: 0 } }
("simd", "simd_splat") => return true, // FIXME Unsupported feature: proposed SIMD operator I8x16ShrS ("simd", "simd_splat") => return true, // FIXME Unsupported feature: proposed SIMD operator I8x16ShrS
("reference_types", _) => return true,
("bulk_memory_operations", _) => return true,
_ => {} _ => {}
}, },
_ => panic!("unrecognized strategy"), _ => panic!("unrecognized strategy"),

12
crates/api/src/trampoline/func.rs

@ -159,9 +159,9 @@ fn make_trampoline(
{ {
let mut builder = FunctionBuilder::new(&mut context.func, fn_builder_ctx); let mut builder = FunctionBuilder::new(&mut context.func, fn_builder_ctx);
let block0 = builder.create_ebb(); let block0 = builder.create_block();
builder.append_ebb_params_for_function_params(block0); builder.append_block_params_for_function_params(block0);
builder.switch_to_block(block0); builder.switch_to_block(block0);
builder.seal_block(block0); builder.seal_block(block0);
@ -172,7 +172,7 @@ fn make_trampoline(
continue; continue;
} }
let val = builder.func.dfg.ebb_params(block0)[i]; let val = builder.func.dfg.block_params(block0)[i];
builder.ins().store( builder.ins().store(
mflags, mflags,
val, val,
@ -181,9 +181,9 @@ fn make_trampoline(
); );
} }
let ebb_params = builder.func.dfg.ebb_params(block0); let block_params = builder.func.dfg.block_params(block0);
let vmctx_ptr_val = ebb_params[0]; let vmctx_ptr_val = block_params[0];
let caller_vmctx_ptr_val = ebb_params[1]; let caller_vmctx_ptr_val = block_params[1];
let call_id_val = builder.ins().iconst(types::I32, call_id as i64); let call_id_val = builder.ins().iconst(types::I32, call_id as i64);
let callee_args = vec![ let callee_args = vec![

8
crates/environ/Cargo.toml

@ -13,9 +13,9 @@ edition = "2018"
[dependencies] [dependencies]
anyhow = "1.0" anyhow = "1.0"
cranelift-codegen = { version = "0.56", features = ["enable-serde"] } cranelift-codegen = { version = "0.58.0", features = ["enable-serde"] }
cranelift-entity = { version = "0.56", features = ["enable-serde"] } cranelift-entity = { version = "0.58.0", features = ["enable-serde"] }
cranelift-wasm = { version = "0.56", features = ["enable-serde"] } cranelift-wasm = { version = "0.58.0", features = ["enable-serde"] }
wasmparser = "0.51.0" wasmparser = "0.51.0"
lightbeam = { path = "../lightbeam", optional = true, version = "0.9.0" } lightbeam = { path = "../lightbeam", optional = true, version = "0.9.0" }
indexmap = "1.0.2" indexmap = "1.0.2"
@ -44,7 +44,7 @@ tempfile = "3"
target-lexicon = { version = "0.10.0", default-features = false } target-lexicon = { version = "0.10.0", default-features = false }
pretty_env_logger = "0.3.0" pretty_env_logger = "0.3.0"
rand = { version = "0.7.0", default-features = false, features = ["small_rng"] } rand = { version = "0.7.0", default-features = false, features = ["small_rng"] }
cranelift-codegen = { version = "0.56", features = ["enable-serde", "all-arch"] } cranelift-codegen = { version = "0.58.0", features = ["enable-serde", "all-arch"] }
filetime = "0.2.7" filetime = "0.2.7"
lazy_static = "1.3.0" lazy_static = "1.3.0"

1
crates/environ/src/cache/tests.rs

@ -317,7 +317,6 @@ fn new_module_cache_data(rng: &mut impl Rng) -> ModuleCacheData {
size: rng.gen(), size: rng.gen(),
offset: rng.gen(), offset: rng.gen(),
}); });
slots.frame_size = rng.gen();
slots slots
}) })
.collect(); .collect();

14
crates/environ/src/cranelift.rs

@ -30,14 +30,14 @@ pub struct RelocSink {
} }
impl binemit::RelocSink for RelocSink { impl binemit::RelocSink for RelocSink {
fn reloc_ebb( fn reloc_block(
&mut self, &mut self,
_offset: binemit::CodeOffset, _offset: binemit::CodeOffset,
_reloc: binemit::Reloc, _reloc: binemit::Reloc,
_ebb_offset: binemit::CodeOffset, _block_offset: binemit::CodeOffset,
) { ) {
// This should use the `offsets` field of `ir::Function`. // This should use the `offsets` field of `ir::Function`.
panic!("ebb headers not yet implemented"); panic!("block headers not yet implemented");
} }
fn reloc_external( fn reloc_external(
&mut self, &mut self,
@ -134,12 +134,12 @@ fn get_function_address_map<'data>(
let mut instructions = Vec::new(); let mut instructions = Vec::new();
let func = &context.func; let func = &context.func;
let mut ebbs = func.layout.ebbs().collect::<Vec<_>>(); let mut blocks = func.layout.blocks().collect::<Vec<_>>();
ebbs.sort_by_key(|ebb| func.offsets[*ebb]); // Ensure inst offsets always increase blocks.sort_by_key(|block| func.offsets[*block]); // Ensure inst offsets always increase
let encinfo = isa.encoding_info(); let encinfo = isa.encoding_info();
for ebb in ebbs { for block in blocks {
for (offset, inst, size) in func.inst_offsets(ebb, &encinfo) { for (offset, inst, size) in func.inst_offsets(block, &encinfo) {
let srcloc = func.srclocs[inst]; let srcloc = func.srclocs[inst];
instructions.push(InstructionAddressMap { instructions.push(InstructionAddressMap {
srcloc, srcloc,

75
crates/environ/src/func_environ.rs

@ -425,6 +425,81 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
})) }))
} }
fn translate_table_grow(
&mut self,
_: cranelift_codegen::cursor::FuncCursor<'_>,
_: u32,
_: ir::Value,
_: ir::Value,
) -> WasmResult<ir::Value> {
Err(WasmError::Unsupported(
"the `table.grow` instruction is not supported yet".into(),
))
}
fn translate_table_get(
&mut self,
_: cranelift_codegen::cursor::FuncCursor<'_>,
_: u32,
_: ir::Value,
) -> WasmResult<ir::Value> {
Err(WasmError::Unsupported(
"the `table.get` instruction is not supported yet".into(),
))
}
fn translate_table_set(
&mut self,
_: cranelift_codegen::cursor::FuncCursor<'_>,
_: u32,
_: ir::Value,
_: ir::Value,
) -> WasmResult<()> {
Err(WasmError::Unsupported(
"the `table.set` instruction is not supported yet".into(),
))
}
fn translate_table_fill(
&mut self,
_: cranelift_codegen::cursor::FuncCursor<'_>,
_: u32,
_: ir::Value,
_: ir::Value,
_: ir::Value,
) -> WasmResult<()> {
Err(WasmError::Unsupported(
"the `table.fill` instruction is not supported yet".into(),
))
}
fn translate_ref_func(
&mut self,
_: cranelift_codegen::cursor::FuncCursor<'_>,
_: u32,
) -> WasmResult<ir::Value> {
Err(WasmError::Unsupported(
"the `ref.func` instruction is not supported yet".into(),
))
}
fn translate_custom_global_get(
&mut self,
_: cranelift_codegen::cursor::FuncCursor<'_>,
_: cranelift_wasm::GlobalIndex,
) -> WasmResult<ir::Value> {
unreachable!("we don't make any custom globals")
}
fn translate_custom_global_set(
&mut self,
_: cranelift_codegen::cursor::FuncCursor<'_>,
_: cranelift_wasm::GlobalIndex,
_: ir::Value,
) -> WasmResult<()> {
unreachable!("we don't make any custom globals")
}
fn make_heap(&mut self, func: &mut ir::Function, index: MemoryIndex) -> WasmResult<ir::Heap> { fn make_heap(&mut self, func: &mut ir::Function, index: MemoryIndex) -> WasmResult<ir::Heap> {
let pointer_type = self.pointer_type(); let pointer_type = self.pointer_type();

2
crates/fuzzing/Cargo.toml

@ -13,7 +13,7 @@ binaryen = "0.10.0"
env_logger = "0.7.1" env_logger = "0.7.1"
log = "0.4.8" log = "0.4.8"
wasmparser = "0.51.0" wasmparser = "0.51.0"
wasmprinter = "0.2.0" wasmprinter = "0.2.1"
wasmtime = { path = "../api", version = "0.9.0" } wasmtime = { path = "../api", version = "0.9.0" }
[dev-dependencies] [dev-dependencies]

10
crates/jit/Cargo.toml

@ -11,11 +11,11 @@ readme = "README.md"
edition = "2018" edition = "2018"
[dependencies] [dependencies]
cranelift-codegen = { version = "0.56", features = ["enable-serde"] } cranelift-codegen = { version = "0.58.0", features = ["enable-serde"] }
cranelift-entity = { version = "0.56", features = ["enable-serde"] } cranelift-entity = { version = "0.58.0", features = ["enable-serde"] }
cranelift-wasm = { version = "0.56", features = ["enable-serde"] } cranelift-wasm = { version = "0.58.0", features = ["enable-serde"] }
cranelift-native = "0.56" cranelift-native = "0.58.0"
cranelift-frontend = "0.56" cranelift-frontend = "0.58.0"
wasmtime-environ = { path = "../environ", version = "0.9.0" } wasmtime-environ = { path = "../environ", version = "0.9.0" }
wasmtime-runtime = { path = "../runtime", version = "0.9.0" } wasmtime-runtime = { path = "../runtime", version = "0.9.0" }
wasmtime-debug = { path = "../debug", version = "0.9.0" } wasmtime-debug = { path = "../debug", version = "0.9.0" }

12
crates/jit/src/compiler.rs

@ -281,14 +281,14 @@ fn make_trampoline(
{ {
let mut builder = FunctionBuilder::new(&mut context.func, fn_builder_ctx); let mut builder = FunctionBuilder::new(&mut context.func, fn_builder_ctx);
let block0 = builder.create_ebb(); let block0 = builder.create_block();
builder.append_ebb_params_for_function_params(block0); builder.append_block_params_for_function_params(block0);
builder.switch_to_block(block0); builder.switch_to_block(block0);
builder.seal_block(block0); builder.seal_block(block0);
let (vmctx_ptr_val, caller_vmctx_ptr_val, values_vec_ptr_val) = { let (vmctx_ptr_val, caller_vmctx_ptr_val, values_vec_ptr_val) = {
let params = builder.func.dfg.ebb_params(block0); let params = builder.func.dfg.block_params(block0);
(params[0], params[1], params[2]) (params[0], params[1], params[2])
}; };
@ -412,13 +412,13 @@ fn register_traps(
struct RelocSink {} struct RelocSink {}
impl binemit::RelocSink for RelocSink { impl binemit::RelocSink for RelocSink {
fn reloc_ebb( fn reloc_block(
&mut self, &mut self,
_offset: binemit::CodeOffset, _offset: binemit::CodeOffset,
_reloc: binemit::Reloc, _reloc: binemit::Reloc,
_ebb_offset: binemit::CodeOffset, _block_offset: binemit::CodeOffset,
) { ) {
panic!("trampoline compilation should not produce ebb relocs"); panic!("trampoline compilation should not produce block relocs");
} }
fn reloc_external( fn reloc_external(
&mut self, &mut self,

6
crates/jit/src/trampoline.rs

@ -20,13 +20,13 @@ pub mod binemit {
pub struct TrampolineRelocSink {} pub struct TrampolineRelocSink {}
impl binemit::RelocSink for TrampolineRelocSink { impl binemit::RelocSink for TrampolineRelocSink {
fn reloc_ebb( fn reloc_block(
&mut self, &mut self,
_offset: binemit::CodeOffset, _offset: binemit::CodeOffset,
_reloc: binemit::Reloc, _reloc: binemit::Reloc,
_ebb_offset: binemit::CodeOffset, _block_offset: binemit::CodeOffset,
) { ) {
panic!("trampoline compilation should not produce ebb relocs"); panic!("trampoline compilation should not produce block relocs");
} }
fn reloc_external( fn reloc_external(
&mut self, &mut self,

2
crates/lightbeam/Cargo.toml

@ -19,7 +19,7 @@ memoffset = "0.5.3"
itertools = "0.8.2" itertools = "0.8.2"
capstone = "0.6.0" capstone = "0.6.0"
thiserror = "1.0.9" thiserror = "1.0.9"
cranelift-codegen = "0.56" cranelift-codegen = "0.58.0"
multi_mut = "0.1" multi_mut = "0.1"
either = "1.5" either = "1.5"
typemap = "0.3" typemap = "0.3"

2
crates/lightbeam/src/translate_sections.rs

@ -80,7 +80,7 @@ pub fn element(elements: ElementSectionReader) -> Result<(), Error> {
struct UnimplementedRelocSink; struct UnimplementedRelocSink;
impl binemit::RelocSink for UnimplementedRelocSink { impl binemit::RelocSink for UnimplementedRelocSink {
fn reloc_ebb(&mut self, _: binemit::CodeOffset, _: binemit::Reloc, _: binemit::CodeOffset) { fn reloc_block(&mut self, _: binemit::CodeOffset, _: binemit::Reloc, _: binemit::CodeOffset) {
unimplemented!() unimplemented!()
} }

2
crates/runtime/src/instance.rs

@ -1017,7 +1017,7 @@ fn initialize_globals(instance: &Instance) {
*to = from; *to = from;
} }
GlobalInit::Import => panic!("locally-defined global initialized as import"), GlobalInit::Import => panic!("locally-defined global initialized as import"),
GlobalInit::RefNullConst => unimplemented!(), GlobalInit::RefNullConst | GlobalInit::RefFunc(_) => unimplemented!(),
} }
} }
} }

29
crates/wast/src/wast.rs

@ -288,36 +288,27 @@ impl WastContext {
}; };
let error_message = format!("{:?}", err); let error_message = format!("{:?}", err);
if !error_message.contains(&message) { if !error_message.contains(&message) {
// TODO: change to bail! bail!(
println!( "assert_invalid: expected \"{}\", got \"{}\"",
"assert_invalid: expected {}, got {}", message,
message, error_message error_message
) )
} }
} }
AssertMalformed { AssertMalformed {
span: _,
module, module,
message, span: _,
message: _,
} => { } => {
let mut module = match module { let mut module = match module {
wast::QuoteModule::Module(m) => m, wast::QuoteModule::Module(m) => m,
// this is a `*.wat` parser test which we're not // This is a `*.wat` parser test which we're not
// interested in // interested in.
wast::QuoteModule::Quote(_) => return Ok(()), wast::QuoteModule::Quote(_) => return Ok(()),
}; };
let bytes = module.encode()?; let bytes = module.encode()?;
let err = match self.module(None, &bytes) { if let Ok(_) = self.module(None, &bytes) {
Ok(()) => bail!("expected module to fail to instantiate"), bail!("expected malformed module to fail to instantiate");
Err(e) => e,
};
let error_message = format!("{:?}", err);
if !error_message.contains(&message) {
// TODO: change to bail!
println!(
"assert_malformed: expected {}, got {}",
message, error_message
)
} }
} }
AssertUnlinkable { AssertUnlinkable {

10
tests/wast_testsuites.rs

@ -12,10 +12,16 @@ fn run_wast(wast: &str, strategy: Strategy) -> anyhow::Result<()> {
let simd = wast.iter().any(|s| s == "simd"); let simd = wast.iter().any(|s| s == "simd");
// Some simd tests assume support for multiple tables, which are introduced
// by reference types.
let reftypes = simd || wast.iter().any(|s| s == "reference-types");
let multi_val = wast.iter().any(|s| s == "multi-value");
let mut cfg = Config::new(); let mut cfg = Config::new();
cfg.wasm_simd(simd) cfg.wasm_simd(simd)
.wasm_reference_types(simd) // some simd tests assume multiple tables ok .wasm_reference_types(reftypes)
.wasm_multi_value(wast.iter().any(|s| s == "multi-value")) .wasm_multi_value(multi_val)
.strategy(strategy)? .strategy(strategy)?
.cranelift_debug_verifier(true); .cranelift_debug_verifier(true);
let store = Store::new(&Engine::new(&cfg)); let store = Store::new(&Engine::new(&cfg));

Loading…
Cancel
Save