summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/wasm-getAllColumnOffsets.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/debug/wasm-getAllColumnOffsets.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 '')
-rw-r--r--js/src/jit-test/tests/debug/wasm-getAllColumnOffsets.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/wasm-getAllColumnOffsets.js b/js/src/jit-test/tests/debug/wasm-getAllColumnOffsets.js
new file mode 100644
index 0000000000..05b032397e
--- /dev/null
+++ b/js/src/jit-test/tests/debug/wasm-getAllColumnOffsets.js
@@ -0,0 +1,41 @@
+// |jit-test| test-also=--wasm-compiler=optimizing; skip-if: !wasmDebuggingEnabled()
+
+// Tests that wasm module scripts have column and line to bytecode offset
+// information when source text is generated.
+
+load(libdir + "asserts.js");
+
+// Checking if experimental format generates internal source map to binary file
+// by querying debugger scripts getAllColumnOffsets.
+function getAllOffsets(wast) {
+ var sandbox = newGlobal({newCompartment: true});
+ var dbg = new Debugger();
+ dbg.addDebuggee(sandbox);
+ dbg.allowWasmBinarySource = true;
+ sandbox.eval(`
+ var wasm = wasmTextToBinary('${wast}');
+ var m = new WebAssembly.Instance(new WebAssembly.Module(wasm));
+ `);
+ var wasmScript = dbg.findScripts().filter(s => s.format == 'wasm')[0];
+ return wasmScript.getAllColumnOffsets();
+}
+
+var offsets1 = getAllOffsets('(module \
+ (func (nop)) \
+ (func (drop (f32.sqrt (f32.add (f32.const 1.0) (f32.const 2.0))))) \
+)');
+
+// There shall be total 5 lines with single and unique offset per line.
+var usedOffsets = Object.create(null),
+ usedLines = Object.create(null);
+assertEq(offsets1.length, 5);
+
+offsets1.forEach(({offset, lineNumber, columnNumber}) => {
+ assertEq(offset > 0, true);
+ assertEq(lineNumber > 0, true);
+ assertEq(columnNumber > 0, true);
+ usedOffsets[offset] = true;
+ usedLines[lineNumber] = true;
+});
+assertEq(Object.keys(usedOffsets).length, 5);
+assertEq(Object.keys(usedLines).length, 5);