Bug 1332691: Allow including files with a jit-test directive; r=sfink
authorBenjamin Bouvier <benj@benj.me>
Thu, 23 Feb 2017 12:10:10 +0100
changeset 373791 07b697bc921ff8d49d0f38ae83ec5ad911bb056e
parent 373790 2c9427dde77e18e358316e360c340960eadf1633
child 373792 f98c8a722582d8a44fd706dea2b6c2b7bcdb931a
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1332691
milestone54.0a1
Bug 1332691: Allow including files with a jit-test directive; r=sfink MozReview-Commit-ID: 8lCFJuEXOaW
js/src/jit-test/tests/wasm/backtrace.js
js/src/jit-test/tests/wasm/baseline-abs-addr-opt.js
js/src/jit-test/tests/wasm/baseline-opt.js
js/src/jit-test/tests/wasm/basic.js
js/src/jit-test/tests/wasm/bce.js
js/src/jit-test/tests/wasm/big-resize.js
js/src/jit-test/tests/wasm/binary.js
js/src/jit-test/tests/wasm/comments.js
js/src/jit-test/tests/wasm/compiler-frame-depth.js
js/src/jit-test/tests/wasm/const.js
js/src/jit-test/tests/wasm/control-flow.js
js/src/jit-test/tests/wasm/conversion.js
js/src/jit-test/tests/wasm/cross-global.js
js/src/jit-test/tests/wasm/directives.txt
js/src/jit-test/tests/wasm/drop.js
js/src/jit-test/tests/wasm/errors.js
js/src/jit-test/tests/wasm/extract-code.js
js/src/jit-test/tests/wasm/fac.js
js/src/jit-test/tests/wasm/float.js
js/src/jit-test/tests/wasm/full-cycle.js
js/src/jit-test/tests/wasm/globals.js
js/src/jit-test/tests/wasm/grow-memory.js
js/src/jit-test/tests/wasm/import-export.js
js/src/jit-test/tests/wasm/import-gc.js
js/src/jit-test/tests/wasm/integer.js
js/src/jit-test/tests/wasm/js-reexport.js
js/src/jit-test/tests/wasm/jsapi.js
js/src/jit-test/tests/wasm/memory-aliasing.js
js/src/jit-test/tests/wasm/memory.js
js/src/jit-test/tests/wasm/nan-semantics.js
js/src/jit-test/tests/wasm/profiling.js
js/src/jit-test/tests/wasm/regress/baseline-bytereg.js
js/src/jit-test/tests/wasm/regress/baseline-joinreg.js
js/src/jit-test/tests/wasm/regress/baseline-pop-along-edge.js
js/src/jit-test/tests/wasm/regress/baseline-pop-before-capture.js
js/src/jit-test/tests/wasm/regress/brtable-conditionblock-folding.js
js/src/jit-test/tests/wasm/regress/bug1300546.js
js/src/jit-test/tests/wasm/regress/bug1311019.js
js/src/jit-test/tests/wasm/regress/current-memory-tls.js
js/src/jit-test/tests/wasm/regress/directives.txt
js/src/jit-test/tests/wasm/regress/gvn-unremovable-phi.js
js/src/jit-test/tests/wasm/regress/long-select.js
js/src/jit-test/tests/wasm/regress/misc-control-flow.js
js/src/jit-test/tests/wasm/regress/movable-traps.js
js/src/jit-test/tests/wasm/regress/pass-stack-int64.js
js/src/jit-test/tests/wasm/regress/regalloc-i64-load-store-global.js
js/src/jit-test/tests/wasm/regress/regalloc-muli64.js
js/src/jit-test/tests/wasm/regress/reserve-enough.js
js/src/jit-test/tests/wasm/regress/reserve-joinreg.js
js/src/jit-test/tests/wasm/regress/select-any.js
js/src/jit-test/tests/wasm/regress/shift-counts.js
js/src/jit-test/tests/wasm/regress/teavm-bugs.js
js/src/jit-test/tests/wasm/regress/too-large-frame.js
js/src/jit-test/tests/wasm/resizing.js
js/src/jit-test/tests/wasm/stack.js
js/src/jit-test/tests/wasm/start.js
js/src/jit-test/tests/wasm/stealing.js
js/src/jit-test/tests/wasm/table-gc.js
js/src/jit-test/tests/wasm/table-pre-barrier.js
js/src/jit-test/tests/wasm/tables.js
js/src/jit-test/tests/wasm/text.js
js/src/jit-test/tests/wasm/to-text-experimental.js
js/src/jit-test/tests/wasm/to-text.js
js/src/jit-test/tests/wasm/validate.js
js/src/jit-test/tests/wasm/wasm-abi.js
js/src/tests/lib/jittests.py
--- a/js/src/jit-test/tests/wasm/backtrace.js
+++ b/js/src/jit-test/tests/wasm/backtrace.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 var code = `(module
   (import $i "env" "test")
   (func $t (call $i))
   (export "test" $t)
 )`;
 var mod = wasmEvalText(code, {
   env: {
     test: function() {
--- a/js/src/jit-test/tests/wasm/baseline-abs-addr-opt.js
+++ b/js/src/jit-test/tests/wasm/baseline-abs-addr-opt.js
@@ -2,18 +2,16 @@
 // This is intended to verify a bounds check elimination optimization in
 // the baseline compiler.
 
 // This can be only a functional test, we can't really see whether
 // the optimization is being applied.  However, manual inspection
 // of the generated code has verified that the optimization is
 // being applied.
 
-load(libdir + "wasm.js");
-
 // Memory is one page and minimum memory is one page, so accesses across
 // the end of the first page should fail.
 
 function gen(base, offset) {
   return wasmEvalText(`(module
 			(memory 1)
 			(data (i32.const 65528) "aaaaaaaa")
 			(func (result i32)
--- a/js/src/jit-test/tests/wasm/baseline-opt.js
+++ b/js/src/jit-test/tests/wasm/baseline-opt.js
@@ -1,12 +1,10 @@
 // Point-testing various optimizations in the wasm baseline compiler.
 
-load(libdir + "wasm.js");
-
 // Boolean optimization for control (bug 1286816).
 //
 // These optimizations combine a test (a comparison or Eqz) with an
 // immediately following conditional branch (BrIf, If, and Select), to
 // avoid generating a boolean value that is then tested with a
 // compare-to-zero.
 //
 // On AngryBots as of November 2016, 84% of all test instructions
--- a/js/src/jit-test/tests/wasm/basic.js
+++ b/js/src/jit-test/tests/wasm/basic.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 const LinkError = WebAssembly.LinkError;
 
 // ----------------------------------------------------------------------------
 // exports
 
 var o = wasmEvalText('(module)').exports;
 assertEq(Object.getOwnPropertyNames(o).length, 0);
 
--- a/js/src/jit-test/tests/wasm/bce.js
+++ b/js/src/jit-test/tests/wasm/bce.js
@@ -1,10 +1,9 @@
 // |jit-test| test-also-wasm-check-bce
-load(libdir + "wasm.js");
 
 mem='\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'+
     '\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff'+
     '\x00'.repeat(65488) +
     '\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff'
 
 let accessWidth = {
   '8_s':  1,
--- a/js/src/jit-test/tests/wasm/big-resize.js
+++ b/js/src/jit-test/tests/wasm/big-resize.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 wasmFullPass(`(module
     (memory 1 32768)
     (func $test (result i32)
         (if (i32.eq (grow_memory (i32.const 16384)) (i32.const -1)) (return (i32.const 42)))
         (i32.store (i32.const 1073807356) (i32.const 42))
         (i32.load (i32.const 1073807356)))
     (export "run" $test)
 )`, 42);
--- a/js/src/jit-test/tests/wasm/binary.js
+++ b/js/src/jit-test/tests/wasm/binary.js
@@ -1,9 +1,8 @@
-load(libdir + "wasm.js");
 load(libdir + "wasm-binary.js");
 
 const Module = WebAssembly.Module;
 const CompileError = WebAssembly.CompileError;
 
 const magicError = /failed to match magic number/;
 const unknownSection = /expected custom section/;
 
--- a/js/src/jit-test/tests/wasm/comments.js
+++ b/js/src/jit-test/tests/wasm/comments.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // sanity check
 assertErrorMessage(() => wasmEvalText(''), SyntaxError, /parsing wasm text/);
 
 // single line comment
 var o = wasmEvalText('(module (func)) ;; end');
 var o = wasmEvalText('(module (func)) ;; end\n');
 var o = wasmEvalText('(module (func))\n;; end');
 var o = wasmEvalText('(module (func))\n;; end');
--- a/js/src/jit-test/tests/wasm/compiler-frame-depth.js
+++ b/js/src/jit-test/tests/wasm/compiler-frame-depth.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // Ensures that the postorder allows us to have very deep expression trees.
 
 var expr = '(get_local 0)';
 
 for (var i = 1000; i --> 0; ) {
     expr = `(f32.neg ${expr})`;
 }
 
--- a/js/src/jit-test/tests/wasm/const.js
+++ b/js/src/jit-test/tests/wasm/const.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 function testConst(type, str, expect) {
     if (type === 'i64')
         wasmFullPassI64(`(module (func (result i64) (i64.const ${str})) (export "run" 0))`, expect);
     else
         wasmFullPass(`(module (func (result ${type}) (${type}.const ${str})) (export "run" 0))`, expect);
 }
 
 function testConstError(type, str) {
--- a/js/src/jit-test/tests/wasm/control-flow.js
+++ b/js/src/jit-test/tests/wasm/control-flow.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 const RuntimeError = WebAssembly.RuntimeError;
 
 // ----------------------------------------------------------------------------
 // if
 
 // Condition is an int32
 wasmFailValidateText('(module (func (local f32) (if (get_local 0) (i32.const 1))))', mismatchError("f32", "i32"));
 wasmFailValidateText('(module (func (local f32) (if (get_local 0) (i32.const 1) (i32.const 0))))', mismatchError("f32", "i32"));
--- a/js/src/jit-test/tests/wasm/conversion.js
+++ b/js/src/jit-test/tests/wasm/conversion.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 function testConversion(resultType, opcode, paramType, op, expect) {
   if (paramType === 'i64') {
     // i64 cannot be imported, so we use a wrapper function.
     wasmFullPass(`(module
                     (func (param i64) (result ${resultType}) (${resultType}.${opcode}/i64 (get_local 0)))
                     (export "run" 0))`, expect, {}, createI64(op));
     // The same, but now the input is a constant.
     wasmFullPass(`(module
--- a/js/src/jit-test/tests/wasm/cross-global.js
+++ b/js/src/jit-test/tests/wasm/cross-global.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 const Module = WebAssembly.Module;
 
 // Create cross-compartment wrappers to typed arrays and array buffers.
 var g = newGlobal();
 var code1 = g.eval("wasmTextToBinary('(module)')");
 var code2 = g.eval("wasmTextToBinary('(module)').buffer");
 
 // Should get unwrapped.
--- a/js/src/jit-test/tests/wasm/directives.txt
+++ b/js/src/jit-test/tests/wasm/directives.txt
@@ -1,1 +1,1 @@
-|jit-test| test-also-wasm-baseline
+|jit-test| test-also-wasm-baseline; include:wasm.js
--- a/js/src/jit-test/tests/wasm/drop.js
+++ b/js/src/jit-test/tests/wasm/drop.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 for (let type of ['i32', 'f32', 'f64']) {
     assertEq(wasmEvalText(`
         (module
          (func $test (result ${type}) (param $p ${type}) (param $p2 ${type})
             get_local $p
             get_local $p2
             (block)
             drop
--- a/js/src/jit-test/tests/wasm/errors.js
+++ b/js/src/jit-test/tests/wasm/errors.js
@@ -1,9 +1,8 @@
-load(libdir + "wasm.js");
 load(libdir + "wasm-binary.js");
 
 const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 const CompileError = WebAssembly.CompileError;
 const RuntimeError = WebAssembly.RuntimeError;
 
 function isWasmFunction(name) {
--- a/js/src/jit-test/tests/wasm/extract-code.js
+++ b/js/src/jit-test/tests/wasm/extract-code.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 var module = new WebAssembly.Module(wasmTextToBinary(`(module (func (nop)))`));
 var exp = wasmExtractCode(module);
 assertEq(exp.code instanceof Uint8Array, true);
 assertEq(Array.isArray(exp.segments), true);
 var funcs = exp.segments.filter(s => s.kind === 0);
 assertEq(funcs.length, 1);
 assertEq(funcs[0].funcIndex, 0);
 assertEq(funcs[0].begin >= 0, true);
--- a/js/src/jit-test/tests/wasm/fac.js
+++ b/js/src/jit-test/tests/wasm/fac.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // This is fac-opt from fac.wast in the official testsuite, changed to use
 // i32 instead of i64.
 assertEq(wasmEvalText(`(module
   (func $fac-opt (param i32) (result i32)
     (local i32)
     (set_local 1 (i32.const 1))
     (block
       (br_if 0 (i32.lt_s (get_local 0) (i32.const 2)))
--- a/js/src/jit-test/tests/wasm/float.js
+++ b/js/src/jit-test/tests/wasm/float.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 wasmFullPass('(module (func (result f32) (f32.const -1)) (export "run" 0))', -1);
 wasmFullPass('(module (func (result f32) (f32.const 1)) (export "run" 0))', 1);
 wasmFullPass('(module (func (result f64) (f64.const -2)) (export "run" 0))', -2);
 wasmFullPass('(module (func (result f64) (f64.const 2)) (export "run" 0))', 2);
 wasmFullPass('(module (func (result f64) (f64.const 4294967296)) (export "run" 0))', 4294967296);
 wasmFullPass('(module (func (result f32) (f32.const 1.5)) (export "run" 0))', 1.5);
 wasmFullPass('(module (func (result f64) (f64.const 2.5)) (export "run" 0))', 2.5);
 wasmFullPass('(module (func (result f64) (f64.const 10e2)) (export "run" 0))', 10e2);
--- a/js/src/jit-test/tests/wasm/full-cycle.js
+++ b/js/src/jit-test/tests/wasm/full-cycle.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 wasmFullPass(`(module
     (func $test (result i32) (param i32) (param i32) (i32.add (get_local 0) (get_local 1)))
     (func $run (result i32) (call $test (i32.const 1) (i32.const ${Math.pow(2, 31) - 1})))
     (export "run" $run)
 )`, -Math.pow(2, 31));
 
 wasmFullPass(`(module
     (func (result i32)
--- a/js/src/jit-test/tests/wasm/globals.js
+++ b/js/src/jit-test/tests/wasm/globals.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 const { Instance, Module } = WebAssembly;
 
 // Locally-defined globals
 assertErrorMessage(() => wasmEvalText(`(module (global))`), SyntaxError, /parsing/);
 assertErrorMessage(() => wasmEvalText(`(module (global i32))`), SyntaxError, /parsing/);
 assertErrorMessage(() => wasmEvalText(`(module (global (mut i32)))`), SyntaxError, /parsing/);
 
 // Initializer expressions.
--- a/js/src/jit-test/tests/wasm/grow-memory.js
+++ b/js/src/jit-test/tests/wasm/grow-memory.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 function linearModule(min, max, ops) {
   var opsText = ops.map(function (op) {
     if (op[0] == "CM") {
       res = `(if i32 (i32.ne (current_memory) (i32.const ${op[1]}))
                   (i32.load offset=10 (i32.const 4294967295))
                   (i32.const 0))`
     } else if (op[0] == "GM") {
       res = `(if i32 (i32.ne (grow_memory (i32.const ${op[1]})) (i32.const ${op[2]}))
--- a/js/src/jit-test/tests/wasm/import-export.js
+++ b/js/src/jit-test/tests/wasm/import-export.js
@@ -1,10 +1,8 @@
-load(libdir + 'wasm.js');
-
 const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 const Memory = WebAssembly.Memory;
 const Table = WebAssembly.Table;
 const LinkError = WebAssembly.LinkError;
 
 const mem1Page = new Memory({initial:1});
 const mem1PageMax1 = new Memory({initial:1, maximum: 1});
--- a/js/src/jit-test/tests/wasm/import-gc.js
+++ b/js/src/jit-test/tests/wasm/import-gc.js
@@ -1,14 +1,12 @@
 // |jit-test| --no-baseline
 // Turn off baseline and since it messes up the GC finalization assertions by
 // adding spurious edges to the GC graph.
 
-load(libdir + 'wasm.js');
-
 const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 
 const m1 = new Module(wasmTextToBinary(`(module (func $f) (export "f" $f))`));
 const m2 = new Module(wasmTextToBinary(`(module (import "a" "f") (func $f) (export "g" $f))`));
 
 // Imported instance objects should stay alive as long as any importer is alive.
 resetFinalizeCount();
--- a/js/src/jit-test/tests/wasm/integer.js
+++ b/js/src/jit-test/tests/wasm/integer.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 assertEq(wasmEvalText('(module (func (result i32) (i32.const -1)) (export "" 0))').exports[""](), -1);
 assertEq(wasmEvalText('(module (func (result i32) (i32.const -2147483648)) (export "" 0))').exports[""](), -2147483648);
 assertEq(wasmEvalText('(module (func (result i32) (i32.const 4294967295)) (export "" 0))').exports[""](), -1);
 
 function testUnary(type, opcode, op, expect) {
     var fullPass = wasmFullPass;
     if (type === 'i64') {
         expect = createI64(expect);
--- a/js/src/jit-test/tests/wasm/js-reexport.js
+++ b/js/src/jit-test/tests/wasm/js-reexport.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 const Memory = WebAssembly.Memory;
 const Table = WebAssembly.Table;
 
 function accum(...args) {
     var sum = 0;
     for (var i = 0; i < args.length; i++)
--- a/js/src/jit-test/tests/wasm/jsapi.js
+++ b/js/src/jit-test/tests/wasm/jsapi.js
@@ -1,10 +1,8 @@
-load(libdir + 'wasm.js');
-
 const WasmPage = 64 * 1024;
 
 const emptyModuleBinary = wasmTextToBinary('(module)');
 const exportingModuleBinary = wasmTextToBinary('(module (func (export "f") (result i32) (i32.const 42)))');
 const importingModuleBinary = wasmTextToBinary('(module (func (import "" "f")))');
 
 // 'WebAssembly' data property on global object
 const wasmDesc = Object.getOwnPropertyDescriptor(this, 'WebAssembly');
--- a/js/src/jit-test/tests/wasm/memory-aliasing.js
+++ b/js/src/jit-test/tests/wasm/memory-aliasing.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 var i = wasmEvalText(
 `(module
    (memory 1) (data (i32.const 0) "\\01\\02\\03\\04\\05\\06\\07\\08")
    (func $off1 (param $base i32) (result i32)
      (i32.add
        (i32.load8_u (get_local $base))
        (i32.load8_u offset=1 (get_local $base)))
    )
--- a/js/src/jit-test/tests/wasm/memory.js
+++ b/js/src/jit-test/tests/wasm/memory.js
@@ -1,10 +1,9 @@
 // |jit-test| test-also-wasm-check-bce
-load(libdir + "wasm.js");
 
 const RuntimeError = WebAssembly.RuntimeError;
 
 function loadModule(type, ext, offset, align) {
     return wasmEvalText(
     `(module
        (memory 1)
        (data (i32.const 0) "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f")
--- a/js/src/jit-test/tests/wasm/nan-semantics.js
+++ b/js/src/jit-test/tests/wasm/nan-semantics.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 var f64 = new Float64Array(2);
 var f32 = new Float32Array(f64.buffer);
 var u8 = new Uint8Array(f64.buffer);
 
 function assertSameBitPattern(from, to, offset) {
     for (let i = from; i < to; i++)
         assertEq(u8[i], u8[i + offset], 'non equality in assertSameBitPattern');
 }
--- a/js/src/jit-test/tests/wasm/profiling.js
+++ b/js/src/jit-test/tests/wasm/profiling.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // Single-step profiling currently only works in the ARM simulator
 if (!getBuildConfiguration()["arm-simulator"])
     quit();
 
 const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 const Table = WebAssembly.Table;
 
--- a/js/src/jit-test/tests/wasm/regress/baseline-bytereg.js
+++ b/js/src/jit-test/tests/wasm/regress/baseline-bytereg.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // Bug 1322450 is about the baseline compiler not properly handling a byte store
 // from a wider datum on 32-bit x86 because it does not move the value to be
 // stored to a valid byte register if it is in a 32-bit register that does not
 // have a byte part (EDI/ESI/EBP).
 //
 // This test is white-box because it knows about the register allocation order:
 // the two values pushed onto the stack occupy EAX and ECX, and the i64.store8
 // will use EDX for the index and (EDI or ESI or EBP) for the low register of
--- a/js/src/jit-test/tests/wasm/regress/baseline-joinreg.js
+++ b/js/src/jit-test/tests/wasm/regress/baseline-joinreg.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // Bug 1322288 is about the floating join register not being reserved properly
 // in the presence of boolean evaluation for control.  The situation is that a
 // conditional branch passes a floating point value to the join point; the join register
 // must be available when it does that, but could have been allocated to the operands of
 // the conditional expression of the control flow.
 //
 // This test is white-box: it depends on the floating join reg being among the first
 // floating registers to be allocated.
--- a/js/src/jit-test/tests/wasm/regress/baseline-pop-along-edge.js
+++ b/js/src/jit-test/tests/wasm/regress/baseline-pop-along-edge.js
@@ -1,12 +1,10 @@
 // Bug 1316181
 
-load(libdir + "wasm.js");
-
 // There are locals with different values here to ensure that the
 // get_local at the end picks up the right one even if the stack might
 // have become unbalanced by a failure to adjust SP along the branch
 // edge.  The logic is that we use SP-relative addressing, and if the
 // actual SP is not what the compiler thinks it is we will read
 // something other than the expected value.
 
 var o = wasmEvalText(
--- a/js/src/jit-test/tests/wasm/regress/baseline-pop-before-capture.js
+++ b/js/src/jit-test/tests/wasm/regress/baseline-pop-before-capture.js
@@ -1,12 +1,10 @@
 // Bug 1319415
 
-load(libdir + "wasm.js");
-
 var src =
 `(module
   (func (result i32)
     i32.const 0
     i32.const 1
     br_if 0
     unreachable)
   (export "run" 0))`;
--- a/js/src/jit-test/tests/wasm/regress/brtable-conditionblock-folding.js
+++ b/js/src/jit-test/tests/wasm/regress/brtable-conditionblock-folding.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 assertEq(wasmEvalText(`
 (module
   (func $f (param $p i32)
     block $out
       i32.const 0
       if
         i32.const 1
         tee_local $p
--- a/js/src/jit-test/tests/wasm/regress/bug1300546.js
+++ b/js/src/jit-test/tests/wasm/regress/bug1300546.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 setJitCompilerOption('wasm.test-mode', 1);
 
 try {
     wasmEvalText(`
 
     (module
       (type $type0 (func))
       (func $func0
--- a/js/src/jit-test/tests/wasm/regress/bug1311019.js
+++ b/js/src/jit-test/tests/wasm/regress/bug1311019.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 new WebAssembly.Module(wasmTextToBinary(`(module
     (memory 1)
     (func
         (i64.trunc_s/f32 (f32.const 6.96875))
         (i32.load8_s (i32.const 0))
         (f32.const -7.66028056e-31)
         (unreachable)
     )
--- a/js/src/jit-test/tests/wasm/regress/current-memory-tls.js
+++ b/js/src/jit-test/tests/wasm/regress/current-memory-tls.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // Bug 1341650:
 // - when compiled with Ion, pass the TLS register to current_memory;
 // - when compiled with Baseline, don't clobber the last stack slot when
 // calling into current_memory/grow_memory;
 
 // This toy module starts with an empty memory, then tries to set values at different
 // indexes, automatically growing memory when that would trigger an out of
 // bounds access, for the exact right amount of pages. Note it's not made for
--- a/js/src/jit-test/tests/wasm/regress/directives.txt
+++ b/js/src/jit-test/tests/wasm/regress/directives.txt
@@ -1,1 +1,1 @@
-|jit-test| test-also-wasm-baseline
+|jit-test| test-also-wasm-baseline; include:wasm.js
--- a/js/src/jit-test/tests/wasm/regress/gvn-unremovable-phi.js
+++ b/js/src/jit-test/tests/wasm/regress/gvn-unremovable-phi.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 wasmEvalText(`(module
   (type $type0 (func (param i32)))
   (func $f (param $p i32)
     (local $x i32) (local $y i32)
     loop $top
       get_local $x
       get_local $p
       get_local $x
--- a/js/src/jit-test/tests/wasm/regress/long-select.js
+++ b/js/src/jit-test/tests/wasm/regress/long-select.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // Bug 1337060 causes too much register pressure on x86 by requiring four int64
 // values in registers at the same time.
 
 setJitCompilerOption('wasm.test-mode', 1);
 
 wasmFullPassI64(`
 (module
   (func (result i64)
--- a/js/src/jit-test/tests/wasm/regress/misc-control-flow.js
+++ b/js/src/jit-test/tests/wasm/regress/misc-control-flow.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 wasmFailValidateText(`(module
    (func (result i32) (param i32)
      (loop (if (i32.const 0) (br 0)) (get_local 0)))
    (export "" 0)
 )`, /unused values not explicitly dropped by end of block/);
 
 wasmFailValidateText(`(module
    (func (param i32)
--- a/js/src/jit-test/tests/wasm/regress/movable-traps.js
+++ b/js/src/jit-test/tests/wasm/regress/movable-traps.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 let bodies = [
     `
     i32.const 1
     i32.const 0
     i32.div_s
     `,
     `
     i32.const 1
--- a/js/src/jit-test/tests/wasm/regress/pass-stack-int64.js
+++ b/js/src/jit-test/tests/wasm/regress/pass-stack-int64.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 var params = '';
 var locals = '';
 for (let i = 0; i < 20; i++) {
     params += '(param i64) ';
     locals += `(get_local ${i}) `;
 }
 
 wasmEvalText(`
--- a/js/src/jit-test/tests/wasm/regress/regalloc-i64-load-store-global.js
+++ b/js/src/jit-test/tests/wasm/regress/regalloc-i64-load-store-global.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 setJitCompilerOption('wasm.test-mode', 1);
 
 wasmFullPassI64(`
     (module
         (global (mut i64) (i64.const 9970292656026947164))
         (func (export "get_global_0") (result i64) get_global 0)
 
         (func (export "run") (result i64) (param i32)
--- a/js/src/jit-test/tests/wasm/regress/regalloc-muli64.js
+++ b/js/src/jit-test/tests/wasm/regress/regalloc-muli64.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // Bug 1298808.
 assertEq(wasmEvalText(`(module
     (func
         (result i32)
         (i32.wrap/i64
             (i64.mul
                 ;; Conditions: rhs == lhs, rhs is not a constant.
                 (i64.add (i64.const 1) (i64.const 10))
--- a/js/src/jit-test/tests/wasm/regress/reserve-enough.js
+++ b/js/src/jit-test/tests/wasm/regress/reserve-enough.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // Bug 1281131 - be sure to reserve enough stack space
 
 wasmEvalText(
 `(module
   (func $func0
    ${loopy(100)}
    (nop)))`);
 
--- a/js/src/jit-test/tests/wasm/regress/reserve-joinreg.js
+++ b/js/src/jit-test/tests/wasm/regress/reserve-joinreg.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // Bug 1280933, excerpted from binary test case provided there.
 
 wasmEvalText(
 `(module
   (func $func0 (param $arg0 i32) (result i32) (local $var0 i64)
 	(set_local $var0 (i64.extend_u/i32 (get_local $arg0)))
 	(i32.wrap/i64
 	 (i64.add
--- a/js/src/jit-test/tests/wasm/regress/select-any.js
+++ b/js/src/jit-test/tests/wasm/regress/select-any.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // Bug 1280921
 
 var m1 = wasmEvalText(
 `(module
   (type $type0 (func))
   (func $func0
    (select
      (unreachable)
--- a/js/src/jit-test/tests/wasm/regress/shift-counts.js
+++ b/js/src/jit-test/tests/wasm/regress/shift-counts.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // Bug 1280926, extracted from binary
 
 wasmEvalText(
 `(module
   (type $type0 (func (result i32)))
   (export "" $func0)
   (func $func0 (result i32)
    (i32.shr_s (i32.const -40) (i32.const 34))))`);
--- a/js/src/jit-test/tests/wasm/regress/teavm-bugs.js
+++ b/js/src/jit-test/tests/wasm/regress/teavm-bugs.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // Register allocation issue with LCompareI64AndBranch.
 let params = '';
 let locals = '';
 let tests = '(i64.const 0)';
 
 for (let i = 15; i --> 0;) {
     params += `\n(param i64)`;
     locals += `\n(local i64)`;
--- a/js/src/jit-test/tests/wasm/regress/too-large-frame.js
+++ b/js/src/jit-test/tests/wasm/regress/too-large-frame.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // Bug 1280934, equivalent test case.
 
 try {
 
 wasmEvalText(
 `(module
   (func $func0 (result i32) ${locals()}
    (i32.const 0))
--- a/js/src/jit-test/tests/wasm/resizing.js
+++ b/js/src/jit-test/tests/wasm/resizing.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 const Table = WebAssembly.Table;
 const Memory = WebAssembly.Memory;
 const RuntimeError = WebAssembly.RuntimeError;
 
 // ======
 // MEMORY
--- a/js/src/jit-test/tests/wasm/stack.js
+++ b/js/src/jit-test/tests/wasm/stack.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 // Test instructions with no return value interposed between pushes and pops.
 wasmFullPass(` (module
    (memory 1)
 
    (func (result i32)
      (local $local f64)
      i32.const 0
      i32.const 16
--- a/js/src/jit-test/tests/wasm/start.js
+++ b/js/src/jit-test/tests/wasm/start.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 assertErrorMessage(() => wasmEvalText('(module (func) (start 0) (start 0))'), SyntaxError, /wasm text error/);
 assertErrorMessage(() => wasmEvalText('(module (func) (start $unknown))'), SyntaxError, /label.*not found/);
 
 wasmFailValidateText('(module (func) (start 1))', /unknown start function/);
 wasmFailValidateText('(module (func (param i32)) (start 0))', /must be nullary/);
 wasmFailValidateText('(module (func (param i32) (param f32)) (start 0))', /must be nullary/);
 wasmFailValidateText('(module (func (param i32) (param f32) (param f64)) (start 0))', /must be nullary/);
 wasmFailValidateText('(module (func (result f32)) (start 0))', /must not return anything/);
--- a/js/src/jit-test/tests/wasm/stealing.js
+++ b/js/src/jit-test/tests/wasm/stealing.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 var exp = wasmEvalText(`(module
     (memory 1)
     (export "mem" memory)
     (func $f (result i32) (i32.load (i32.const 0)))
     (export "f" $f)
 )`).exports;
 
 var ab = exp.mem.buffer;
--- a/js/src/jit-test/tests/wasm/table-gc.js
+++ b/js/src/jit-test/tests/wasm/table-gc.js
@@ -1,14 +1,12 @@
 // |jit-test| --no-baseline
 // Turn off baseline and since it messes up the GC finalization assertions by
 // adding spurious edges to the GC graph.
 
-load(libdir + 'wasm.js');
-
 const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 const Table = WebAssembly.Table;
 const RuntimeError = WebAssembly.RuntimeError;
 
 var caller = `(type $v2i (func (result i32))) (func $call (param $i i32) (result i32) (call_indirect $v2i (get_local $i))) (export "call" $call)`
 var callee = i => `(func $f${i} (type $v2i) (i32.const ${i}))`;
 
--- a/js/src/jit-test/tests/wasm/table-pre-barrier.js
+++ b/js/src/jit-test/tests/wasm/table-pre-barrier.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 const Table = WebAssembly.Table;
 
 var i42 = new Instance(new Module(wasmTextToBinary(`(module (func (result i32) (i32.const 42)) (export "f" 0))`)));
 var i13 = new Instance(new Module(wasmTextToBinary(`(module (func (result i32) (i32.const 13)) (export "f" 0))`)));
 var t = new Table({element:"anyfunc", initial:1});
 t.set(0, i42.exports.f);
--- a/js/src/jit-test/tests/wasm/tables.js
+++ b/js/src/jit-test/tests/wasm/tables.js
@@ -1,10 +1,8 @@
-load(libdir + 'wasm.js');
-
 const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 const Table = WebAssembly.Table;
 const Memory = WebAssembly.Memory;
 const LinkError = WebAssembly.LinkError;
 const RuntimeError = WebAssembly.RuntimeError;
 
 var callee = i => `(func $f${i} (result i32) (i32.const ${i}))`;
--- a/js/src/jit-test/tests/wasm/text.js
+++ b/js/src/jit-test/tests/wasm/text.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 var parsingError = /parsing wasm text at/;
 
 assertErrorMessage(() => wasmEvalText(''), SyntaxError, parsingError);
 assertErrorMessage(() => wasmEvalText('('), SyntaxError, parsingError);
 assertErrorMessage(() => wasmEvalText('(m'), SyntaxError, parsingError);
 assertErrorMessage(() => wasmEvalText('(module'), SyntaxError, parsingError);
 assertErrorMessage(() => wasmEvalText('(moduler'), SyntaxError, parsingError);
 assertErrorMessage(() => wasmEvalText('(module (func) (export "a'), SyntaxError, parsingError);
--- a/js/src/jit-test/tests/wasm/to-text-experimental.js
+++ b/js/src/jit-test/tests/wasm/to-text-experimental.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 assertErrorMessage(() => wasmBinaryToText(wasmTextToBinary(`(module (func (result i32) (f32.const 13.37)))`), 'experimental'), WebAssembly.CompileError, /type mismatch/);
 
 function runTest(code, expected) {
   var binary = wasmTextToBinary(code);
   var s = wasmBinaryToText(binary, "experimental");
   s = s.replace(/\s+/g, ' ');
   print("TEXT: " + s);
   assertEq(s, expected);
--- a/js/src/jit-test/tests/wasm/to-text.js
+++ b/js/src/jit-test/tests/wasm/to-text.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 var caught = false;
 try {
     wasmBinaryToText(new Int8Array(1));
 } catch (e) {
     caught = true;
 }
 assertEq(caught, true);
 
--- a/js/src/jit-test/tests/wasm/validate.js
+++ b/js/src/jit-test/tests/wasm/validate.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 const { validate } = WebAssembly;
 
 assertErrorMessage(() => validate(), Error, /requires more than 0 arguments/);
 
 const argError = /first argument must be an ArrayBuffer or typed array object/;
 assertErrorMessage(() => validate(null), Error, argError);
 assertErrorMessage(() => validate(true), Error, argError);
 assertErrorMessage(() => validate(42), Error, argError);
--- a/js/src/jit-test/tests/wasm/wasm-abi.js
+++ b/js/src/jit-test/tests/wasm/wasm-abi.js
@@ -1,10 +1,8 @@
-load(libdir + "wasm.js");
-
 for (let numLocals of [3, 4, 5, 6, 17, 18, 19]) {
     for (let numParams of [1, 2, 3, 4, 5, 6, 7, 8]) {
         let locals = `       (local `;
         let setLocals = ``;
         let getLocals = ``;
         let adds = ``;
         let sum = 0;
         for (let i = 0; i < numLocals; i++) {
--- a/js/src/tests/lib/jittests.py
+++ b/js/src/tests/lib/jittests.py
@@ -111,16 +111,17 @@ class JitTest:
         self.allow_overrecursed = False # True means that hitting recursion the
                                         # limits is not considered a failure.
         self.valgrind = False  # True means run under valgrind
         self.tz_pacific = False # True means force Pacific time for the test
         self.test_also_noasmjs = False # True means run with and without asm.js
                                        # enabled.
         self.test_also_wasm_baseline = False # True means run with and and without
                                        # wasm baseline compiler enabled.
+        self.other_includes = [] # Additional files to include, in addition to prologue.js
         self.test_also = [] # List of other configurations to test with.
         self.test_join = [] # List of other configurations to test with all existing variants.
         self.expect_error = '' # Errors to expect and consider passing
         self.expect_status = 0 # Exit status to expect from shell
         self.expect_crash = False # Exit status or error output.
         self.is_module = False
         self.need_for_each = False # Enable for-each syntax
         self.test_reflect_stringify = None  # Reflect.stringify implementation to test
@@ -134,16 +135,17 @@ class JitTest:
         t.slow = self.slow
         t.allow_oom = self.allow_oom
         t.allow_unhandlable_oom = self.allow_unhandlable_oom
         t.allow_overrecursed = self.allow_overrecursed
         t.valgrind = self.valgrind
         t.tz_pacific = self.tz_pacific
         t.test_also_noasmjs = self.test_also_noasmjs
         t.test_also_wasm_baseline = self.test_also_wasm_baseline
+        t.other_includes = self.other_includes[:]
         t.test_also = self.test_also
         t.test_join = self.test_join
         t.expect_error = self.expect_error
         t.expect_status = self.expect_status
         t.expect_crash = self.expect_crash
         t.test_reflect_stringify = self.test_reflect_stringify
         t.enable = True
         t.is_module = self.is_module
@@ -223,16 +225,18 @@ class JitTest:
                                   " {}".format(value))
                     elif name == 'thread-count':
                         try:
                             test.jitflags.append('--thread-count={}'.format(
                                 int(value, 0)))
                         except ValueError:
                             print("warning: couldn't parse thread-count"
                                   " {}".format(value))
+                    elif name == 'include':
+                        test.other_includes.append(value)
                     else:
                         print('{}: warning: unrecognized |jit-test| attribute'
                               ' {}'.format(path, part))
                 else:
                     if name == 'slow':
                         test.slow = True
                     elif name == 'allow-oom':
                         test.allow_oom = True
@@ -303,23 +307,26 @@ class JitTest:
 
         if self.need_for_each:
             expr += "; enableForEach()"
 
         # We may have specified '-a' or '-d' twice: once via --jitflags, once
         # via the "|jit-test|" line.  Remove dups because they are toggles.
         cmd = prefix + ['--js-cache', JitTest.CacheDir]
         cmd += list(set(self.jitflags)) + ['-e', expr]
+        for inc in self.other_includes:
+            cmd += ['-f', libdir + inc]
         if self.is_module:
             cmd += ['--module-load-path', moduledir]
             cmd += ['--module', path]
         elif self.test_reflect_stringify is None:
             cmd += ['-f', path]
         else:
             cmd += ['--', self.test_reflect_stringify, "--check", path]
+
         if self.valgrind:
             cmd = self.VALGRIND_CMD + cmd
         return cmd
 
     # The test runner expects this to be set to give to get_command.
     js_cmd_prefix = None
     def get_command(self, prefix):
         """Shim for the test runner."""