Bug 1313024: Implement assert_soft_invalid in the wast interpreter; r=luke
authorBenjamin Bouvier <benj@benj.me>
Wed, 26 Oct 2016 18:42:25 +0200
changeset 320010 fb3cd4dc8aef5f2e33a274c21e5e0acc7cce230a
parent 320009 58c6affba442284f0ca3b02f14b1f10ea1907109
child 320011 9a5184bfa3877779da110696be3e68ce43b05227
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1313024
milestone52.0a1
Bug 1313024: Implement assert_soft_invalid in the wast interpreter; r=luke MozReview-Commit-ID: 6P8lfjzxUSd
js/src/jit-test/tests/wasm/spec.js
js/src/jit-test/tests/wasm/spec/imports.wast
js/src/jit-test/tests/wasm/spec/linking.wast
js/src/jit-test/tests/wasm/spec/linking.wast.js
js/src/jit-test/tests/wasm/spec/memory.wast.js
js/src/jit-test/tests/wasm/spec/soft-fail.wast.js
--- a/js/src/jit-test/tests/wasm/spec.js
+++ b/js/src/jit-test/tests/wasm/spec.js
@@ -411,16 +411,33 @@ function exec(e) {
         } catch(e) {
             if (/wasm text error/.test(e.toString()))
                 return;
             throw e;
         }
         return;
     }
 
+    if (exprName === "assert_soft_invalid") {
+        let moduleText = e.list[1].toString();
+        let errMsg = e.list[2];
+        if (errMsg) {
+            assert(errMsg.quoted, "assert_soft_invalid second argument must be a string");
+            errMsg.quoted = false;
+        }
+
+        try {
+            new WebAssembly.Module(wasmTextToBinary(moduleText));
+        } catch(e) {
+            debug('assert_soft_invalid caught:\nExpected:', errMsg, '\nActual:', e.toString());
+        }
+
+        return;
+    }
+
     if (exprName === 'assert_trap') {
         let caught = false;
         let errMsg = e.list[2];
         assert(errMsg.quoted, "assert_trap second argument must be a string");
         errMsg.quoted = false;
         try {
             exec(e.list[1]);
         } catch(err) {
--- a/js/src/jit-test/tests/wasm/spec/imports.wast
+++ b/js/src/jit-test/tests/wasm/spec/imports.wast
@@ -172,17 +172,18 @@
 
 (module
   (import "spectest" "global" (global i32))
   (global (import "spectest" "global") i32)
 
   (import "spectest" "global" (global $x i32))
   (global $y (import "spectest" "global") i32)
 
-  (import "spectest" "global" (global i64))
+  ;; limitation of the spidermonkey testing mode (an imported global can't be both a number and i64).
+  ;;(import "spectest" "global" (global i64))
   (import "spectest" "global" (global f32))
   (import "spectest" "global" (global f64))
 
   (func (export "get-0") (result i32) (get_global 0))
   (func (export "get-1") (result i32) (get_global 1))
   (func (export "get-x") (result i32) (get_global $x))
   (func (export "get-y") (result i32) (get_global $y))
 )
--- a/js/src/jit-test/tests/wasm/spec/linking.wast
+++ b/js/src/jit-test/tests/wasm/spec/linking.wast
@@ -152,17 +152,17 @@
 (assert_trap (invoke $Nt "Mt.call" (i32.const 0)) "uninitialized")
 (assert_return (invoke $Nt "call" (i32.const 0)) (i32.const 5))
 (assert_trap (invoke $Nt "call Mt.call" (i32.const 0)) "uninitialized")
 (assert_trap (invoke $Ot "call" (i32.const 0)) "uninitialized")
 
 (assert_trap (invoke $Ot "call" (i32.const 20)) "undefined")
 
 (assert_unlinkable
-  (module $Qt
+  (module
     (func $host (import "spectest" "print"))
     (table (import "Mt" "tab") 10 anyfunc)
     (memory (import "Mt" "mem") 1)  ;; does not exist
     (elem (i32.const 7) $own)
     (elem (i32.const 9) $host)
     (func $own (result i32) (i32.const 666))
   )
   "unknown import"
@@ -225,17 +225,17 @@
 (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 3))
 (assert_return (invoke $Pm "grow" (i32.const 1)) (i32.const 3))
 (assert_return (invoke $Pm "grow" (i32.const 1)) (i32.const 4))
 (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 5))
 (assert_return (invoke $Pm "grow" (i32.const 1)) (i32.const -1))
 (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 5))
 
 (assert_unlinkable
-  (module $Qm
+  (module
     (func $host (import "spectest" "print"))
     (memory (import "Mm" "mem") 1)
     (table (import "Mm" "tab") 0 anyfunc)  ;; does not exist
     (data (i32.const 0) "abc")
   )
   "unknown import"
 )
 (assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 0))
--- a/js/src/jit-test/tests/wasm/spec/linking.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/linking.wast.js
@@ -1,4 +1,4 @@
 // |jit-test| test-also-wasm-baseline
-// TODO type mismatch on reimports
+// TODO type checks against exotic exported function objects
 quit();
 var importedArgs = ['linking.wast']; load(scriptdir + '../spec.js');
--- a/js/src/jit-test/tests/wasm/spec/memory.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/memory.wast.js
@@ -1,4 +1,6 @@
 // |jit-test| test-also-wasm-baseline
-// TODO initializer expression can reference global mutable (module-defined) variables?
+// TODO initializer expression can reference global module-defined variables?
+// TODO data segment fitting must be done at instantiation time, not compile time
+// TODO module with 0-sized memory can accept empty segments at any offsets?
 quit();
 var importedArgs = ['memory.wast']; load(scriptdir + '../spec.js');
--- a/js/src/jit-test/tests/wasm/spec/soft-fail.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/soft-fail.wast.js
@@ -1,4 +1,2 @@
 // |jit-test| test-also-wasm-baseline
-// TODO operator assert_soft_invalid
-quit();
 var importedArgs = ['soft-fail.wast']; load(scriptdir + '../spec.js');