diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/jit-test/tests/cacheir/bug1420910.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/cacheir/bug1420910.js')
-rw-r--r-- | js/src/jit-test/tests/cacheir/bug1420910.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/cacheir/bug1420910.js b/js/src/jit-test/tests/cacheir/bug1420910.js new file mode 100644 index 0000000000..41d17376dd --- /dev/null +++ b/js/src/jit-test/tests/cacheir/bug1420910.js @@ -0,0 +1,35 @@ +// Testing InstanceOf IC. + +Array.prototype.sum = function() { + return this.reduce(( acc, cur ) => acc + cur, 0); +} + + +Iters = 20; + +function resultArray(fn, obj) { + res = new Array(); + for (var x = 0; x < Iters; x++) { + res.push(fn(obj) ? 1 : 0); + } + return res; +} + +// Ensure alteration of .prototype invalidates IC +function basic() {}; + +protoA = { prop1: "1"}; +basic.prototype = protoA; + +io1 = x => { return x instanceof basic; } + +var x = new basic(); +beforePrototypeModification = resultArray(io1,x).sum(); //Attach and test IC +assertEq(beforePrototypeModification,Iters); + +basic.prototype = {}; // Invalidate IC +afterPrototypeModification = resultArray(io1,x).sum(); //Test +assertEq(afterPrototypeModification,0); + +//Primitive LHS returns false. +assertEq(resultArray(io1,0).sum(),0);
\ No newline at end of file |