Bug 1717895 - Bump wast version and handle assert_exception r=rhunt
authorAsumu Takikawa <asumu@igalia.com>
Thu, 02 Sep 2021 15:56:01 +0000
changeset 590829 16701eb6570662d4e1ffb50f6d43db679766130f
parent 590828 d68c972998b5eb7736d56d3367ddfdb6a9a96122
child 590830 f6f4514d09bf220c9a0f2fd6abfeec36891ce36a
push id38757
push usermalexandru@mozilla.com
push dateFri, 03 Sep 2021 03:51:58 +0000
treeherdermozilla-central@3634785345fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhunt
bugs1717895
milestone93.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1717895 - Bump wast version and handle assert_exception r=rhunt This updates wast2js to be able to handle exception handling core spec tests. Differential Revision: https://phabricator.services.mozilla.com/D123403
js/src/jit-test/etc/wasm/generate-spectests/Cargo.lock
js/src/jit-test/etc/wasm/generate-spectests/wast2js/Cargo.toml
js/src/jit-test/etc/wasm/generate-spectests/wast2js/src/convert.rs
js/src/jit-test/etc/wasm/generate-spectests/wast2js/src/harness.js
--- a/js/src/jit-test/etc/wasm/generate-spectests/Cargo.lock
+++ b/js/src/jit-test/etc/wasm/generate-spectests/Cargo.lock
@@ -1,10 +1,12 @@
 # This file is automatically @generated by Cargo.
 # It is not intended for manual editing.
+version = 3
+
 [[package]]
 name = "Inflector"
 version = "0.11.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3"
 dependencies = [
  "lazy_static",
  "regex",
@@ -811,19 +813,19 @@ dependencies = [
  "serde",
  "serde_derive",
  "toml",
  "wast2js",
 ]
 
 [[package]]
 name = "wast"
-version = "35.0.2"
+version = "38.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2ef140f1b49946586078353a453a1d28ba90adfc54dde75710bc1931de204d68"
+checksum = "0ebc29df4629f497e0893aacd40f13a4a56b85ef6eb4ab6d603f07244f1a7bf2"
 dependencies = [
  "leb128",
 ]
 
 [[package]]
 name = "wast2js"
 version = "0.1.0"
 dependencies = [
--- a/js/src/jit-test/etc/wasm/generate-spectests/wast2js/Cargo.toml
+++ b/js/src/jit-test/etc/wasm/generate-spectests/wast2js/Cargo.toml
@@ -3,10 +3,10 @@ name = "wast2js"
 version = "0.1.0"
 authors = ["Ryan Hunt <rhunt@eqrion.net>"]
 edition = "2018"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
 anyhow = "1.0.19"
-wast = { version = "35.0.0" }
+wast = { version = "38.0.0" }
 dprint-plugin-typescript = { version = "0.46.0" }
--- a/js/src/jit-test/etc/wasm/generate-spectests/wast2js/src/convert.rs
+++ b/js/src/jit-test/etc/wasm/generate-spectests/wast2js/src/convert.rs
@@ -173,17 +173,20 @@ fn convert_directive(
                 escape_template_string(message)
             )?;
         }
         AssertInvalid {
             span: _,
             module,
             message,
         } => {
-            let text = module_to_js_string(&module, wast)?;
+            let text = match module {
+                wast::QuoteModule::Module(m) => module_to_js_string(&m, wast)?,
+                wast::QuoteModule::Quote(source) => quote_module_to_js_string(source)?,
+            };
             writeln!(
                 out,
                 "assert_invalid(() => instantiate(`{}`), `{}`);",
                 text,
                 escape_template_string(message)
             )?;
         }
         AssertMalformed {
@@ -210,16 +213,26 @@ fn convert_directive(
             let text = module_to_js_string(&module, wast)?;
             writeln!(
                 out,
                 "assert_unlinkable(() => instantiate(`{}`), `{}`);",
                 text,
                 escape_template_string(message)
             )?;
         }
+        AssertException {
+            span: _,
+            exec,
+        } => {
+            writeln!(
+                out,
+                "assert_exception(() => {});",
+                execute_to_js(current_instance, exec, wast)?,
+            )?;
+        }
     }
     writeln!(out, "")?;
 
     Ok(())
 }
 
 fn escape_template_string(text: &str) -> String {
     text.replace("$", "$$")
--- a/js/src/jit-test/etc/wasm/generate-spectests/wast2js/src/harness.js
+++ b/js/src/jit-test/etc/wasm/generate-spectests/wast2js/src/harness.js
@@ -195,16 +195,26 @@ function assert_malformed(thunk, message
     assertEq(err instanceof TypeError ||
              err instanceof SyntaxError ||
              err instanceof WebAssembly.CompileError ||
              err instanceof WebAssembly.LinkError, true,
              `expected a malformed module`);
   }
 }
 
+function assert_exception(thunk) {
+  let thrown = false;
+  try {
+    thunk();
+  } catch (err) {
+    thrown = true;
+  }
+  assertEq(thrown, true, "expected an exception to be thrown");
+}
+
 function assert_return(thunk, expected) {
   let results = thunk();
 
   if (results === undefined) {
     results = [];
   } else if (!Array.isArray(results)) {
     results = [results];
   }