diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/jit-test/tests/debug/wasm-getAllColumnOffsets.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/debug/wasm-getAllColumnOffsets.js')
-rw-r--r-- | js/src/jit-test/tests/debug/wasm-getAllColumnOffsets.js | 41 |
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..58e85f1d84 --- /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 8 lines with single and unique offset per line. +var usedOffsets = Object.create(null), + usedLines = Object.create(null); +assertEq(offsets1.length, 8); + +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, 8); +assertEq(Object.keys(usedLines).length, 8); |