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/inlining/getelem-getter-id-mismatch.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/inlining/getelem-getter-id-mismatch.js')
-rw-r--r-- | js/src/jit-test/tests/ion/inlining/getelem-getter-id-mismatch.js | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/ion/inlining/getelem-getter-id-mismatch.js b/js/src/jit-test/tests/ion/inlining/getelem-getter-id-mismatch.js new file mode 100644 index 0000000000..57a2c0ff68 --- /dev/null +++ b/js/src/jit-test/tests/ion/inlining/getelem-getter-id-mismatch.js @@ -0,0 +1,113 @@ +// Ensure BaselineInspector properly handles mixed atom/symbols when determining +// whether or not a jsop_getelem access to a getter can be inlined. + +// Defined outside of the test functions to ensure they're recognised as +// constants in Ion. +var atom1 = "prop1"; +var atom2 = "prop2"; +var sym1 = Symbol(); +var sym2 = Symbol(); + +function testAtomAtom() { + var holder = { + get [atom1]() { return 1; }, + get [atom2]() { return 2; }, + }; + + function get(name) { + // Single access point called with different atoms. + return holder[name]; + } + + function f() { + for (var i = 0; i < 1000; ++i) { + var x = get(atom1); + var y = get(atom2); + assertEq(x, 1); + assertEq(y, 2); + } + } + + for (var i = 0; i < 2; i++) { + f(); + } +} +testAtomAtom(); + +function testAtomSymbol() { + var holder = { + get [atom1]() { return 1; }, + get [sym2]() { return 2; }, + }; + + function get(name) { + // Single access point called with atom and symbol. + return holder[name]; + } + + function f() { + for (var i = 0; i < 1000; ++i) { + var x = get(atom1); + var y = get(sym2); + assertEq(x, 1); + assertEq(y, 2); + } + } + + for (var i = 0; i < 2; i++) { + f(); + } +} +testAtomSymbol(); + +function testSymbolAtom() { + var holder = { + get [sym1]() { return 1; }, + get [atom2]() { return 2; }, + }; + + function get(name) { + // Single access point called with symbol and atom. + return holder[name]; + } + + function f() { + for (var i = 0; i < 1000; ++i) { + var x = get(sym1); + var y = get(atom2); + assertEq(x, 1); + assertEq(y, 2); + } + } + + for (var i = 0; i < 2; i++) { + f(); + } +} +testSymbolAtom(); + +function testSymbolSymbol() { + var holder = { + get [sym1]() { return 1; }, + get [sym2]() { return 2; }, + }; + + function get(name) { + // Single access point called with different symbols. + return holder[name]; + } + + function f() { + for (var i = 0; i < 1000; ++i) { + var x = get(sym1); + var y = get(sym2); + assertEq(x, 1); + assertEq(y, 2); + } + } + + for (var i = 0; i < 2; i++) { + f(); + } +} +testSymbolSymbol(); |