commit e7ac05af823bc27101b31cd7c1792428f09fd6fb
parent 82a381ce25f5cd47ce64b0f80f63eae721be0271
Author: Iain Ireland <iireland@mozilla.com>
Date: Wed, 10 Dec 2025 16:44:07 +0000
Bug 2004827: Avoid redundant branches in visitIsNullOrLikeUndefinedAndBranchV r=mgaudet
Differential Revision: https://phabricator.services.mozilla.com/D275563
Diffstat:
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp
@@ -13528,6 +13528,14 @@ void CodeGenerator::visitIsNullOrLikeUndefinedAndBranchV(
Label* ifTrueLabel = getJumpLabelForBranch(ifTrue);
Label* ifFalseLabel = getJumpLabelForBranch(ifFalse);
+ bool extractObject = !intact;
+ Register objreg = Register::Invalid();
+#if defined(DEBUG) || defined(FUZZING)
+ // always extract objreg if we're in debug and
+ // assertObjectDoesNotEmulateUndefined;
+ extractObject = true;
+#endif
+
{
ScratchTagScope tag(masm, value);
masm.splitTagForTest(value, tag);
@@ -13535,21 +13543,13 @@ void CodeGenerator::visitIsNullOrLikeUndefinedAndBranchV(
masm.branchTestNull(Assembler::Equal, tag, ifTrueLabel);
masm.branchTestUndefined(Assembler::Equal, tag, ifTrueLabel);
- masm.branchTestObject(Assembler::NotEqual, tag, ifFalseLabel);
+ if (extractObject) {
+ masm.branchTestObject(Assembler::NotEqual, tag, ifFalseLabel);
+ objreg = masm.extractObject(value, ToTempUnboxRegister(lir->temp1()));
+ }
}
- bool extractObject = !intact;
-#if defined(DEBUG) || defined(FUZZING)
- // always extract objreg if we're in debug and
- // assertObjectDoesNotEmulateUndefined;
- extractObject = true;
-#endif
-
- Register objreg = Register::Invalid();
Register scratch = ToRegister(lir->temp0());
- if (extractObject) {
- objreg = masm.extractObject(value, ToTempUnboxRegister(lir->temp1()));
- }
if (!intact) {
// Objects that emulate undefined are loosely equal to null/undefined.
OutOfLineTestObject* ool = new (alloc()) OutOfLineTestObject();
@@ -13559,7 +13559,9 @@ void CodeGenerator::visitIsNullOrLikeUndefinedAndBranchV(
} else {
assertObjectDoesNotEmulateUndefined(objreg, scratch, lir->cmpMir());
// Bug 1874905. This would be nice to optimize out at the MIR level.
- masm.jump(ifFalseLabel);
+ if (!isNextBlock(ifFalse->lir())) {
+ masm.jump(ifFalseLabel);
+ }
}
}