Bug 1789821: Don't DCE MMinMaxArray r=jandem

Differential Revision: https://phabricator.services.mozilla.com/D156881
This commit is contained in:
Iain Ireland 2022-09-09 16:21:27 +00:00
parent 98ab6b639b
commit 3c329f99d6
2 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,14 @@
function foo(x) {
Math.max(...[x]);
}
with ({}) {}
for (let i = 0; i < 100; i++) {
foo(0);
}
let called = false;
const evil = { valueOf: () => { called = true; } };
foo(evil);
assertEq(called, true);

View File

@ -4430,6 +4430,11 @@ class MMinMaxArray : public MUnaryInstruction, public SingleObjectPolicy::Data {
: MUnaryInstruction(classOpcode, array), isMax_(isMax) {
MOZ_ASSERT(type == MIRType::Int32 || type == MIRType::Double);
setResultType(type);
// We can't DCE this, even if the result is unused, in case one of the
// elements of the array is an object with a `valueOf` function that
// must be called.
setGuard();
}
public: