summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/disasm.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/wasm/disasm.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/wasm/disasm.js')
-rw-r--r--js/src/jit-test/tests/wasm/disasm.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/disasm.js b/js/src/jit-test/tests/wasm/disasm.js
new file mode 100644
index 0000000000..9e9a3f2116
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/disasm.js
@@ -0,0 +1,43 @@
+// |jit-test| skip-if: !hasDisassembler()
+
+// Test that the disassembler is reasonably sane.
+
+var mod = new WebAssembly.Module(wasmTextToBinary(`
+(module
+ (func $hum (import "m" "hum") (param i32) (result f64))
+ (memory 1)
+ (func $hi (export "f") (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (result i32)
+ (i32.add (i32.load (local.get 5)) (i32.load (local.get 6))))
+ (func $ho (param i32) (result i32) (i32.const 37))
+)
+`));
+
+// The following capture the disassembly as a string. We can't really check
+// that no other output is produced.
+
+var s = wasmDis(mod, {tier:'best', asString:true});
+assertEq(typeof s, "string")
+assertEq(s.match(/Kind = Function/g).length, 3)
+
+var ins = new WebAssembly.Instance(mod, {m:{hum:(x) => x+0.5}});
+var s = wasmDis(ins, {tier:'best', asString:true});
+assertEq(typeof s, "string")
+assertEq(s.match(/Kind = Function/g).length, 3)
+
+var s = wasmDis(ins.exports.f, {tier:'best', asString:true})
+assertEq(typeof s, "string")
+
+var s = wasmDis(ins, {asString:true, kinds:"InterpEntry,ImportInterpExit,Function"})
+assertEq(typeof s, "string")
+assertEq(s.match(/Kind = Function/g).length, 3)
+assertEq(s.match(/Kind = InterpEntry/g).length, 1)
+assertEq(s.match(/Kind = ImportInterpExit/g).length, 1)
+assertEq(s.match(/name = hi/g).length, 2)
+assertEq(s.match(/name = ho/g).length, 1)
+assertEq(s.match(/name = hum/g).length, 2)
+
+// This one prints to stderr, we can't check the output but we can check that a
+// string is not returned.
+
+var s = wasmDis(ins, {tier:'best'})
+assertEq(typeof s, "undefined")