Skip to content

Commit 61af7a9

Browse files
committed
Do not dead-store type check bailouts on stores by default
1 parent 705338b commit 61af7a9

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

lib/Backend/BackwardPass.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,6 +2232,13 @@ BackwardPass::DeadStoreTypeCheckBailOut(IR::Instr * instr)
22322232
return;
22332233
}
22342234

2235+
// By default, do not do this for stores, as it makes the presence of type checks unpredictable in the forward pass.
2236+
// For instance, we can't predict which stores may cause reallocation of aux slots.
2237+
if (!PHASE_ON(Js::DeadStoreTypeChecksOnStoresPhase, this->func) && instr->GetDst() && instr->GetDst()->IsSymOpnd())
2238+
{
2239+
return;
2240+
}
2241+
22352242
IR::BailOutKind oldBailOutKind = instr->GetBailOutKind();
22362243
if (!IR::IsTypeCheckBailOutKind(oldBailOutKind))
22372244
{

lib/Backend/Lower.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7419,7 +7419,7 @@ Lowerer::GenerateStFldWithCachedType(IR::Instr *instrStFld, bool* continueAsHelp
74197419

74207420
if (hasTypeCheckBailout)
74217421
{
7422-
AssertMsg(PHASE_ON1(Js::ObjTypeSpecIsolatedFldOpsWithBailOutPhase) || !propertySymOpnd->IsTypeDead() || propertySymOpnd->TypeCheckRequired(),
7422+
AssertMsg(PHASE_ON1(Js::ObjTypeSpecIsolatedFldOpsWithBailOutPhase) || !PHASE_ON(Js::DeadStoreTypeChecksOnStoresPhase, this->m_func) || !propertySymOpnd->IsTypeDead() || propertySymOpnd->TypeCheckRequired(),
74237423
"Why does a field store have a type check bailout, if its type is dead?");
74247424

74257425
if (instrStFld->GetBailOutInfo()->bailOutInstr != instrStFld)
@@ -7481,7 +7481,7 @@ Lowerer::GenerateCachedTypeCheck(IR::Instr *instrChk, IR::PropertySymOpnd *prope
74817481
// cache and no type check bailout. In the latter case, we can wind up doing expensive failed equivalence checks
74827482
// repeatedly and never rejit.
74837483
bool doEquivTypeCheck =
7484-
(instrChk->HasEquivalentTypeCheckBailOut() && propertySymOpnd->TypeCheckRequired()) ||
7484+
instrChk->HasEquivalentTypeCheckBailOut() ||
74857485
(propertySymOpnd->HasEquivalentTypeSet() &&
74867486
!(propertySymOpnd->HasFinalType() && propertySymOpnd->HasInitialType()) &&
74877487
!propertySymOpnd->MustDoMonoCheck() &&

lib/Common/ConfigFlagsList.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ PHASE(All)
158158
PHASE(DepolymorphizeInlinees)
159159
PHASE(ReuseAuxSlotPtr)
160160
PHASE(PolyEquivTypeGuard)
161+
PHASE(DeadStoreTypeChecksOnStores)
161162
#if DBG
162163
PHASE(SimulatePolyCacheWithOneTypeForFunction)
163164
#endif

0 commit comments

Comments
 (0)