Bug 1894456: Handle Float32 for null and undefined comparisons r=jandem

Differential Revision: https://phabricator.services.mozilla.com/D209176
This commit is contained in:
Iain Ireland 2024-05-02 17:54:58 +00:00
parent e024c86bb9
commit 077138cc3d
3 changed files with 22 additions and 1 deletions

View file

@ -0,0 +1,6 @@
var f32 = new Float32Array(1);
for (var i = 0; i < 50; i++) {
if (f32[0] != null) {
}
try {} catch {}
}

View file

@ -0,0 +1,6 @@
var f32 = new Float32Array(1);
for (var i = 0; i < 50; i++) {
if (f32[0] != undefined) {
}
try {} catch {}
}

View file

@ -229,7 +229,16 @@ bool ComparePolicy::adjustInputs(TempAllocator& alloc,
switch (compare->compareType()) {
case MCompare::Compare_Undefined:
case MCompare::Compare_Null:
// Nothing to do for undefined and null, lowering handles all types.
MOZ_ASSERT(compare->rhs()->type() == MIRType::Undefined ||
compare->rhs()->type() == MIRType::Null);
// IF the operand is float32, we must convert it to a double.
if (compare->lhs()->type() == MIRType::Float32) {
MInstruction* replace = MToDouble::New(alloc, compare->lhs());
def->block()->insertBefore(def, replace);
def->replaceOperand(0, replace);
return replace->typePolicy()->adjustInputs(alloc, replace);
}
// GVN and lowering handle all other types.
return true;
case MCompare::Compare_Int32:
return convertOperand(0, MIRType::Int32) &&