diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/debug/Script-getEffectfulOffsets.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/debug/Script-getEffectfulOffsets.js')
-rw-r--r-- | js/src/jit-test/tests/debug/Script-getEffectfulOffsets.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/Script-getEffectfulOffsets.js b/js/src/jit-test/tests/debug/Script-getEffectfulOffsets.js new file mode 100644 index 0000000000..2221b7e6cd --- /dev/null +++ b/js/src/jit-test/tests/debug/Script-getEffectfulOffsets.js @@ -0,0 +1,67 @@ +// Check that Script.getEffectfulOffsets behaves sensibly. + +var g = newGlobal({newCompartment: true}); +var dbg = Debugger(g); +var numEffectfulOperations; + +function onNewScript(script) { + script.getChildScripts().forEach(onNewScript); + numEffectfulOperations += script.getEffectfulOffsets().length; +} +dbg.onNewScript = onNewScript; + +function test(code, expected) { + numEffectfulOperations = 0; + g.eval(` +function f(a, b, c) { +${code} +} +`); + assertEq(numEffectfulOperations, expected); +} + +const base = 1; +test("", base); + +test("a.f = 0", base + 1); +test("a.f++", base + 1); +test("return a.f", base + 0); +test("a[b] = 0", base + 1); +test("a[b]++", base + 1); +test("return a[b]", base + 0); +test("a = 0", base + 0); +test("d = 0", base + 1); +test("with (a) { b = 0; }", base + 7); +test("let o = {}; ({x: o.x} = { x: 10 })", base + 1); +test("var x", base + 0); + +// d is not closed over, and "let d = 0;" uses InitLexical, +// which is non-effectful. +test(` +let d = 10; +`, base + 0); + +// d is closed over, and "let d = 0;" uses InitAliasedLexical with hops == 0, +// which is non-effectful. +test(` +let d = 10; +function g() { + d; +} +`, base + 0); + +// Private accessor uses InitAliasedLexical with hops == 1, +// which is currently marked as effectful. +// Please fix this test if it's marked as non-effectful in the future. +test(` +class B { + set #x(x) {} +} +`, base + 1); + +test(` +class B { + get #x() {} + set #x(x) {} +} +`, base + 2); |