From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../ion/inlining/getelem-getter-id-mismatch.js | 113 +++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 js/src/jit-test/tests/ion/inlining/getelem-getter-id-mismatch.js (limited to 'js/src/jit-test/tests/ion/inlining/getelem-getter-id-mismatch.js') 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(); -- cgit v1.2.3