Backed out changeset 8030f70a5130 (bug 1308056)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Tue, 11 Oct 2016 14:24:59 +0200
changeset 360371 8276f7f3413f821e07bbea0f77842d807b951815
parent 360370 8030f70a51308de1e8448e538817b86b7315721e
child 360372 206a77f3fffbc168474cfc3acc13630d22658faf
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1308056
milestone52.0a1
backs out8030f70a51308de1e8448e538817b86b7315721e
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
Backed out changeset 8030f70a5130 (bug 1308056)
js/src/jit-test/tests/wasm/spec.js
js/src/jit-test/tests/wasm/spec/br.wast.js
js/src/jit-test/tests/wasm/spec/br_table.wast.js
js/src/jit-test/tests/wasm/spec/call_indirect.wast.js
js/src/jit-test/tests/wasm/spec/exports.wast.js
js/src/jit-test/tests/wasm/spec/func.wast.js
js/src/jit-test/tests/wasm/spec/func_ptrs.wast.js
js/src/jit-test/tests/wasm/spec/globals.wast.js
js/src/jit-test/tests/wasm/spec/imports.wast
js/src/jit-test/tests/wasm/spec/imports.wast.js
js/src/jit-test/tests/wasm/spec/left-to-right.wast.js
js/src/jit-test/tests/wasm/spec/return.wast.js
js/src/jit-test/tests/wasm/spec/unreachable.wast.js
--- a/js/src/jit-test/tests/wasm/spec.js
+++ b/js/src/jit-test/tests/wasm/spec.js
@@ -40,16 +40,18 @@ Element.prototype.toString = function() 
         if (this.quoted) {
             return `"${this.str}"`;
         }
         return this.str;
     }
     return `(${this.list.map(x => x.toString()).join(" ")})`;
 };
 
+var module;
+
 setJitCompilerOption('wasm.test-mode', 1);
 
 // Creates a tree of s-expressions. Ported from Binaryen's SExpressionParser.
 function parseSExpression(text) {
     var input = 0;
 
     var commentDepth = 0;
     function skipBlockComment() {
@@ -187,20 +189,19 @@ function parseSExpression(text) {
     while (!root) { // Keep parsing until we pass an initial comment.
         root = parseInnerList();
     }
     return root;
 }
 
 var imports = {
     spectest: {
-        print,
-        global: 666,
-        table: new WebAssembly.Table({ initial: 10, maximum: 20, element: "anyfunc" }),
-        memory: new WebAssembly.Memory({ initial: 1, maximum: 2 }),
+        print: function (x) {
+            print(x);
+        }
     }
 };
 
 function handleNonStandard(exprName, e)
 {
     if (exprName === 'quit') {
         quit();
     }
@@ -253,80 +254,44 @@ function testNaNEqualityFunction() {
 
     assertEq(f64[0], f64[1]);
     assertErrorMessage(() => assertEqNaN(pNaN, nNaN), Error, /Assertion failed/);
     assertEqNaN(pNaN, pNaN);
     assertEqNaN(nNaN, nNaN);
 }
 
 var constantCache = new Map;
-var moduleCache = new Map;
-
-function getModuleAndField(e) {
-    let nextArgIndex = 1;
-    let nameExpr = e.list[nextArgIndex];
-    let name = nameExpr.str;
-
-    let moduleName = '__last_module__';
-    if (nameExpr.dollared && !nameExpr.quoted) {
-        moduleName = name;
-        nextArgIndex += 1;
-    }
-
-    if (!moduleCache.has(moduleName)) {
-        throw new Error('We should have a module here before trying to invoke things!');
-    }
-
-    let module = moduleCache.get(moduleName);
-    let fieldName = e.list[nextArgIndex++].str;
-    let rest = e.list.slice(nextArgIndex).map(exec);
-
-    return [module, fieldName, rest];
-}
 
 // Recursively execute the expression.
 function exec(e) {
     var exprName = e.list[0].str;
 
     if (exprName === "module") {
         let moduleText = e.toString();
-
-        let moduleName = null;
-        if (e.list && e.list.length >= 2 && e.list[1].str && e.list[1].dollared) {
-            moduleName = e.list[1].str;
-            moduleText = moduleText.replace(`$${moduleName}`, '');
-        }
-
-        let module = wasmEvalText(moduleText, imports).exports;
-        moduleCache.set('__last_module__', module);
-        if (moduleName) {
-            moduleCache.set(moduleName, module);
-        }
-
+        module = wasmEvalText(moduleText, imports).exports;
         return;
     }
 
     if (exprName === "invoke") {
-        let [module, field, args] = getModuleAndField(e);
+        var name = e.list[1].str;
+        var args = e.list.slice(2).map(exec);
+        var fn = null;
 
-        let fn = null;
-        if (typeof module[field] === "function") {
-            fn = module[field];
-        } else {
-            throw new Error("Exported function not found: " + e);
+        if (module === null) {
+            throw new Error('We should have a module here before trying to invoke things!');
         }
 
+        if (typeof module[name] === "function") {
+            fn = module[name];
+        } else {
+            assert(false, "Exported function not found: " + e);
+        }
         return fn.apply(null, args);
     }
 
-    if (exprName === "get") {
-        let [module, field, args] = getModuleAndField(e);
-        return module[field];
-    }
-
     if (exprName.indexOf(".const") > 0) {
         // Eval the expression using a wasm module.
         var type = exprName.substring(0, exprName.indexOf(".const"));
         var key = e.toString();
 
         if (constantCache.has(key)) {
             return constantCache.get(key);
         }
@@ -405,36 +370,16 @@ function exec(e) {
             caught = true;
             if (err.toString().indexOf(errMsg) === -1)
                 warn(`expected error message "${errMsg}", got "${err}"`);
         }
         assert(caught, "assert_trap exception not caught");
         return;
     }
 
-    if (exprName === 'assert_unlinkable') {
-        let moduleText = e.list[1].toString();
-        let errMsg = e.list[2];
-        if (errMsg) {
-            assert(errMsg.quoted, "assert_invalid second argument must be a string");
-            errMsg.quoted = false;
-        }
-        let module = new WebAssembly.Module(wasmTextToBinary(moduleText));
-        let caught = false;
-        try {
-            new WebAssembly.Instance(module, imports);
-        } catch(err) {
-            caught = true;
-            if (err.toString().indexOf(errMsg) === -1)
-                warn(`expected error message "${errMsg}", got "${err}"`);
-        }
-        assert(caught, "assert_unlinkable exception not caught");
-        return;
-    }
-
     if (!handleNonStandard(exprName, e)) {
         assert(false, "NYI: " + e);
     }
 }
 
 var args = typeof importedArgs !== 'undefined' ? importedArgs : scriptArgs;
 
 // Whether we should keep on executing tests if one of them failed or throw.
--- a/js/src/jit-test/tests/wasm/spec/br.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/br.wast.js
@@ -1,2 +1,4 @@
 // |jit-test| test-also-wasm-baseline
+// TODO: new anyfunc table syntax
+quit();
 var importedArgs = ['br.wast']; load(scriptdir + '../spec.js');
--- a/js/src/jit-test/tests/wasm/spec/br_table.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/br_table.wast.js
@@ -1,2 +1,4 @@
 // |jit-test| test-also-wasm-baseline
+// TODO: new anyfunc table syntax
+quit();
 var importedArgs = ['br_table.wast']; load(scriptdir + '../spec.js');
--- a/js/src/jit-test/tests/wasm/spec/call_indirect.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/call_indirect.wast.js
@@ -1,2 +1,4 @@
 // |jit-test| test-also-wasm-baseline
+// TODO: new anyfunc table syntax
+quit();
 var importedArgs = ['call_indirect.wast']; load(scriptdir + '../spec.js');
--- a/js/src/jit-test/tests/wasm/spec/exports.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/exports.wast.js
@@ -1,2 +1,5 @@
 // |jit-test| test-also-wasm-baseline
+// TODO: module names
+// TODO: new anyfunc table syntax
+quit();
 var importedArgs = ['exports.wast']; load(scriptdir + '../spec.js');
--- a/js/src/jit-test/tests/wasm/spec/func.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/func.wast.js
@@ -1,2 +1,4 @@
 // |jit-test| test-also-wasm-baseline
+// TODO: new anyfunc table syntax
+quit();
 var importedArgs = ['func.wast']; load(scriptdir + '../spec.js');
--- a/js/src/jit-test/tests/wasm/spec/func_ptrs.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/func_ptrs.wast.js
@@ -1,2 +1,4 @@
 // |jit-test| test-also-wasm-baseline
+// TODO: new anyfunc table syntax
+quit();
 var importedArgs = ['func_ptrs.wast']; load(scriptdir + '../spec.js');
deleted file mode 100644
--- a/js/src/jit-test/tests/wasm/spec/globals.wast.js
+++ /dev/null
@@ -1,2 +0,0 @@
-// |jit-test| test-also-wasm-baseline
-var importedArgs = ['globals.wast']; load(scriptdir + '../spec.js');
--- a/js/src/jit-test/tests/wasm/spec/imports.wast
+++ b/js/src/jit-test/tests/wasm/spec/imports.wast
@@ -72,28 +72,26 @@
   ;; (func (export "set-y") (param i32) (set_global $y (get_local 0)))
 )
 
 (assert_return (invoke "get-0") (i32.const 666))
 (assert_return (invoke "get-1") (i32.const 666))
 (assert_return (invoke "get-x") (i32.const 666))
 (assert_return (invoke "get-y") (i32.const 666))
 
-;; TODO; Tests not adapted for a JS host!
-;;(assert_unlinkable
-;;  (module (import "spectest" "unknown" (global i32)))
-;;  "unknown import"
-;;)
-;;(assert_unlinkable
-;;  (module (import "spectest" "print" (global i32)))
-;;  "type mismatch"
-;;)
+(assert_unlinkable
+  (module (import "spectest" "unknown" (global i32)))
+  "unknown import"
+)
+(assert_unlinkable
+  (module (import "spectest" "print" (global i32)))
+  "type mismatch"
+)
 
-;; TODO;
-;;(module (import "spectest" "global" (global i64)))
+(module (import "spectest" "global" (global i64)))
 (module (import "spectest" "global" (global f32)))
 (module (import "spectest" "global" (global f64)))
 
 
 ;; Tables
 
 (module
   (type (func (result i32)))
--- a/js/src/jit-test/tests/wasm/spec/imports.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/imports.wast.js
@@ -1,2 +1,4 @@
 // |jit-test| test-also-wasm-baseline
+// TODO: new anyfunc table syntax
+quit();
 var importedArgs = ['imports.wast']; load(scriptdir + '../spec.js');
--- a/js/src/jit-test/tests/wasm/spec/left-to-right.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/left-to-right.wast.js
@@ -1,2 +1,4 @@
 // |jit-test| test-also-wasm-baseline
+// TODO: new anyfunc table syntax
+quit();
 var importedArgs = ['left-to-right.wast']; load(scriptdir + '../spec.js');
--- a/js/src/jit-test/tests/wasm/spec/return.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/return.wast.js
@@ -1,2 +1,4 @@
 // |jit-test| test-also-wasm-baseline
+// TODO: new anyfunc table syntax
+quit();
 var importedArgs = ['return.wast']; load(scriptdir + '../spec.js');
--- a/js/src/jit-test/tests/wasm/spec/unreachable.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/unreachable.wast.js
@@ -1,2 +1,4 @@
 // |jit-test| test-also-wasm-baseline
+// TODO: new anyfunc table syntax
+quit();
 var importedArgs = ['unreachable.wast']; load(scriptdir + '../spec.js');