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/for-of/iterclose-dynamic-slot-throw.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/for-of/iterclose-dynamic-slot-throw.js')
-rw-r--r-- | js/src/jit-test/tests/for-of/iterclose-dynamic-slot-throw.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/for-of/iterclose-dynamic-slot-throw.js b/js/src/jit-test/tests/for-of/iterclose-dynamic-slot-throw.js new file mode 100644 index 0000000000..5f91160da2 --- /dev/null +++ b/js/src/jit-test/tests/for-of/iterclose-dynamic-slot-throw.js @@ -0,0 +1,55 @@ +var counter = 0; +const iterable = { + [Symbol.iterator]() { + return { + i: 0, + + // Force the return method into a dynamic slot. + x0: 0, x1: 0, x2: 0, x3: 0, x4: 0, x5: 0, x6: 0, x7: 0, x8: 0, + x9: 0, x10: 0, x11: 0, x12: 0, x13: 0, x14: 0, x15: 0, x16: 0, + x17: 0, x18: 0, x19: 0, x20: 0, x21: 0, x22: 0, x23: 0, x24: 0, + + next() { + return { value: this.i++, done: false } + }, + return() { + counter += 1; + return { value: undefined, done: true }; + } + }; + } +} + +function closeIter(o) { + for (var x of o) { + if (x == 2) { + throw "good"; + } + } +} + +function test() { + with ({}) {} + counter = 0; + for (var i = 0; i < 100; i++) { + var caught = "bad"; + try { + closeIter(iterable) + } catch (e) { + caught = e; + } + assertEq(caught, "good"); + } + assertEq(counter, 100) +} + +with ({}) {} + +test(); + +// Force an IC in Ion. +try { + closeIter([1,2,3]); +} catch {} + +test(); |