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/ion/recover-newarrayiterator.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/ion/recover-newarrayiterator.js')
-rw-r--r-- | js/src/jit-test/tests/ion/recover-newarrayiterator.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/ion/recover-newarrayiterator.js b/js/src/jit-test/tests/ion/recover-newarrayiterator.js new file mode 100644 index 0000000000..3d98640a2c --- /dev/null +++ b/js/src/jit-test/tests/ion/recover-newarrayiterator.js @@ -0,0 +1,66 @@ +var max = 40; +setJitCompilerOption("ion.warmup.trigger", max - 10); + +// Prevent the GC from cancelling Ion compilations, when we expect them to succeed +gczeal(0); + +function selfhosted() { + if (typeof getSelfHostedValue === "undefined") + return; + + var NewArrayIterator = getSelfHostedValue("NewArrayIterator"); + var iter = NewArrayIterator(); + bailout(); + // assertRecoveredOnBailout(iter, true); +} + +function iterator(i) { + var array = [1, i]; + var iter = array[Symbol.iterator](); + assertEq(iter.next().value, 1); + bailout(); + // This sometimes fails + // assertRecoveredOnBailout(iter, true); + var result = iter.next(); + assertEq(result.value, i); + assertEq(result.done, false); + assertEq(iter.next().done, true); +} + +function forof(i) { + var array = [1, i]; + var first = true; + + for (var x of array) { + if (first) { + assertEq(x, 1); + bailout(); + first = false; + } else { + assertEq(x, i); + } + } +} + +var data = { + a: 'foo', + b: {c: 'd'}, + arr: [1, 2, 3] +}; + +function fn() { + var {a, b:{c:b}, arr:[, c]} = data; + return c; +} + +function destructuring() { + for (var i = 0; i < max; i++) + assertEq(fn(), 2); +} + +for (var i = 0; i < max; i++) { + selfhosted(); + iterator(i); + forof(i); + destructuring(); +} |