summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/spectre-mask.js
blob: 76e91d778e1460a44a457459f0355d47b02085eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// |jit-test| skip-if: !hasDisassembler() || !(wasmCompileMode() == "baseline" || wasmCompileMode() == "ion") || !(getBuildConfiguration().x64 && !getBuildConfiguration()["arm64-simulator"] && !getBuildConfiguration()["mips64-simulator"])

// What we can't test here is the direct-call-from-JIT path, as the generated
// code is not available to wasmDis.

var ins = wasmEvalText(`
(module
  (import "" "wasm2import" (func $g (result i32)))
  (memory 1)
  (type $ty (func (result i32)))
  (table $t 1 1 funcref)
  (func $f (result i32)
    (i32.const 37))
  (func (export "wasm2wasm") (result i32)
    (call $f))
  (func (export "wasm2import") (result i32)
    (call $g))
  (func (export "wasmIndirect") (result i32)
    (call_indirect (type $ty) $t (i32.const 0)))
  (func (export "instanceCall") (result i32)
    (memory.size))
)`, {'':{'wasm2import': function() {}}});

switch (wasmCompileMode()) {
case "ion":
    assertEq(wasmDis(ins.exports.wasm2wasm, 'stable', true).match(/call.*\n.*mov %eax, %eax/).length, 1);
    assertEq(wasmDis(ins.exports.wasm2import, 'stable', true).match(/call.*\n(?:.*movq.*\n)*.*mov %eax, %eax/).length, 1);
    assertEq(wasmDis(ins.exports.wasmIndirect, 'stable', true).match(/call.*\n(?:.*movq.*\n)*.*mov %eax, %eax/).length, 1);
    assertEq(wasmDis(ins.exports.instanceCall, 'stable', true).match(/call.*\n(?:.*movq.*\n)*.*mov %eax, %eax/).length, 1);
    break;
case "baseline":
    assertEq(wasmDis(ins.exports.wasm2wasm, 'stable', true).match(/call.*\n.*add.*%rsp\n.*mov %eax, %eax/).length, 1);
    assertEq(wasmDis(ins.exports.wasm2import, 'stable', true).match(/call.*\n.*add.*%rsp\n(?:.*movq.*\n)*.*mov %eax, %eax/).length, 1);
    assertEq(wasmDis(ins.exports.wasmIndirect, 'stable', true).match(/call.*\n.*add.*%rsp\n(?:.*movq.*\n)*.*mov %eax, %eax/).length, 1);
    assertEq(wasmDis(ins.exports.instanceCall, 'stable', true).match(/call.*\n.*add.*%rsp\n(?:.*movq.*\n)*.*mov %eax, %eax/).length, 1);
    break;
default:
    throw "Unexpected compile mode";
}