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/testObjectHasPrototype.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/jit-test/tests/ion/testObjectHasPrototype.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/ion/testObjectHasPrototype.js b/js/src/jit-test/tests/ion/testObjectHasPrototype.js new file mode 100644 index 0000000000..0fce075c5b --- /dev/null +++ b/js/src/jit-test/tests/ion/testObjectHasPrototype.js @@ -0,0 +1,63 @@ +setJitCompilerOption("ion.warmup.trigger", 4); + +var ObjectHasPrototype = getSelfHostedValue("ObjectHasPrototype"); + +var StringProto = String.prototype; +var ObjectProto = Object.prototype; + +function testBasic() { + var f = function() { + assertEq(ObjectHasPrototype(StringProto, ObjectProto), true); + }; + for (var i = 0; i < 40; i++) { + f(); + } +} +testBasic(); + +function testProtoChange(proto) { + var f = function(expected) { + assertEq(ObjectHasPrototype(StringProto, ObjectProto), expected); + }; + var expected = true; + for (var i = 0; i < 120; i++) { + f(expected); + if (i == 40) { + Object.setPrototypeOf(StringProto, proto); + expected = false; + } + if (i == 80) { + Object.setPrototypeOf(StringProto, ObjectProto); + expected = true; + } + } +} +testProtoChange(null); +// Different singleton +testProtoChange(Function.prototype); +// native non-singleton +testProtoChange(/a/); +// non-native non-singleton +testProtoChange({}); + +var Int32ArrayProto = Int32Array.prototype; +var TypedArrayProto = Object.getPrototypeOf(Int32ArrayProto); +function testProtoProtoChange(proto) { + var f = function() { + assertEq(ObjectHasPrototype(Int32ArrayProto, TypedArrayProto), true); + }; + for (var i = 0; i < 120; i++) { + f(); + if (i == 40) + Object.setPrototypeOf(TypedArrayProto, proto); + if (i == 80) + Object.setPrototypeOf(TypedArrayProto, Object); + } +} +testProtoProtoChange(null); +// Different singleton +testProtoProtoChange(Function.prototype); +// native non-singleton +testProtoProtoChange(/a/); +// non-native non-singleton +testProtoProtoChange({}); |